Skip to main content

Android Native - Location indicator

Location indicator

Enabling user location indicator will render a view on the map that shows the device's current location.

Enable the default user location indicator using the following code:

mapView.map.locationComponent.apply {
cameraMode = CameraMode.TRACKING_COMPASS
renderMode = RenderMode.COMPASS
}

Change view style

There are several options to customize the appearance of the location indicator using UserLocationStyle.

  • By modifying colors of default userLocationViewStyle:

    mapView.locationManager.userLocationViewStyle = UserLocationViewStyle(
    foregroundTintColor = Color.parseColor("#FFC0CB"),
    backgroundTintColor = Color.BLACK,
    bearingTintColor = Color.GREEN,
    outOfActiveLevelStyle = UserLocationViewStyle.OutOfActiveLevelStyle(
    foregroundTintColor = Color.WHITE,
    bearingTintColor = Color.RED,
    alpha = 0.5F
    )
    )
  • By modifying drawables of default userLocationViewStyle:

    mapView.locationManager.userLocationViewStyle = UserLocationViewStyle(
    foregroundDrawable = R.drawable.custom_user_puck_icon,
    backgroundDrawable = R.drawable.background,
    bearingDrawable = R.drawable.custom_user_arrow,
    outOfActiveLevelStyle = UserLocationViewStyle.OutOfActiveLevelStyle(
    foregroundDrawable = R.drawable.custom_user_puck_icon,
    bearingDrawable = R.drawable.custom_user_arrow
    )
    )

Examples

You can find additional examples for the WemapSDKs on GitHub. Clone the repository and run the example application following the instructions in the README.