zoukankan      html  css  js  c++  java
  • 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) {
    
                }
            });
        }
  • 相关阅读:
    hdu 4521 小明系列问题——小明序列(线段树 or DP)
    hdu 1115 Lifting the Stone
    hdu 5476 Explore Track of Point(2015上海网络赛)
    Codeforces 527C Glass Carving
    hdu 4414 Finding crosses
    LA 5135 Mining Your Own Business
    uva 11324 The Largest Clique
    hdu 4288 Coder
    PowerShell随笔3 ---别名
    PowerShell随笔2---初始命令
  • 原文地址:https://www.cnblogs.com/sjfsjf/p/6565638.html
Copyright © 2011-2022 走看看