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 of this itinerary with the latitude-longitude every 1 kilometer for example. If the itinerary is 100 kilometers long, i'll get an array with 100 datas
I need it because i would like to propose points interest near an itinerary. Example: https://roadtrippers.com/
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);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.