I am trying to develop an applicition with the latest Mapbox Maps SDK for Android (v9.5.0).
At the moment, my map can show the location of my device with LocationComponent
but there isn't any button in the UI to go back to the device's location and put it in the center, like Google Maps does with the "my location button".
Therefore my question would be: is there any already included method within SDK which I haven't found or I should use a combination of animateCamera()
and CameraUpdate()
for this purpose?
Easiest way would to use
animateCamera()
andCameraUpdate()
with the last known location coordinates. To get the last known coordinates:There are various camera modes as well https://docs.mapbox.com/android/maps/examples/location-component-camera-options. Once the camera is moved, you could change the mode to
CameraMode.TRACKING
. But this is different than just having the camera move back to the device location without any tracking behavior, as seen in the code snippet above.