API Google Maps doesn't return enough of step

十年热恋 提交于 2019-12-28 07:05:13

问题


I'm making an app with Xamarin.Forms.Maps and then, I need to get all of the steps between two "place id" to make my own polyline. However, when I'm making my request, I get about only thirty five steps.

35 steps.. Between Le Mans (France) and Paris (France).. About 200km but only 35 steps.. The problem isn't that the two points aren't connected to the polyline made, no, the problem is that the polyline get out of the existing road..

Google API direction seems to give me, only, some important information, like important steps, but without following the road.. Does it normal?

PS: This is my request (I use Postman to test it)

https://maps.googleapis.com/maps/api/directions/json?origin=Le Mans&destination=Paris&key=[MY_API_KEY]&travel_mode=DRIVING

回答1:


Are you using the polyline results in each driving step?

I used your example and got 31 start_location that each contain Encoded Polylines for drawing that path on the map.

The "Take the exit toward Paris-Centre Porte de Bercy" step results in:

"polyline": {
   "points": "mn_iHmxqM@[?WA_@Ck@CeAAMGcAEi@Gc@Ke@GUI[IYGSIMIKGECAMIMEA?EAA?A?K?I@A?C?IBE@C@?@C@GBOHEHGJIVIX_@j@"
 },

Decoded that is:

The "Take the exit on the left onto Bd Périphérique" step results in 91 points, etc...

There are hundreds and hundreds of locations points within the results, you just have to decode the locations of each driving step and plot them:

Google's Interactive Poly Line Utility



来源:https://stackoverflow.com/questions/37189634/api-google-maps-doesnt-return-enough-of-step

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