如何在objective-c中使用谷歌地图中的gps

时间:2010-05-12 04:14:13

标签: iphone gps

我想在谷歌地图中使用gps来自动定位用户当前位置。 是mapkit framwork,在objective-c中为iphone的gps。

1 个答案:

答案 0 :(得分:2)

在viewDidLoad中

self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self; // Tells the location manager to send updates to this object

self.mapView.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[self.locationManager startUpdatingLocation];

然后 实施

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

委托方法newLocation将是用户的位置

locationManager是CLLocationManager * locationManager;