-1

I have a route on map: https://www.google.com/maps/dir/Roundup,+Montana+59072,+USA/2945+Jacklin+Rd,+Victoria,+BC+V9B+5E3,+Canada/@45.7204302,-120.5129496,6z/data=!3m2!4b1!5s0x548f0d04924f69f5:0xef822e581273d32c!4m14!4m13!1m5!1m1!1s0x534784d43e074a11:0x7bd3fabbb2514f50!2m2!1d-108.5417999!2d46.445242!1m5!1m1!1s0x548f0d04880dd0ef:0xf1b45d9fa9fedce0!2m2!1d-123.5085874!2d48.4398998!3e0

And on google maps site they have a warning about changing time zone at destination: image with time zone warning

I want to make the same warning, but can't find "time zone field" in response from Directions Service.

Question: is there a way to get time zone from google maps api Directions Service in DRIVING MODE (NOT TRANSIT) ? https://developers.google.com/maps/documentation/javascript/directions

Alex
  • 1
  • 1

1 Answers1

0

The feature is currently not available for Directions API, however, you may file a Feature Request in the Issue Tracker and share your use case so the engineers can review the feasibility of the feature.

As a workaround, what you may do is scan the results of the request then look for strings like "Passing through Idaho Entering Washington", this way, you'll know that a boundary has been crossed, you may then call a Timezone API request to return the timezone information.

for this sample request:

Origin: Roundup, MT 59072, USA

Destination: 2945 Jacklin Rd, Victoria, BC V9B 5E3, Canada

URL Request: https://maps.googleapis.com/maps/api/directions/json?origin=Roundup%2C%20Montana%2059072%2C%20USA&destination=2945%20Jacklin%20Rd%2C%20Victoria%2C%20BC%20V9B%205E3&mode=driving&key=YOUR_API_KEY

If you inspect the result, you will see in the html_instruction there will be instructions:

"html_instructions":"Merge onto I-90 W
Passing through Idaho
Entering Washington
",

and

"html_instructions":"Merge onto I-5 N
Entering Canada (British Columbia)
",

This will be your basis on whether a timezone has been crossed, but please also note that this may not be very reliable. I would still suggest that you file a Feature Request for this.

Shawn Domingo
  • 1,371
  • 1
  • 11
  • 16