API Google Maps 没有返回足够的步骤 [英] API Google Maps doesn't return enough of step

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

问题描述

我正在使用 Xamarin.Forms.Maps 制作一个应用程序,然后,我需要获取两个位置 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

解决方案

您是否在每个驾驶步骤中使用 polyline 结果?

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

从左侧出口驶入 Bd Périphérique" 步骤得到 91 分,依此类推...

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

Google 的交互式折线实用程序

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 Google Maps 没有返回足够的步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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