11164

Get latitude longitude from google maps itinerary

Question:

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

<ul><li>(latitude,longitude, 0)</li> <li>(latitude,longitude, 1)</li> <li>(latitude,longitude, ...)</li> <li>(latitude,longitude, 99)</li> </ul>

I need it because i would like to propose points interest near an itinerary. Example: <a href="https://roadtrippers.com/" rel="nofollow">https://roadtrippers.com/</a>

<ol><li>You select the start of your trip</li> <li>You select the destination of your trip</li> <li>It suggest what you can do near your itinerary</li> </ol>

Answer1:

The DirectionsService class will give you a response with a <a href="https://developers.google.com/maps/documentation/javascript/reference#DirectionsResult" rel="nofollow">DirectionsResult object</a>. This object has a property called overview_path that gives, from the docs:

<blockquote>

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).

</blockquote>

You can use these to perform places searches (with the <a href="https://developers.google.com/maps/documentation/javascript/places" rel="nofollow">places library</a>) 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); } });

Recommend

  • capturing document level keypress events with javascript
  • Grepping a batch ping
  • Converting Swift Data into Int16
  • What is the optimum bulk item count with InsertBatch method in mongodb c# driver?
  • Calendar control without postback
  • React.js, wait for setState to finish before triggering a function?
  • How to accomplish WHERE IN query in Cloud Firestore [duplicate]
  • Can you display multiple maps on the same page with directions using Google Maps JavaScript API v3?
  • Understanding geolocation example
  • OTP encoded polyline same as Google encoded polyline?
  • Use php to trim URL to just domain name by removing protocol and path
  • Confluent's Kafka REST Proxy vs Kafka Client
  • Show data from Google Directions API on Google Maps
  • Accurately measuring elapsed time between machines
  • Issue with infoWindows with multiple markers and directionsDisplay variables in Google Maps API v3
  • mysql_real_escape_string() in .NET Framework
  • Add value from previous row under conditions
  • How to handle date between India Time on Client side and Server date in US Time via mongo
  • Multiple sheet copying from a working sheet to an archive sheet
  • Are these two code snippets using IQueryable and .AsParallel equivalent?
  • Tables vs CSS for positioning and design [duplicate]
  • How to read the particular value from Ping result
  • String Distance Matrix in Python
  • how do I design intermittent via points for travel itinerary
  • Bing Map polyline using MVVM pattern XAML
  • query large table
  • count(*) cannot be selected in PL/SQL
  • Iterate twice through a DataReader
  • Google Maps api v3 get start and end coordinates of a street
  • Redshift Querying: error xx000 disk full redshift
  • Should I or shouldn't I use the CachingConnectionFactory with hornetq 2.4.1
  • Rails Find when some params will be blank
  • Swift: Switch statement fallthrough behavior
  • How to test if a URL from an Eclipse bundle is a directory?
  • Deselecting radio buttons while keeping the View Model in synch
  • ORA-29908: missing primary invocation for ancillary operator
  • How can I estimate amount of memory left with calling System.gc()?
  • How to get next/previous record number?
  • How do you join a server to an Active Directory (domain)?
  • How does Linux kernel interrupt the application?