iPhone:谷歌地图方向 [英] IPhone : google maps directions

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

问题描述

我正在开发一款嵌入了用mkmapkit制作的mapView的iPhone应用程序。
我有两个坐标,我正在追踪这两点之间的方向。

i'm developing an iPhone app which embed a mapView made with mkmapkit. I got two coordinates and I'm tracing the direction between these two points.

一切运作良好。我正在使用谷歌地图api:maps.googleapis.com/maps/api/directions来检索带有方向所有步骤的xml。

Everything works well. I'm using google maps api : maps.googleapis.com/maps/api/directions to retrieve xml with all the steps of the direction.

但有一点非常奇怪:我只是无法理解为什么驾驶方向不准确。
在两个步骤之间,它会跟踪一条右线并且不会沿着道路行走,而行走模式则沿着道路追踪非常准确的方向。

But one thing is very strange : I just can't understand why driving direction is not accurate. Between two steps it trace a right line and don't follow the road while walking travel mode trace a very accurate direction, following roads.

驾驶模式:
http:// www。 michael-blin.fr/misc/aden/google/driving.png

步行模式:
http://www.michael-blin.fr/misc/aden/google/walking .png

我的问题很简单:你有没有使用谷歌地图api,你能理解为什么一个比另一个更精确......

My question is simple : have you ever used the google maps api and can you understand why one is more accurate than the other...

推荐答案

您的行车路线似乎带您沿着主要道路或高速公路行驶,因此每个点之间的行车路线没有变化。你没有说明你从方向api得到的答复,但我的猜测是你正在接收沿着必须改变方向的路线的步骤,例如。高速公路路口等:

Your driving directions seems to take you along major roads or highways, so there are no change of driving directions between each of these points. You have not stated the reply you get from the directions api, but my guess is that you are receiving the steps along the route where you have to change direction, eg. highway junctions, etc:


Google文档:
步骤数组中的每个元素
定义
计算方向的单步。一个步骤是方向的
路线的
最原子单位,包含一步
描述旅程中的特定单
指令。例如。 在W. 4th St.离开
步骤不仅
描述了指令,而且
包含距离和持续时间
有关此步骤
如何与下一步骤相关的信息。对于
示例,表示为合并到
I-80 West的步骤可以包含
37英里和40分钟的持续时间,
表示下一个步数为37
英里/ 40分钟。

Google documentation: Each element in the steps array defines a single step of the calculated directions. A step is the most atomic unit of a direction's route, containing a single step describing a specific, single instruction on the journey. E.g. "Turn left at W. 4th St." The step not only describes the instruction but also contains distance and duration information relating to how this step relates to the following step. For example, a step denoted as "Merge onto I-80 West" may contain a duration of "37 miles" and "40 minutes," indicating that the next step is 37 miles/40 minutes from this step.

当你走路时,你经常轮流在为了获得最短的路线。

When you are walking, you are taking turns more often in order to get the shortest route.

路线api没有为您提供与实际行驶路线相匹配的确切覆盖。只有您进行更改的位置。

The directions api does not provide you with the exact overlays that match the actually roads travelled. Only the positions where you make changes.

或者您可以查看回复中的 overview_polyline 字段。它可能比使用航路点的路径更平滑。

Alternatively you could take a look at the overview_polyline field in the reply. It may have a smoother path than by using the waypoints.

这篇关于iPhone:谷歌地图方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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