获取当前的位置信息
2014-11-25 14:23
134 查看
用地图之前要导入MapKit框架
更新当前位置,如果不停止,此方法实时调用,一秒钟更新一次
CLLocationManager * cllocationmanager =[[CLLocationManager alloc] init];
//设置代理
cllocationmanager.delegate = self;
//设置显示区域范围
[cllocationmanager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
//开始加载位置
[cllocationmanager startUpdatingLocation];
//调用的协议方法
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CLLocationDistance altitude = newLocation.altitude;
CLLocationCoordinate2D coordinate = newLocation.coordinate;
NSDate * timep=[location timestamp];
NSLog(@"纬度:%f,经度:%f,高度:%f,时间:%@",coordinate.latitude,coordinate.longitude,altitude,timep);
[manager stopUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations
{
for (CLLocation *location in locations)
{
CLLocationDistance altitude = location.altitude;
CLLocationCoordinate2D coordinate = location.coordinate;
NSLog(@"纬度:%f,经度:%f,高度:%f",coordinate.latitude,coordinate.longitude,altitude);
//创建MKReverseGeocoder实例
// MKReverseGeocoder *mkReverse =[[MKReverseGeocoder alloc] initWithCoordinate:coordinate];
//设置代理
// mkReverse.delegate = self;
//开始反编码
// [mkReverse start];
[self reverseGEO:location];
}
[manager stopUpdatingLocation];
}
更新当前位置,如果不停止,此方法实时调用,一秒钟更新一次
CLLocationManager * cllocationmanager =[[CLLocationManager alloc] init];
//设置代理
cllocationmanager.delegate = self;
//设置显示区域范围
[cllocationmanager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters];
//开始加载位置
[cllocationmanager startUpdatingLocation];
//调用的协议方法
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CLLocationDistance altitude = newLocation.altitude;
CLLocationCoordinate2D coordinate = newLocation.coordinate;
NSDate * timep=[location timestamp];
NSLog(@"纬度:%f,经度:%f,高度:%f,时间:%@",coordinate.latitude,coordinate.longitude,altitude,timep);
[manager stopUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations
{
for (CLLocation *location in locations)
{
CLLocationDistance altitude = location.altitude;
CLLocationCoordinate2D coordinate = location.coordinate;
NSLog(@"纬度:%f,经度:%f,高度:%f",coordinate.latitude,coordinate.longitude,altitude);
//创建MKReverseGeocoder实例
// MKReverseGeocoder *mkReverse =[[MKReverseGeocoder alloc] initWithCoordinate:coordinate];
//设置代理
// mkReverse.delegate = self;
//开始反编码
// [mkReverse start];
[self reverseGEO:location];
}
[manager stopUpdatingLocation];
}
相关文章推荐
- 运行中获取当前执行位置所在类、所在函数等信息
- iPhone获取当前位置信息
- Android GPS获取当前位置信息
- GPS-利用百度SDK获取当前的位置信息
- 利用百度SDK获取当前的位置信息
- IOS 定位(获取当前位置信息)
- Android获取当前位置信息,百分之百有效
- 根据经纬度获取用户当前位置信息
- iOS 10获取当前定位信息,根据位置获取天气
- 定位功能---封装的一个获取当前位置的经纬度信息的类
- 获取当前位置经纬度下的地名以及信息
- Android开发之GPS获取当前位置信息
- iOS定位服务系列之一:获取当前位置信息
- android中获取位置(一)--利用locationManager获取当前经纬度信息
- iOS下获取用户当前位置的信息
- iOS---获取当前位置信息
- PHP获取网页头部信息、获取文件当前位置、获取文件最后修改时间
- iOS获取当前位置信息
- 使用苹果自带地图获取当前位置及周围信息
- 微信JSSDK获取当前地理位置信息