Google Direction API and Google Maps App showing different routes for same destination

核能气质少年 提交于 2020-01-10 06:06:25

问题


I am working on an app in which I have to show shortest route. I am using Google Direction API but the result is different from Google Maps app for same destination and travel mode.

https://maps.googleapis.com/maps/api/directions/json?origin=19.107163,72.862375&destination=19.106995400000002,72.8643029&sensor=false&mode=driving&alternatives=true&key=XXXXXXXXXXXXXXXXXX

Since alternative is true I am already using shortest route from available routes (response).

Note : - When I enter lat lng of origin and destination in the map app it shows same result. It shows different result only when we type the origin and destination.


回答1:


I got the solution. When I put destination place_id instead of lat lng it is showing same result as google map app. I don't know how it is working. Such variation not even mentioned in developer docs.

https://maps.googleapis.com/maps/api/directions/json?origin=19.107163,72.862375&destination=place_id:ChIJ_0P9DzjI5zsRf5xuhTv8VCk&sensor=false&mode=driving&alternatives=true&key=XXXXXXXXXXXXXXXXXXXXXX



来源:https://stackoverflow.com/questions/54269684/google-direction-api-and-google-maps-app-showing-different-routes-for-same-desti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!