Skip to content Skip to sidebar Skip to footer

Get Latitude Longitude From Google Maps Itinerary

I would like to know if someone can help me about this point. I have a script based on google maps who calculate itinerary. I would like to know if it is possible to get an array o

Solution 1:

The DirectionsService class will give you a response with a DirectionsResult object. This object has a property called overview_path that gives, from the docs:

An array of LatLngs representing the entire course of this route. The path is simplified in order to make it suitable in contexts where a small number of vertices is required (such as Static Maps API URLs).

You can use these to perform places searches (with the places library) to get points of interest, etc, within a radius from each LatLng that's returned in the overview_path array.

Example:

var request = {
  origin: start_point,
  destination: end_point,
  travelMode: google.maps.TravelMode.DRIVING
};

var directionsService = new google.maps.DirectionsService();
directionsService.route(request, function(response, status) {
  if (status == google.maps.DirectionsStatus.OK) {
    var path = (response.routes[0].overview_path);
  }
});

Post a Comment for "Get Latitude Longitude From Google Maps Itinerary"