开发者

how to use the gps in google map in objective-c

开发者 https://www.devze.com 2022-12-29 19:57 出处:网络
i want to use the gps i开发者_StackOverflown google map to automatically locate the user current location.

i want to use the gps i开发者_StackOverflown google map to automatically locate the user current location. is mapkit framwork , the gps for iphone in objective-c.


in viewDidLoad write

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];

and then implement

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

delegate method newLocation will be user's Location

locationManager is CLLocationManager * locationManager;

0

精彩评论

暂无评论...
验证码 换一张
取 消