Protocol

MKMapViewDelegate

Optional methods that you use to receive map-related update messages.

Overview

Because many map operations require the MKMapView class to load data asynchronously, the map view calls these methods to notify your application when specific operations complete. The map view also uses these methods to request annotation and overlay views and to manage interactions with those views.

Before releasing an MKMapView object for which you have set a delegate, remember to set that object’s delegate property to nil.

Topics

Responding to Map Position Changes

func mapView(MKMapView, regionWillChangeAnimated: Bool)

Tells the delegate that the region displayed by the map view is about to change.

func mapView(MKMapView, regionDidChangeAnimated: Bool)

Tells the delegate that the region displayed by the map view just changed.

Loading the Map Data

func mapViewWillStartLoadingMap(MKMapView)

Tells the delegate that the specified map view is about to retrieve some map data.

func mapViewDidFinishLoadingMap(MKMapView)

Tells the delegate that the specified map view successfully loaded the needed map data.

func mapViewDidFailLoadingMap(MKMapView, withError: Error)

Tells the delegate that the specified view was unable to load the map data.

func mapViewWillStartRenderingMap(MKMapView)

Tells the delegate that the map view is about to start rendering some of its tiles.

func mapViewDidFinishRenderingMap(MKMapView, fullyRendered: Bool)

Tells the delegate that the map view has finished rendering all visible tiles.

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, didUpdate: MKUserLocation)

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

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.

Managing Annotation Views

func mapView(MKMapView, viewFor: MKAnnotation)

Returns the view associated with the specified annotation object.

func mapView(MKMapView, didAdd: [MKAnnotationView])

Tells the delegate that one or more annotation views were added to the map.

func mapView(MKMapView, annotationView: MKAnnotationView, calloutAccessoryControlTapped: UIControl)

Tells the delegate that the user tapped one of the annotation view’s accessory buttons.

Dragging an Annotation View

Selecting Annotation Views

func mapView(MKMapView, didSelect: MKAnnotationView)

Tells the delegate that one of its annotation views was selected.

func mapView(MKMapView, didDeselect: MKAnnotationView)

Tells the delegate that one of its annotation views was deselected.

Managing the Display of Overlays

func mapView(MKMapView, rendererFor: MKOverlay)

Asks the delegate for a renderer object to use when drawing the specified overlay.

func mapView(MKMapView, didAdd: [MKOverlayRenderer])

Tells the delegate that one or more renderer objects were added to the map.

Relationships

Inherits From

See Also

Customizing the Map View Behavior

var delegate: MKMapViewDelegate?

The receiver’s delegate.