MSMapLocationProvider Class (iOS only)
Note
Bing Maps SDK for Android and iOS retirement
Bing Maps SDK for Android and iOS is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps SDK for Android and iOS until June 30th, 2025. Enterprise account customers can continue to use Bing Maps SDK for Android and iOS until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps SDK for Android and iOS will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type.
Azure Maps is Microsoft's next-generation maps and geospatial services for developers. Azure Maps has many of the same features as Bing Maps for Enterprise, and more. To get started with Azure Maps, create a free Azure subscription and an Azure Maps account. For more information about azure Maps, see Azure Maps Documentation. For migration guidance, see Bing Maps Migration Overview.
A location provider to be used to retrieve user location on iOS.
See MapUserLocation for more details on how to start tracking user location with a location provider.
@interface MSMapLocationProvider : NSObject<CLLocationManagerDelegate>
Constructors
Default constructor
Initializes location provider with the default properties from MSMapLocationProviderBuilder. See MSMapLocationProviderBuilder for more details on what the default properties are.
- (instancetype)init
Customizable Constructor
Initializes location provider with the properties set on the builder inside the passed in block. See MSMapLocationProviderBuilder for more details what properties can be set.
- (instancetype)initWithBuilderBlock:(void (^)(MSMapLocationProviderBuilder*))builderBlock
Example:
[[MSMapLocationProvider alloc] initWithBuilderBlock:^(MSMapLocationProviderBuilder* builder) { builder.headingFilter = 3; [builder useLastKnownLocationOnLaunch]; }];
Properties
DesiredAccuracy
Refer to MSMapLocationProviderBuilder for information on what desiredAccuracy represents.
If set is called before location retrieval started, setting will be saved for when location retrieval starts. If set is called after location retrieval started, it will restart with the new setting.
@property(nonatomic) CLLocationAccuracy desiredAccuracy
HeadingFilter
Refer to MSMapLocationProviderBuilder for information on what headingFilter represents.
If set is called before location retrieval started, setting will be saved for when location retrieval starts. If set is called after location retrieval started, it will restart with the new setting.
@property(nonatomic) CLLocationDegrees headingFilter
LastLocation
Returns the last location emitted by this location provider, if any. Returns CLLocation
.
@property(nonatomic, readonly, nullable) CLLocation* lastLocation
Methods
startTracking
Starts tracking the location on the device. This method may be called multiple times and stopTracking should be called once for each call to startTracking that returns MapUserLocationTrackingStateReady.
- (MSMapUserLocationTrackingState)startTracking
stopTracking
Stops a previous call to start tracking. Must be called once for each call to startTracking that returns MapUserLocationTrackingState.READY.
- (void)stopTracking
Events
LocationChanged
Fired when a location event is received while tracking is active.
removeLocationDidChangeHandler returns false if the listener has not been previously added or has been already removed.
- (MSMapHandlerId)addLocationDidChangeHandler:(MSMapLocationChangedHandler)handler - (BOOL)removeLocationDidChangeHandler:(MSMapHandlerId)handlerId
See also: MSMapLocationChangedHandler