【发布时间】:2010-05-12 12:57:49
【问题描述】:
我想使用谷歌地图中的 gps 自动定位用户当前位置。 是 mapkit 框架,objective-c 中用于 iphone 的 gps。
【问题讨论】:
我想使用谷歌地图中的 gps 自动定位用户当前位置。 是 mapkit 框架,objective-c 中用于 iphone 的 gps。
【问题讨论】:
在 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;
【讨论】: