I'm getting a JSON return like so:


How can I use jQuery to convert this into a line string? Or does leaflet have such a function?

  • Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq. – underdark Oct 26 '15 at 0:02

See the Leaflet polyline documentation:

// create a red polyline from an array of LatLng points
var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);

where latlngs is your JSON result. Here's a quick JS Fiddle example.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.