使用iPhone中的谷歌地图计算两个位置之间的距离

编程入门 行业动态 更新时间:2024-10-21 06:35:01
本文介绍了使用iPhone中的谷歌地图计算两个位置之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我只是想计算两个位置之间的距离。 在哪个用户可以输入位置的地址,并从该地址我想要计算它们之间的距离。

是否可以使用这些地址计算CLLocation的距离?

首先,您需要将地址编码为纬度/经度,然后您可以使用CLLocation框架计算距离。 要对地址进行地理编码,您可以使用此转发地理编码API 。

//获取CLLocation两个地址 CLLocation * location = [[CLLocation alloc] initWithLatitude :address.latitude longitude:address.longitude]; //计算它们之间的距离 CLLocationDistance distance = [firstLocation distanceFromLocation:secondLocation];

I just want to calculate distance between two location . In which user can enter both the location's addresses, and from that addresses I want to calculate the distance between them.

Is it possible to calculate distance from CLLocation using these addresses ?

解决方案

First you need to geocode the address to latitude/longitude, then you can use the CLLocation framework to calculate the distance. To geocode the adress, you could use this forward geocoding API.

// get CLLocation fot both addresses CLLocation *location = [[CLLocation alloc] initWithLatitude:address.latitude longitude:address.longitude]; // calculate distance between them CLLocationDistance distance = [firstLocation distanceFromLocation:secondLocation];

更多推荐

使用iPhone中的谷歌地图计算两个位置之间的距离

本文发布于:2023-11-12 20:22:38,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:距离   位置   两个   地图   iPhone

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!