中的两个坐标之间绘制路径

中的两个坐标之间绘制路径

本文介绍了在MapView(iOS)中的两个坐标之间绘制路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在iOS中的MapView上绘制两个坐标之间的路径,但我不知道如何。我在一个视图中有两个经度和纬度点。

I am trying to draw a path between two coordinates on a MapView in iOS, but I can't figure out how. I have the two latitude and longitude points in one view.

如何绘制这两点之间的路径?我附上了这个问题的例子。请帮帮我。

How can I draw the path between these two points? I've attached the example with this question. Please help me. Any tutorials and code will be appreciated!

推荐答案

你不能。至少,不使用iOS的内置API方法。

A simple answer is; you can't. At least, not using the built in API methods of iOS.

至今我已经看到,你有三个选择:

As far as i've seen so far, you have three alternatives:


  1. 使用提供此类功能的外部库 - 我确信在GitHub上可以找到很多。

  1. Use an external library that offers such functionality - i'm sure there are plenty to be found on GitHub.

编辑相应的网址,并通过路线请求打开指向Google地图的移动Safari浏览器。

Compile the appropriate url and open mobile safari pointing to Google Maps with a directions request.

使用iOS的内置方法5/6在本地Maps.app中打开路线

Use the built in methods of iOS 5/6 to open your route in the native Maps.app

我在应用中使用了第三种方法但这样做的缺点是,当在地图中查看路线时,用户必须离开您的应用程序。

I've used the third method in an app and this works fine but does come with the disadvantage that users will have to leave your application when viewing directions in Maps. It does however remain consistent and not quite as jarring to the user than opening mobile Safari.

如果你在自己的应用程序中找到了一种方法,我会有兴趣看到你的结果。

If you do find a way to do this inside your own app, i'd be interested in seeing your results.

这篇关于在MapView(iOS)中的两个坐标之间绘制路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 17:50