Location Plugin Impl
The Location Component provides location awareness to your mobile application. Enabling this component provides a contextual experience to your users by showing an icon representing the users current location. A few different modes are offered to provide the right context to your users at the correct time. RenderMode.NORMAL simply shows the users location on the map represented as a dot. RenderMode.COMPASS mode allows you to display an arrow icon (by default) that points in the direction the device is pointing in. RenderMode.GPS can be used in conjunction with our Navigation SDK to display a larger icon (customized with LocationComponentOptions.gpsDrawable) we call the user puck.
This component also offers the ability to set a map camera behavior for tracking the user location. These different CameraModes will track, stop tracking the location based on the mode set with LocationPluginImpl.setCameraMode.
** To get the component object use MapPluginProviderDelegate.getLocationPlugin and activate it with .activateLocationComponent or one of the overloads. Then, manage its visibility with .setLocationComponentEnabled. The component will not process location updates right after activation, but only after being enabled.
Using this component requires you to request permission beforehand manually or using PermissionsManager. Either ACCESS_COARSE_LOCATION
or ACCESS_FINE_LOCATION
permissions can be requested for this component to work as expected.
This component offers a default, built-in LocationEngine with some of the activation methods. This engine will be obtained by LocationEngineProvider.getBestLocationEngine which defaults to the com.mapbox.android.core.location.MapboxFusedLocationEngineImpl. If you'd like to utilize Google Play Services for more precise location updates, simply add the Google Play Location Services dependency in your build script. This will make the default engine the com.mapbox.android.core.location.GoogleLocationEngineImpl instead. After a custom engine is passed to the component, or the built-in is initialized, the location updates are going to be requested with the LocationEngineRequest, either a default one, or the one passed during the activation. When using any engine, requesting/removing the location updates is going to be managed internally.
You can also push location updates to the component without any internal engine management. To achieve that, use .activateLocationComponent with false. No engine is going to be initialized and you can push location updates with .forceLocationUpdate.
For location puck animation purposes, like navigation, we recommend limiting the maximum zoom level of the map for the best user experience.
Location Component doesn't support state saving out-of-the-box.
Constructors
Default empty constructor for LocationComponentPlugin.
Internal use.
Types
Functions
Properties
The camera mode determines how the map camera will track the rendered location.
When camera is transitioning to a new mode, it will reject inputs like .zoomWhileTracking or .tiltWhileTracking. Use OnLocationCameraTransitionListener to listen for the transition state.
CameraMode.NONE: No camera tracking
CameraMode.NONE_COMPASS: Camera does not track location, but does track compass bearing
CameraMode.NONE_GPS: Camera does not track location, but does track GPS bearing
CameraMode.TRACKING: Camera tracks the user location
CameraMode.TRACKING_COMPASS: Camera tracks the user location, with bearing provided by a compass
CameraMode.TRACKING_GPS: Camera tracks the user location, with normalized bearing
CameraMode.TRACKING_GPS_NORTH: Camera tracks the user location, with bearing always set to north
Defines whether the LocationPluginImpl is enabled.
Indicates whether the component has been initialized.
Get the last know location of the location component.
Returns the current location options being used.
The render mode determines how the location updates will be rendered on the map.
RenderMode.NORMAL: Shows user location, bearing ignored
RenderMode.COMPASS: Shows user location with bearing considered from compass
RenderMode.GPS: Shows user location with bearing considered from location