使用MKMapKit查找两点之间的距离 [英] Find distance between two points using MKMapKit

查看:88
本文介绍了使用MKMapKit查找两点之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用iPhone OS 3.2在MKMapView上的两点之间找到以米为单位的欧几里得距离.问题是我在纬度和经度方面拥有这些坐标,这在数学上为我提供了足够的数据来查找距离,但是这将需要一些棘手的三角学.有没有更简单的解决方案?

I'm attempting to find the euclidean distance in meters between two points on an MKMapView using iPhone OS 3.2. The problem is that I have these coordinates in terms of latitude and longitude, which, mathematically provides me enough data to find the distance, but it's going to take some tricky trigonometry. Is there any simpler solution?

谢谢!

推荐答案

CLLocation具有一种为您计算距离的方法:

CLLocation has a method to calculate the distance for you:

- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location

API文档此处

这篇关于使用MKMapKit查找两点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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