The MGLMapViewDelegate protocol defines a set of optional methods that you
can use to receive map-related update messages. Because many map operations
require the MGLMapView 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 information about annotations
displayed on the map, such as the styles and interaction modes to apply to
individual annotations.

During the animation, this method may be called many times to report updates to
the viewpoint. Therefore, your implementation of this method should be as lightweight
as possible to avoid affecting performance.

Parameters

Asks the delegate whether the map view should be allowed to change from the
existing camera to the new camera in response to a user gesture.

This method is called as soon as the user gesture is recognized. It is not
called in response to a programmatic camera change, such as by setting the
centerCoordinate property or calling -flyToCamera:completionHandler:.

This method is called many times during gesturing, so you should avoid performing
complex or performance-intensive tasks in your implementation.

Parameters

Tells the delegate that the map view was unable to load data needed for
displaying the map.

This method may be called for a variety of reasons, including a network
connection failure or a failure to fetch the style from the server. You can use
the given error message to notify the user that map data is unavailable.

This method is called any time the map view needs to redraw due to a change in
the viewpoint or style property transition. This method may be called very
frequently, even moreso than -mapViewRegionIsChanging:. Therefore, your
implementation of this method should be as lightweight as possible to avoid
affecting performance.

Parameters

This method is called any time the map view needs to redraw due to a change in
the viewpoint or style property transition. This method may be called very
frequently, even moreso than -mapViewRegionIsChanging:. Therefore, your
implementation of this method should be as lightweight as possible to avoid
affecting performance.

Parameters

This method is called during the initialization of the map view and after any
subsequent loading of a new style. This method is called between the
-mapViewWillStartRenderingMap: and -mapViewDidFinishRenderingMap: delegate
methods. Changes to sources or layers of the current style do not cause this
method to be called.

This method is the earliest opportunity to modify the layout or appearance of
the current style before the map view is displayed to the user.

Parameters

While the showsUserLocation property is set to YES, 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
MGLUserTrackingModeFollowWithHeading and the heading changes, or if it is set
to MGLUserTrackingModeFollowWithCourse and the course 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.

Returns an annotation image object to mark the given point annotation object on
the map.

Implement this method to mark a point annotation with a static image. If you
want to mark a particular point annotation with an annotation view instead,
omit this method or have it return nil for that annotation, then implement
-mapView:viewForAnnotation:.

Static annotation images use less memory and draw more quickly than annotation
views. On the other hand, annotation views are compatible with UIKit, Core
Animation, and other Cocoa Touch frameworks.

Return Value

Returns a view object to mark the given point annotation object on the map.

Implement this method to mark a point annotation with a view object. If you
want to mark a particular point annotation with a static image instead, omit
this method or have it return nil for that annotation, then implement
-mapView:imageForAnnotation: instead.

Annotation views are compatible with UIKit, Core Animation, and other Cocoa
Touch frameworks. On the other hand, static annotation images use less memory
and draw more quickly than annotation views.

The user location annotation view can also be customized via this method. When
annotation is an instance of MGLUserLocation (or equal to the map view’s
userLocation property), return an instance of MGLUserLocationAnnotationView
(or a subclass thereof).

You can use this method to track changes in the selection state of annotation
views.

This method is only called for annotation views. To track changes in the
selection state of all annotations, including those associated with static
annotation images, implement -mapView:didSelectAnnotation:, which is called
immediately before this method is called.

You can use this method to track changes in the selection state of annotation
views.

This method is only called for annotation views. To track changes in the
selection state of all annotations, including those associated with static
annotation images, implement -mapView:didDeselectAnnotation:, which is called
immediately before this method is called.

Return Value

Returns the view to display on the left side of the standard callout bubble.

The left callout view is typically used to convey information about the
annotation or to link to custom information provided by your application.

If the view you specify is a descendant of the UIControl class, you can use
the map view’s delegate to receive notifications when your control is tapped,
by implementing the -mapView:annotation:calloutAccessoryControlTapped:
method. If the view you specify does not descend from UIControl, your view is
responsible for handling any touch events within its bounds.

If this method is absent from the delegate, or if it returns nil, the
standard callout view has no accessory view on its left side. The return value
of this method is ignored if -mapView:calloutViewForAnnotation: is present in
the delegate.

Return Value

Returns the view to display on the right side of the standard callout bubble.

The right callout view is typically used to convey information about the
annotation or to link to custom information provided by your application.

If the view you specify is a descendant of the UIControl class, you can use
the map view’s delegate to receive notifications when your control is tapped,
by implementing the -mapView:annotation:calloutAccessoryControlTapped:
method. If the view you specify does not descend from UIControl, your view is
responsible for handling any touch events within its bounds.

If this method is absent from the delegate, or if it returns nil, the
standard callout view has no accessory view on its right side. The return value
of this method is ignored if -mapView:calloutViewForAnnotation: is present in
the delegate.

Return Value

Tells the delegate that the user tapped one of the accessory controls in the
annotation’s callout view.

In a standard callout view, accessory views contain custom content and are
positioned on either side of the annotation title text. If an accessory view
you specify is a descendant of the UIControl class, the map view calls this
method as a convenience whenever the user taps your view. You can use this
method to respond to taps and perform any actions associated with that control.
For example, if your control displays additional information about the
annotation, you could use this method to present a modal panel with that
information.

If your custom accessory views are not descendants of the UIControl class,
the map view does not call this method. If the annotation has a custom callout
view via the -mapView:calloutViewForAnnotation: method, you can specify the
custom accessory views using the MGLCalloutView protocol’s
leftAccessoryView and rightAccessoryView properties.