Search code examples
iphonemapkitmkmapviewcore-locationcoordinate

iPhone: mapView.showUserLocation. VS locationUpdate function


I'm developing on an app that is location-based, I have a mapView set to show the user location (mapView.showUserLocation); I also have a locationUpdate function to retrieve lat/long of current position:

(void)locationUpdate:(CLLocation *)location{} 

After I call the function stopUpdatingLocation to stop the update location, the mapview (blue ball) continues to update my location...

In other word: is there another locationUpdate function is called automatically from the mapview?


Solution

  • I think you might use both MKMapView and CLLocationManager. (void)locationUpdate is executed when there's a position obtained by CLLocationManager. MKMapView uses GPS device independently and updates itself.

    You should stop using showUserLocation and use CLLocationManager to obtain location, then MKMapView to present it.