API谷歌地图没有足够的步骤 [英] API Google Maps doesn't return enough of step

查看:105
本文介绍了API谷歌地图没有足够的步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作Xamarin.Forms.Maps的应用程序,然后我需要获取两个place id之间的所有步骤来制作我自己的多段线。然而,当我提出我的要求时,我只能得到三十五步。

<35>在勒芒(法国)和巴黎(法国)之间..大约200公里,但只有35步..问题是不是两个点没有连接到折线,不,问题是折线走出现有道路。



Google API的方向似乎只给我一些重要的信息,就像重要的步骤一样,但没有遵循道路......这是否正常?

PS:这是我的要求(我使用Postman来测试它)

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


折线结果?



我使用了您的示例,并获得了每个包含



从左边的出口进入BdPériphérique步骤结果为91分,等等......



结果中有成百上千个地点,您只需要解码每个驾驶步骤的位置并绘制它们即可:

谷歌的交互式多线实用程序


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

解决方案

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

这篇关于API谷歌地图没有足够的步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆