Aracılığıyla paylaş


MapUserLocation Class

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.

Allows to track the user's location and display it on the map with an accuracy radius and a directionality cone.

Look here for more information on how this class can be used with examples.

Android

public class MapUserLocation

iOS

@interface MSMapUserLocation : NSObject

Overview

There is no direct way to construct a UserLocation class. Instead, MapView holds a UserLocation instance which should be accessed in order to use user location features.

See also: MapView

Android

public class Mapview {
  MapUserLocation getUserLocation()
}

iOS

@interface MSMapView : UIView
@property(nonatomic, readonly) MSMapUserLocation* userLocation
@end

Properties

Visible

Sets user location icon's visibility while tracking continues. If called before tracking was started, setting will be saved but nothing will show until tracking is started. The default value is true.

Android

boolean getVisible()
void setVisible(boolean visible)

iOS

@property(nonatomic) BOOL visible

Tracking Mode

Sets user tracking mode to None or centeredOnUser. Default value is none. If tracking mode is set to centeredOnUser, once the user interrupts the map, it will change back to none. Add tracking interrupted event listeners to be notified once the user interrupts the map. See events section below for more information.

See also: MapUserLocationTrackingMode

Android

MapUserLocationTrackingMode getTrackingMode()
void setTrackingMode(MapUserLocationTrackingMode mode)

iOS

@property(nonatomic) MSMapUserLocationTrackingMode trackingMode

Orientation

Sets user location orientation to be used by the directionality cone. Default value is heading. If called before tracking is started, the setting will take effect next time tracking is started. If called after tracking is started, the orientation will be switched immediately.

See also: MapUserLocationOrientation

Android

MapUserLocationOrientation getOrientation()
void setOrientation(MapUserLocationOrientation orientation)

iOS

@property(nonatomic) MSMapUserLocationOrientation orientation

Signal Lost Alert Action

Sets the action that should be taken for future signal lost alerts. Default value is ignore. If the alert is currently being shown, setting this action will not affect the current alert.

See also: MapUserLocationSignalLostAlertAction

Android

MapUserLocationSignalLostAlertAction getSignalLostAlertAction()
void setSignalLostAlertAction(MapUserLocationSignalLostAlertAction action)

iOS

@property(nonatomic) MSMapUserLocationSignalLostAlertAction signalLostAlertAction

Last Location Data

Gets last location retrieved or null(Android) / nil(iOS) if no locations were ever recorded.

See also: MapLocationData

Android

@Nullable MapLocationData getLastLocationData()

iOS

@property(nonatomic, readonly, nullable) MSMapLocationData* lastLocationData

Last Heading

Gets last heading retrieved where heading is the direction the phone is pointing at. This value is relative to true North. The value 0 means the device is pointed toward true North, 90 means it is pointed east, 180 means it is pointed south, and 270 means it is pointed west.

Android

Returns null if no headings were ever recorded.

@Nullable Double getLastHeading()

iOS

Returns -1 if no headings were ever recorded.

@property(nonatomic, readonly) CLLocationDirection lastHeading

Methods

Start Tracking

Starts tracking and returns ready state if location permission were granted. Returns permissionDenied state if no location permissions were granted and tracking will not start. Returns disabled state if all providers were disabled. If permissionDenied was returned, developer should request for location permissions and then call this method again. If called multiple times, tracking will restart with the new locationProvider.

See also: MapUserLocationTrackingState

Android

MapUserLocationTrackingState startTracking(MapLocationProvider mapLocationProvider)

See also: MapLocationProvider, and GPSMapLocationProvider

iOS

- (MSMapUserLocationTrackingState)startTrackingWithLocationProvider:(MSMapLocationProvider*)locationProvider

See also: MSMapLocationProvider

Stop Tracking

Will stop tracking and hide the user location if it was already active. If called when user location was not active, nothing happens.

Android

void stopTracking()

iOS

- (void)stopTracking

Events

Tracking Interrupted

Fired when tracking mode was in CenteredOnUser state and the user interrupts the map and changes it back to tracking mode None.

Android

void addOnMapUserLocationTrackingInterruptedListener(OnMapUserLocationTrackingInterruptedListener listener)
void removeOnMapUserLocationTrackingInterruptedListener(OnMapUserLocationTrackingInterruptedListener listener)

See also: OnMapUserLocationTrackingInterruptedListener

iOS

- (MSMapHandlerId)addUserDidInterruptTrackingHandler:(MSMapUserLocationTrackingInterruptedHandler)handler
- (BOOL)removeUserDidInterruptTrackingHandler:(MSMapHandlerId)handlerId

See also: MSMapUserLocationTrackingInterruptedHandler