perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.08k stars 350 forks source link

how do i retrieve the latitudes/longitudes only from L.LatLng[]? #566

Closed UVERtainment closed 4 years ago

UVERtainment commented 4 years ago

Currently, im just trying to show the coordinates of the route im setting.

routeControl.on('routeselected', function (e) { var coord = e.route.coordinates; var name = e.route.name; alert('Array size = ' + coord.length + '\nCoordinates: \n' + coord.join('\n'));
//$.postJSON('/Map/GetRouteCoordinates', coord); });

however, its showing: L.LatLng(1.22, 1.33) for eg.

i do not want the L.LatLng, i just want the 1.22 and 1.33. i don't think i saw anywhere in the documentation on how to get the lat/long in L.LatLng.

perliedman commented 4 years ago

Use the .lat and .lng properties on the L.LatLng objects.