Instance Method

mapView(_:didUpdate:)

Tells the delegate that the location of the user was updated.

Declaration

optional func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation)

Parameters

mapView

The map view that is tracking the user’s location.

userLocation

The location object representing the user’s latest location. This property may be nil.

Discussion

While the showsUserLocation property is set to true, this method is called whenever a new location update is received by the map view. This method is also called if the map view’s user tracking mode is set to MKUserTrackingMode.followWithHeading and the heading changes.

This method is not called if the application is currently running in the background. If you want to receive location updates while running in the background, you must use the Core Location framework.

See Also

Tracking the User Location

func mapViewWillStartLocatingUser(MKMapView)

Tells the delegate that the map view will start tracking the user’s position.

func mapViewDidStopLocatingUser(MKMapView)

Tells the delegate that the map view stopped tracking the user’s location.

func mapView(MKMapView, didFailToLocateUserWithError: Error)

Tells the delegate that an attempt to locate the user’s position failed.

func mapView(MKMapView, didChange: MKUserTrackingMode, animated: Bool)

Tells the delegate that the user tracking mode changed.