从iphone检索当前的lat / long而不显示地图

时间:2011-06-01 15:06:50

标签: objective-c

我需要从iphone获取当前的lat / long而不显示地图。

这可以完成吗?

目标C请。

谢谢你 贝

4 个答案:

答案 0 :(得分:1)

看看CLLocationManager。您可以简单地创建一个实例,将控制器设置为委托,启动实例以获取您的位置,并在CLLocationManagerDelegate委托方法中处理结果,您可以访问坐标。无需地图。

答案 1 :(得分:1)

- (void)startUpdates {
    coreManager = [[CLLocationManager alloc] init];
    coreManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
    coreManager.delegate = self;
    [coreManager startUpdatingLocation];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    // newLocation is location from gps...
    // you'll need to stop coreManager updating when you have a good fix
}

有关详细信息,请参阅Apple docs

答案 2 :(得分:1)

CLLocationManager是您必须使用的接口,以便检索当前的Lat / Long

以下是代码:

locationManager = [[CLLocationManager alloc] init]; 
locationManager.desiredAccuracy = kCLLocationAccuracyBest; 
locationManager.distanceFilter = DISTANCE_FILTER_VALUE;
locationManager.delegate = self; 
[locationManager startUpdatingLocation];

答案 3 :(得分:0)

只需使用CLLocationManager即可。