MGLLocationManagerDelegate
@protocol MGLLocationManagerDelegate <NSObject>
The MGLLocationManagerDelegate
protocol defines a set of methods that respond to location updates from an MGLLocationManager
object that is serving as the location manager of an MGLMapView
.
Responding to Location Updates
-locationManager:didUpdateLocations:
Notifies the delegate with the new location data.
Declaration
Objective-C
- (void)locationManager:(nonnull id<MGLLocationManager>)manager
didUpdateLocations:(nonnull NSArray<CLLocation *> *)locations;
Swift
func locationManager(_ manager: MGLLocationManager, didUpdate locations: [CLLocation])
Parameters
manager
The location manager reporting the update.
locations
An array of CLLocation
objects in chronological order, with the last object representing the most recent location. This array contains multiple CLLocation
objects when MGLMapView
uses its default location manager.
Responding to Heading Updates
-locationManager:didUpdateHeading:
Notifies the delegate with the new heading data.
Declaration
Objective-C
- (void)locationManager:(nonnull id<MGLLocationManager>)manager
didUpdateHeading:(nonnull CLHeading *)newHeading;
Swift
func locationManager(_ manager: MGLLocationManager, didUpdate newHeading: CLHeading)
Parameters
manager
The location manager reporting the update.
newHeading
The new heading update.
-locationManagerShouldDisplayHeadingCalibration:
Asks the delegate if the calibration alert should be displayed.
Declaration
Objective-C
- (BOOL)locationManagerShouldDisplayHeadingCalibration:
(nonnull id<MGLLocationManager>)manager;
Swift
func locationManagerShouldDisplayHeadingCalibration(_ manager: MGLLocationManager) -> Bool
Parameters
manager
The location manager reporting the calibration.
Responding to Location Updates Errors
-locationManager:didFailWithError:
Notifies the delegate that the location manager was unable to retrieve location updates.
Declaration
Objective-C
- (void)locationManager:(nonnull id<MGLLocationManager>)manager
didFailWithError:(nonnull NSError *)error;
Swift
func locationManager(_ manager: MGLLocationManager, didFailWithError error: Error)
Parameters
manager
The location manager reporting the error.
error
An error object containing the error code that indicates why the location manager failed.
-locationManagerDidChangeAuthorization:
Notifies the delegate that the location authorization status has changed.
Declaration
Objective-C
- (void)locationManagerDidChangeAuthorization:
(nonnull id<MGLLocationManager>)manager;
Swift
func locationManagerDidChangeAuthorization(_ manager: MGLLocationManager)
Parameters
manager
The location manager reporting the change.
iOS SDK
SDK JS Reference
- MGLUserLocationAnnotationViewStyle
- MGLAccountManager
- MGLAnnotationImage
- MGLCircleStyleLayer
- MGLMapSnapshot
- NSValue(MGLHillshadeStyleLayerAdditions)
- MGLLight
- MGLCoordinateSpan
- MGLOfflinePack
- MGLAnnotationVerticalAlignment
- MGLSource
- MGLDEMEncoding
- MGLCoordinateSpan
- MGLMapCamera
- MGLTextWritingMode
- MGLIconTranslationAnchor
- NSValue(MGLSymbolStyleLayerAdditions)
- MGLOfflinePackProgress
- MGLMapSnapshotOptions
- Primitive Shapes
- NSValue(MGLAdditions)
- MGLTextPitchAlignment
- MGLSphericalPosition
- MGLCompassDirectionFormatter
- MGLVectorTileSource
- MGLMapViewDelegate
- MGLHillshadeIlluminationAnchor
- MGLIconTextFit
- MGLLocationManagerDelegate
- MGLShape
- Formatters
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLMapSnapshotterDelegate
- MGLAnnotationViewDragState
- MGLComputedShapeSource
- NSValue(MGLCircleStyleLayerAdditions)
- MGLHillshadeStyleLayer
- MGLOverlay
- MGLPolygon
- MGLStyleLayer
- MGLTilePyramidOfflineRegion
- MGLMapView
- MGLTransition
- MGLOfflineStorage
- MGLComputedShapeSourceDataSource
- MGLMapDebugMaskOptions
- MGLClockDirectionFormatter
- MGLTextRotationAlignment
- MGLUserTrackingMode
- NSValue(MGLRasterStyleLayerAdditions)
- MGLAttributionInfo
- MGLRasterStyleLayer
- Style Content
- MGLUserLocation
- MGLRasterTileSource
- MGLFillTranslationAnchor
- Other Protocols
- MGLSphericalPosition
- MGLMapSnapshotter
- MGLRasterResamplingMode
- MGLAnnotationView
- MGLResourceKind
- MGLShapeCollection
- Other Enumerations
- NSExpression(MGLAdditions)
- MGLCirclePitchAlignment
- MGLFillExtrusionTranslationAnchor
- Style Layers
- Other Constants
- MGLCoordinateBounds
- Appendices
- MGLLoggingConfiguration
- Other Structures
- MGLMapSnapshotOverlay
- MGLCircleTranslationAnchor
- User Interaction
- NSValue(MGLLineStyleLayerAdditions)
- MGLErrorCode
- MGLAttributedExpression
- MGLSymbolStyleLayer
- MGLCircleScaleAlignment
- MGLTextTransform
- MGLOrnamentVisibility
- MGLMultiPoint
- MGLShapeSource
- MGLLightAnchor
- MGLCalloutViewDelegate
- MGLCluster
- MGLOfflinePackProgress
- MGLPolyline
- MGLFeature
- MGLAnnotation
- MGLFillStyleLayer
- MGLIconRotationAlignment
- NSValue(MGLFillStyleLayerAdditions)
- Other Classes
- MGLLineTranslationAnchor
- MGLTextAnchor
- Offline Maps
- MGLLocationManager
- MGLStyle
- Other Type Definitions
- NSValue(MGLFillExtrusionStyleLayerAdditions)
- Style Primitives
- MGLTileSource
- MGLTransition
- MGLForegroundStyleLayer
- MGLStylable
- MGLIconPitchAlignment
- MGLOfflineRegion
- MGLHeatmapStyleLayer
- MGLCompassButton
- MGLFillExtrusionStyleLayer
- MGLSymbolPlacement
- MGLMultiPolyline
- MGLOfflinePackState
- MGLImageSource
- MGLCoordinateFormatter
- MGLDistanceFormatter
- MGLCoordinateQuad
- MGLPointCollection
- MGLPointAnnotation
- MGLTextJustification
- MGLOfflineStorageDelegate
- MGLCalloutView
- MGLOrnamentPosition
- MGLUserLocationAnnotationView
- MGLTileCoordinateSystem
- MGLSymbolZOrder
- MGLLineCap
- Other Functions
- MGLNetworkConfiguration
- MGLShapeOfflineRegion
- Styling the Map
- MGLLineJoin
- Maps
- MGLAttributionInfoStyle
- MGLIconAnchor
- MGLBackgroundStyleLayer
- MGLMultiPolygon
- Annotations
- MGLVectorStyleLayer
- Location Updates
- MGLTextTranslationAnchor
- MGLLineStyleLayer
- Other Categories
- Geometry
- MGLLoggingLevel