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.locationManager.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

For additional examples and sample implementations of WemapSDKs, visit the official GitHub repository.

Clone the repository and follow the README instructions to run the sample application.