在Mapview Xcode中更新位置 [英] Update Location in Mapview Xcode
本文介绍了在Mapview Xcode中更新位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我当前的项目中.
每一次50 meter
用户移动都需要用户的位置.
I need user's location at every 50 meter
user move.
因此,基本上,打开应用程序后,每个50 meter
更改都需要用户位置,以便在Objective c
中调用Web服务.我也希望在应用程序处于后台状态时运行相同的进程.
So Basically After open application every 50 meter
change I need user location for call web service in Objective c
. Also i want same process run when application is in background state.
预先感谢
推荐答案
在
//create location manager object
locationManager = [[CLLocationManager alloc] init];
//there will be a warning from this line of code
[locationManager setDelegate:self];
//and we want it to be as accurate as possible
//regardless of how much time/power it takes
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
//set the amount of metres travelled before location update is made
[locationManager setDistanceFilter:50];
并添加
if ([CLLocationManager locationServicesEnabled]) {
[self.locationManager startUpdatingLocation];
}
更新
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
CLLocation *location = locations.lastObject;
NSLog(@"%@", location.description);
//In here you get all details like
NSLog(@"latitude = %@",location.coordinate.latitude);
NSLog(@"longitude = %@",location.coordinate.longitude);
NSLog(@"altitude = %@",location.altitude);
NSLog(@"horizontalAccuracy = %@",location.horizontalAccuracy);
NSLog(@"verticalAccuracy = %@",location.verticalAccuracy);
NSLog(@"timestamp = %@",location.timestamp);
NSLog(@"speed = %@",location.speed);
NSLog(@"course = %@",location.course);
}
这篇关于在Mapview Xcode中更新位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文