2

I am creating a route using google.maps.DirectionsService.
What would be the best method to get the list of countries the route goes through? I can't find this info in the DirectionsResult https://developers.google.com/maps/documentation/javascript/reference#DirectionsResult

rhinoeli
  • 151
  • 7
  • 1
    It looks like the directions request contains the string `Entering France`, `Entering Switzerland`, `Entering Italy`, etc. when that route crosses into a new country: http://www.geocodezip.com/v3_example_geo2.asp?addr1=Hawkinge,%20England&addr2=Milan,%20Italy&geocode=1&geocode=2 (however that is probably not documented...) – geocodezip Jan 04 '14 at 22:41
  • @geocodezip My visitors come with different languages, so the textual directions google gives them is also different. I would like a more precise solution. – rhinoeli Jan 05 '14 at 14:08

1 Answers1

0

Each route from the routes array have a overview_path array with all the coordinates. You can geocode each of this coordinates and get the country of it (remember the limitation of geocoding calls!). Isn't the best solution but....

cadetill
  • 1,552
  • 16
  • 24
  • 2
    The overview_path is _simplified_, it does not contain all the coordinates, but is probably adequate for this purpose. However, using the reverse geocoder on all the points of even the simplified overview_path will most likely run into the query limit or rate limit and will probably take a prohibitively long time (unless the route is really short). – geocodezip Jan 04 '14 at 22:32