【问题标题】:How to get time zone, from google maps directions api response, in DRIVING MODE (NOT TRANSIT)如何在驾驶模式(非中转)下从谷歌地图方向 api 响应获取时区
【发布时间】:2019-05-09 11:21:22
【问题描述】:

我在地图上有一条路线: 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

在谷歌地图网站上,他们有关于更改目的地时区的警告: image with time zone warning

我想发出同样的警告,但在路线服务的响应中找不到“时区字段”。

问题:有没有办法从 google maps api Directions Service 在 DRIVING MODE (NOT TRANSIT) 中获取时区? https://developers.google.com/maps/documentation/javascript/directions

【问题讨论】:

  • 路线服务中没有我可以看到的。

标签: api google-maps directions map-directions


【解决方案1】:

该功能目前不适用于Directions API,但是,您可以在Issue Tracker 提交功能请求并分享您的用例,以便工程师审查该功能的可行性。

作为一种解决方法,您可以扫描请求的结果,然后查找诸如“Passing through Idaho Entering Washington”之类的字符串,这样,您就会知道已经越过了边界,然后您可以调用时区 API 请求返回时区信息。

对于这个示例请求:

产地:农达,MT 59072,美国

目的地:2945 Jacklin Rd, Victoria, BC V9B 5E3, Canada

网址请求: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

如果你检查结果,你会在html_instruction看到会有说明:

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

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

这将作为您是否跨越时区的依据,但也请注意,这可能不是很可靠。我仍然建议您为此提交功能请求。

【讨论】:

    猜你喜欢
    • 2019-04-30
    • 2013-05-22
    • 1970-01-01
    • 1970-01-01
    • 2012-12-26
    • 1970-01-01
    • 1970-01-01
    • 2017-09-22
    • 2013-06-21
    相关资源
    最近更新 更多