首页 > 代码库 > OpenLayers 3 实现轨迹回放
OpenLayers 3 实现轨迹回放
function PathBack() { var PVLayer = new ol.layer.Vector({ source: new ol.source.Vector({}) }); var pointList = new Array(); map.addLayer(PVLayer); $.ajax({ type: "get", url: "images/zb.json", async: false, contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { var obj = data.T_Project; for (var i = 0; i < obj.length; i++) { var pointFeature = new ol.Feature({ geometry: new ol.geom.Point(ol.proj.transform([parseFloat(obj[i].x), parseFloat(obj[i].y)], ‘EPSG:4326‘, ‘EPSG:3857‘)) }) var propertieList = new Array(); // propertieList.push(obj[i].ID, obj[i].x, obj[i].y, obj[i].Note); propertieList.push(obj[i].ID, obj[i].x, obj[i].y); pointFeature.setProperties(propertieList); if (pointFeature != null) { pointList.push(pointFeature); } } var stoptime = setInterval(function () { if (j + 1 <= pointList.length) { if (j > 0) { var twoCoordinatePoint = new Array(); var coordinateFirst = pointList[j - 1].getGeometry().getCoordinates(); var coordinateSecond = pointList[j].getGeometry().getCoordinates(); twoCoordinatePoint.push(coordinateFirst); twoCoordinatePoint.push(coordinateSecond); var lineString = new ol.geom.LineString(twoCoordinatePoint); var lineFeature = new ol.Feature({ geometry: lineString }); PVLayer.getSource().addFeature(lineFeature); pointList[j - 1].setStyle(null); } pointList[j].setStyle(iconstyle); PVLayer.getSource().addFeature(pointList[j]); } else { clearInterval(stoptime); } j++; }, 300); }, error: function (result) { } }); }
OpenLayers 3 实现轨迹回放
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。