本文介绍了使用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中的谷歌地图计算两个位置之间的距离
发布评论