myLocationEnabled property

bool myLocationEnabled
final

True if a "My Location" layer should be shown on the map.

This layer includes a location indicator at the current device location, as well as a My Location button.

  • The indicator is a small blue dot if the device is stationary, or a chevron if the device is moving.
  • The My Location button animates to focus on the user's current location if the user's location is currently known.

Enabling this feature requires adding location permissions to both native platforms of your app.

  • On Android add either <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> or <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> to your AndroidManifest.xml file. ACCESS_COARSE_LOCATION returns a location with an accuracy approximately equivalent to a city block, while ACCESS_FINE_LOCATION returns as precise a location as possible, although it consumes more battery power. You will also need to request these permissions during run-time. If they are not granted, the My Location feature will fail silently.
  • On iOS add a NSLocationWhenInUseUsageDescription key to your Info.plist file. This will automatically prompt the user for permissions when the map tries to turn on the My Location layer.

Implementation

final bool myLocationEnabled;