val locationComponentOptions = LocationComponentOptions.builder(requireContext())
.trackingGesturesManagement(true)
.build()
val locationEngineRequest = LocationEngineRequest.Builder(interval)
.setPriority(priority)
.build()
val options = LocationComponentActivationOptions.builder(requireContext(), style)
.locationEngineRequest(locationEngineRequest)
.locationComponentOptions(locationComponentOptions)
.useDefaultLocationEngine(true)
.build()
locationComponent.activateLocationComponent(options)
locationComponent.isLocationComponentEnabled = true
locationComponent.cameraMode = CameraMode.TRACKING_GPS
locationComponent.renderMode = RenderMode.COMPASS
locationComponent.zoomWhileTracking(16.0)
Zoom and move to location position with 16.0 zoom
Stays in the same zoom as before. (It actually zoom a little out and in to make pretty animation, but the result zoom is the same as at the beginning.)
Recalling this code again (whem location is the already on the correct position) just jump in zoom without an animation.
Android versions: Android Q
Device models: Pixel 2
Mapbox SDK versions:
implementation "com.mapbox.mapboxsdk:mapbox-android-sdk:8.2.1"
implementation "com.mapbox.mapboxsdk:mapbox-android-navigation:0.41.0"
implementation "com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.41.0"
Thanks for reaching out @hrach. Setting a tracking camera mode starts its own transition which makes the zoomWhileTracking being ignored until the transition is finished.
The correct way to achieve the behavior you're looking for is either setting the desired zoom as a transition parameter:
component.setCameraMode(
CameraMode.TRACKING_GPS,
750L /*duration*/,
16.0 /*zoom*/,
null /*bearing, use current/determine based on the tracking mode*/,
40.0 /*tilt*/,
null /*transition listener*/)
or wait for the transition to finish:
component.setCameraMode(CameraMode.TRACKING_GPS, object : OnLocationCameraTransitionListener {
override fun onLocationCameraTransitionFinished(cameraMode: Int) {
component.zoomWhileTracking(16.0)
}
override fun onLocationCameraTransitionCanceled(cameraMode: Int) {}
})
I hope this helps!
Most helpful comment
Thanks for reaching out @hrach. Setting a tracking camera mode starts its own transition which makes the
zoomWhileTrackingbeing ignored until the transition is finished.The correct way to achieve the behavior you're looking for is either setting the desired zoom as a transition parameter:
or wait for the transition to finish:
I hope this helps!