Mat*_*son 7 google-maps google-maps-urls
我目前有一个应用程序,它从用户那里获取起点和终点并向谷歌地图方向 API 发送请求,例如:https://maps.googleapis.com/maps/api/directions/xml?key=my_key8&origin=M460PU&destination=NN36NW&sensor=false&mode=driving&units=imperial&departure_time=1501752779
然后,我们显示给定路线的预计行程时间。用户询问我们是否可以添加直接指向 Google 地图的链接,以便他们可以在地图上看到路线并确保它看起来没问题。
我之前见过这样的问题:Link to Google Maps但这似乎是一个简单的 Google 地图搜索的解决方案,在我的例子中,我想从方向 API 中查看一条路线。
我试图弄清楚是否有一种方法可以从 Directions API 响应中获取数据并将其插入到用户可以点击的http://maps.google.com/maps URL 中。有没有人在这方面取得过成功?
正如 @geocodezip 提到的,您应该使用 Google Maps JavaScript API 或 Google Static Maps API 来显示与 Directions API 的输出完全相同的路线。
There is also an option to open Google Maps web site or native app using the Google Maps URLs. You can have a look at the documentation to figure out how to create the URL:
https://developers.google.com/maps/documentation/urls/guide#directions-action
唯一的问题是 Google 地图 URL 不提供任何出发时间参数,因此您始终会获得“立即出发”的路线,与请求不同出发时间的 Web 服务相比,这些路线可能存在差异。
根据您的问题,我认为 Google 地图 URL 可能是
https://www.google.com/maps/dir/?api=1&origin=M460PU&destination=NN36NW&travelmode=driving
归档时间: |
|
查看次数: |
8048 次 |
最近记录: |