iOS版:(SWIFT)如何从当前位置显示距离并标注字幕存在标注 [英] iOS: (Swift) How to show distance from current location and exist annotation on annotation subtitle

查看:233
本文介绍了iOS版:(SWIFT)如何从当前位置显示距离并标注字幕存在标注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在对地图应用的基础上使用SWIFT语言的iOS。我想一个建议,因为在我绘制在地图上查看所有的引脚

I am currently working on map application base on iOS using Swift language. I would like an suggestion because after I plot all the pins on map view

(这是我收到使用JSON框架从我的服务器数据调用Alamofire)

(which I receive data from my server using JSON frameworks call Alamofire)

我想在地图上的所有标注的字幕显示来自用户的当前位置的距离。

I would like the subtitle of all annotations on map to show distance from user current location.

现在可以添加注释到地图视图,但只能显示标题和字幕信息基地从我的服务器接收。

Now it can add annotations onto map view but can only show title and subtitle base on information receive from my server.

感谢你。

推荐答案

如果你有两个 CLLocation 的情况下,就可以计算出用下面的code距离:

If you have two CLLocation instances, you can calculate distance with the following code:

var one, two: CLLocation
// assign one and two
let distance = two.distanceFromLocation(one)

CLLocationDistance 就是双击和米计算的距离

这篇关于iOS版:(SWIFT)如何从当前位置显示距离并标注字幕存在标注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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