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
Examples
SDK JS Reference
- Annotations
- Appendices
- NSExpression(MGLAdditions)
- NSValue(MGLAdditions)
- NSValue(MGLCircleStyleLayerAdditions)
- NSValue(MGLFillExtrusionStyleLayerAdditions)
- NSValue(MGLFillStyleLayerAdditions)
- NSValue(MGLHillshadeStyleLayerAdditions)
- NSValue(MGLLineStyleLayerAdditions)
- NSValue(MGLRasterStyleLayerAdditions)
- NSValue(MGLSymbolStyleLayerAdditions)
- MGLAccountManager
- MGLAnnotationImage
- MGLAnnotationView
- MGLAttributedExpression
- MGLAttributionInfo
- MGLBackgroundStyleLayer
- MGLCircleStyleLayer
- MGLClockDirectionFormatter
- MGLCompassButton
- MGLCompassDirectionFormatter
- MGLComputedShapeSource
- MGLCoordinateFormatter
- MGLDistanceFormatter
- MGLFillExtrusionStyleLayer
- MGLFillStyleLayer
- MGLForegroundStyleLayer
- MGLHeatmapStyleLayer
- MGLHillshadeStyleLayer
- MGLImageSource
- MGLLight
- MGLLineStyleLayer
- MGLLoggingConfiguration
- MGLMapCamera
- MGLMapSnapshot
- MGLMapSnapshotOptions
- MGLMapSnapshotOverlay
- MGLMapSnapshotter
- MGLMapView
- MGLMultiPoint
- MGLMultiPolygon
- MGLMultiPolyline
- MGLNetworkConfiguration
- MGLOfflinePack
- MGLOfflineStorage
- MGLPointAnnotation
- MGLPointCollection
- MGLPolygon
- MGLPolyline
- MGLRasterStyleLayer
- MGLRasterTileSource
- MGLShape
- MGLShapeCollection
- MGLShapeOfflineRegion
- MGLShapeSource
- MGLSource
- MGLStyle
- MGLStyleLayer
- MGLSymbolStyleLayer
- MGLTilePyramidOfflineRegion
- MGLTileSource
- MGLUserLocation
- MGLUserLocationAnnotationView
- MGLUserLocationAnnotationViewStyle
- MGLVectorStyleLayer
- MGLVectorTileSource
- MGLAnnotationVerticalAlignment
- MGLAnnotationViewDragState
- MGLAttributionInfoStyle
- MGLCirclePitchAlignment
- MGLCircleScaleAlignment
- MGLCircleTranslationAnchor
- MGLDEMEncoding
- MGLErrorCode
- MGLFillExtrusionTranslationAnchor
- MGLFillTranslationAnchor
- MGLHillshadeIlluminationAnchor
- MGLIconAnchor
- MGLIconPitchAlignment
- MGLIconRotationAlignment
- MGLIconTextFit
- MGLIconTranslationAnchor
- MGLLightAnchor
- MGLLineCap
- MGLLineJoin
- MGLLineTranslationAnchor
- MGLLoggingLevel
- MGLMapDebugMaskOptions
- MGLOfflinePackState
- MGLOrnamentPosition
- MGLOrnamentVisibility
- MGLRasterResamplingMode
- MGLResourceKind
- MGLSymbolPlacement
- MGLSymbolZOrder
- MGLTextAnchor
- MGLTextJustification
- MGLTextPitchAlignment
- MGLTextRotationAlignment
- MGLTextTransform
- MGLTextTranslationAnchor
- MGLTextWritingMode
- MGLTileCoordinateSystem
- MGLUserTrackingMode
- Formatters
- Geometry
- Location Updates
- Maps
- Offline Maps
- Other Categories
- Other Classes
- Other Constants
- Other Enumerations
- Other Functions
- Other Protocols
- Other Structures
- Other Type Definitions
- Primitive Shapes
- MGLAnnotation
- MGLCalloutView
- MGLCalloutViewDelegate
- MGLCluster
- MGLComputedShapeSourceDataSource
- MGLFeature
- MGLLocationManager
- MGLLocationManagerDelegate
- MGLMapSnapshotterDelegate
- MGLMapViewDelegate
- MGLOfflineRegion
- MGLOfflineStorageDelegate
- MGLOverlay
- MGLStylable
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLCoordinateSpan
- MGLOfflinePackProgress
- MGLSphericalPosition
- MGLTransition
- Style Content
- Style Layers
- Style Primitives
- Styling the Map
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLCoordinateSpan
- MGLOfflinePackProgress
- MGLSphericalPosition
- MGLTransition
- User Interaction
- Customizing Fonts
- Information for Style Authors
- Gesture Recognizers
- Info.plist Keys
- Migrating to Expressions
- Predicates and expressions
- Tile URL Templates
- Working with GeoJSON Data