围:-90~90
注意:
CLLocationManager创建对象,必须要用强引用,不然可能会提前释放.
5.计算两点间的距离
1 /**
2 * 计算两点间的距离
3 */
4 -(void)calculateDistance{
5 CLLocation *beijing = [[CLLocation alloc] initWithLatitude:39.54 longitude:116.28];
6 CLLocation *chengdu = [[CLLocation alloc] initWithLatitude:30.67 longitude:104.06];
7 //计算距离(单位是米)
8 CLLocationDistance distance = [beijing distanceFromLocation:chengdu];
9 NSLog(@"北京到成都的距离是:%f米",distance);
10 }
打印结果:
1 2016-05-21 19:50:06.315 地图[2201:79784] 北京到成都的距离是:1483882.846655米
本节内容到这就完了,下一节是地理编码,望大家指正,不明白的可以评论或者留言,我会第一时间回复.谢谢