OpenLayers 3 实现轨迹回放

Posted 破碎s

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 实现轨迹回放的主要内容,如果未能解决你的问题,请参考以下文章

对接腾讯地图API实现车辆轨迹回放

Vue中使用mapBox完成轨迹回放

百度地图上如何实现轨迹回放

在物流行业地图开发中,如何实现车辆轨迹回放?

使用GMap.NET类库,实现地图轨迹回放。(WPF版)

用OpenLayers 在地图上画简单的轨迹怎么画