Google Maps iOS SDK,获取两个位置之间的路线 [英] Google Maps iOS SDK, Getting Directions between 2 locations

查看:27
本文介绍了Google Maps iOS SDK,获取两个位置之间的路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 Google Maps SDK 时,我正在尝试获取 iOS 上两个位置之间的行车路线.我知道我们可以使用两种方法来做到这一点:-

While I am using Google Maps SDK, I am trying to get driving direction between two locations on iOS. I know we can do this using two methods:-

1.) 使用 URL Scheme,为此需要在您的设备上安装 Google Maps App.

1.) Using URL Scheme, for which it is necessary that Google Maps App is installed on your device.

2.) 使用 Directions API,通过请求-响应,然后解析 JSON.显示标记以显示方向.

2.) Using Directions API, via Request-Response and then parsing the JSON. Displaying markers to show the direction.

现在,我的问题是还有其他方法可以在 iOS 上执行此操作吗?我需要显示从我当前位置到我有纬度/经度的特定位置的方向.

Now, my question is there any other way by which I can do this on iOS? I need to show the direction from my current location to a particular location of which i have the Lat/Long.

我的意思是真的不可能简单地将 2 个位置作为参数和 Google Maps SDK 传递给我吗?

I mean is it really not possible to simply pass 2 location as parameter and Google Maps SDK, will give me the directions?

谢谢,

推荐答案

听起来您正在寻找像 Google Maps 应用那样显示路线的 UI Chrome.适用于 iOS 的 Google Maps SDK 将为您绘制地图,但您需要负责额外的导航镶边.

It sounds like you are looking for UI Chrome like the Google Maps app has for showing directions. Google Maps SDK for iOS will paint you a map, but you are responsible for the additional navigation chrome.

您可以使用 Google Directions API 请求路线,然后使用从服务返回的编码路径,用于使用 GMSPolyline"https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_path#a4060269354374332afbb532557c4899e" rel="noreferrer">GMSPath 的 pathFromEncodedPath: 方法.

You can use the Google Directions API to request directions, and then use the encoded path returned from the service to draw a GMSPolyline using GMSPath's pathFromEncodedPath: method.

这篇关于Google Maps iOS SDK,获取两个位置之间的路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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