1

Is it possible during dragable routing we can get latitude and longitude value along the routing way

If it have please leave me a link or solution

Thank for help

Kara
  • 6,115
  • 16
  • 50
  • 57
Plzoenr Bj
  • 23
  • 4

2 Answers2

0
  1. Use the dragend event.
  2. Add a listener to the route
  3. when the dragend event fires get the points out of the route.

Example of how to iterate through the coordinates in a dragged route (look at the getPolylineXml function)

geocodezip
  • 158,664
  • 13
  • 220
  • 245
0

See my example to get LatLng for all points in route

directionsRenderer.addListener("directions_changed", function() {             
  var lat = [];
  var lng = [];
  result = directionsRenderer.getDirections()               
  var myroute = result.routes[0];
  for (var i = 0; i < myroute.legs.length; i++) 
  {
    //console.log(myroute.legs[i].start_location.lat())
    lat[i] = myroute.legs[i].start_location.lat();
    lng[i] = myroute.legs[i].start_location.lng();
  }

    i=myroute.legs.length-1;
    lat[i+1] = myroute.legs[i].end_location.lat();
    lng[i+1] = myroute.legs[i].end_location.lng();

    console.log(lat)
    console.log(lng)                                
});