现在的位置: 首页 > 综合 > 正文

iphone 怎么获得自己的当前位置坐标

2013年08月18日 ⁄ 综合 ⁄ 共 1127字 ⁄ 字号 评论关闭

                                                           iphone  怎么获得自己的当前位置坐标

 1。首先

       #import <CoreLocation/CoreLocation.h>

 

 

2。类里面定义两个变量:

     CLLocationManagerlocationManager;

     CLLocationCoordinate2D         curLocation;

 

3。 类 实现 CLLocationManagerDelegate  代理。

 

 

 

4。实现代码:

 

   

  startUpdatingLocation 是启动对当前位置的搜索,只要 当前位置移动的范围超过 distanceFilter指定的范围,那么就会重新收到

  最新的坐标位置信息。

 

  如果要关闭对位置的更新,需要调用  stopUpdatingLocation。

 

5。 如果获取到用户的当前位置,会有delegate的函数:

   - (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation

fromLocation:(CLLocation *)oldLocation

     被调用。

 

      

 

抱歉!评论已关闭.