Mapbox-gl-native: [android] zoomWhileTracking doesn't zoom

Created on 13 Aug 2019  路  1Comment  路  Source: mapbox/mapbox-gl-native

Steps to reproduce

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)

Expected behavior

Zoom and move to location position with 16.0 zoom

Actual behavior

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.

Configuration

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"
Android support

Most helpful comment

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!

>All comments

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!

Was this page helpful?
0 / 5 - 0 ratings