Линия Маршрутные точки маршрута не отображается правильно, когда карта закончена - PullRequest
0 голосов
/ 20 июня 2019

Я добавляю в карту путевые точки, как на картинке ниже.В большинстве случаев, точки и линия между точками отображаются правильно, но в одном случае, когда точка находится на финише карты, возникает проблема: линия не следует за точками, но идет в последней точке.игнорируя другие пункты.Пожалуйста, проверьте изображения.

easyFetch(url,
        function(data){
         var obj = JSON.parse(data);
         geojson_layer = new OpenLayers.Layer.Vector("GeoJSON", {
          styleMap: new OpenLayers.StyleMap({
          "default": new OpenLayers.Style({
          pointRadius: 2,
          fillColor: "red",
          fillOpacity: 1,
          strokeColor: "black",
          strokeWidth: 0.1,
          strokeOpacity: 1 } ),
          "select": { fillColor: "#8aeeef",
          strokeColor: "#32a8a9",
          labelYOffset:13,
          label:"${name}"}

          //Text entspricht feature.attributes.name
        }),
        //projection: new OpenLayers.Projection("EPSG:4326"),
        //strategies: [new OpenLayers.Strategy.Fixed()],
        //protocol: new OpenLayers.Protocol.HTTP({
         // url: 'https://api.myjson.com/bins/1gw97c',
          //url:'https://api.myjson.com/bins/sqri8',
          //format: new OpenLayers.Format.GeoJSON()
        // })
        }),

          map.addLayer(geojson_layer); 
        //setTimeout(function() {
        //var points = [];
        //geojson_layer.features.forEach(function(feature) { points.push(feature.geometry); });
        //geojson_layer.addFeatures([
           //new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(points), {}, {})
        //]);
        //}, 5000);
        var features = [];
        var points = [];
        obj.Waypoints.forEach(function(wp) {
        var point = new OpenLayers.Geometry.Point(wp.Lon, wp.Lat).transform(
        new OpenLayers.Projection("EPSG:4326"),
        map.getProjectionObject()
        );
        features.push(new OpenLayers.Feature.Vector(point));
        points.push(point);
        })
        features.push(new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString(points), {}, {}));
        geojson_layer.addFeatures(features);

            //console.log(JSON.stringify(obj));
            //alert(JSON.stringify(obj));
            //console.log("TotalDistance:" + JSON.stringify(obj.TotalDistance));
            //alert("TotalDistance:" + JSON.stringify(obj.TotalDistance));
            document.getElementById('dist').innerHTML = ("TotalDistance:" + JSON.stringify(obj.TotalDistance));
            document.getElementById('TotalDistance').innerHTML = (JSON.stringify(obj.TotalDistance));
...