Calculate distance between 2 point on maps for iOS [closed]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 13:46:35

问题


Is it possible to calculate the distance between 2 close points on iOS using Apple map framework or Google framework? For example, i want to get the distance between this 2 blu point with the highest accuracy possible.

Using google maps or apple maps can i get the 2 coordinate with a lot of digit? how can i calculate the distance in centimeters or millimeters?


回答1:


Try this -

let coordinate0 = CLLocation(latitude: 5.0, longitude: 5.0)
let coordinate1 = CLLocation(latitude: 5.0, longitude: 3.0)
let distanceInMeters = coordinate0.distance(from: coordinate1)



回答2:


Yes, you'll get accurate enough position information. CLLocation has a distance(from: CLLocation) function that does the trick and gives accurate results also for short distances.



来源:https://stackoverflow.com/questions/45533739/calculate-distance-between-2-point-on-maps-for-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!