Search code examples
google-mapsgoogle-maps-api-3directions

Get stopover towns using the Google Maps API (directions)


I am new to the Google Maps API (3.0). I would like to get stopover cities based on a direction query to the Maps API and did not find any documentation on this specific topic so far.

https://developers.google.com/maps/documentation/javascript/directions#Steps

I am getting a direction based on Address A and address B. I would like to know every city that a user would cross during his journey. I found some information about way points (stopovers) but these relate to every stop or street change. I couldn't find any core object so far...


Solution

  • What I would do:

    1. Use the RouteBoxer to find bounds containing the route (fairly small ones)
    2. Use the Places API to return Places of types of city_hall, local_government_office or library (maybe tune that choice a little) inside those bounds.
    3. Take the town data out of those responses, sort them for unique results, then use those.

    Proof of concept, will require tuning for types of locations, distance and area where you are doing the search. Depending on the use and the length of the route, it might be better to use the reverse geocoder on points at some regular interval along the road (100 meters or 1000 meters), that might be quicker and won't use up the Places API quota.