Sunday, 2 August 2015

google maps - Leaflet : How to update polyline ? Live Tracking


        var ColorVar = '#bd0026'; 
var firstpolyline = new L.Polyline(polyList, {
color:ColorVar,
weight: 8,
opacity:0.8,
smoothFactor: 1
}

);
focusId.addLayer(firstpolyline);
}

On the page load , i have using the above code after that i want to update the polyline based on the new data without page refreshing for Live Tracking Concept.



Answer



not sure if this is what you are after:


// get data using ajax. Might be triggered by a button, some other user interaction, or polling remote tracking data
$.get(url, {params}, function(response, {
// on success, remove the old polyline

focusId.removeLayer(firstpolyline);

// refresh the Polyline
polylist = response.polylist;
var firstpolyline = new L.Polyline(polyList, {...} );

// then add the new polyline back to the map
focusId.addLayer(firstpolyline);
})

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...