mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

Documentation on viewport orientation tracking

Open tir38 opened this issue 3 years ago • 1 comments

New Feature

Not sure if this is a feature with missing documentation, or not (yet) a feature in v10.

I'm migrating from v9 to v10. Previously I could switch between tracking the compass or not, when also tracking users location

val trackOrientation :Boolean = ... 

mapView?.getMapboxMap()!!.locationComponent.apply {
    activateLocationComponent(locationComponentActivationOptions)
    isLocationComponentEnabled = true
    cameraMode = if (trackOrientation) TRACKING_COMPASS else TRACKING
}

I now see that this is handled by the viewport plugin, not by location component. I'm following along the sample but I don't see how this is configurable. Currently this always tracks orientation and location

mapView?.viewport?.apply {
    transitionTo(
        makeFollowPuckViewportState(
            FollowPuckViewportStateOptions.Builder()
                .pitch(0.0) // keep birds-eye view
                .build()
        )
    )
}

How can I do the same thing in v10?

tir38 avatar May 03 '22 17:05 tir38

@tir38 please use FollowPuckViewportStateOptions.bearing if you want to disable bearing and just track location of the puck. There's also an example for this api https://github.com/mapbox/mapbox-maps-android/blob/main/app/src/main/java/com/mapbox/maps/testapp/examples/viewport/AdvancedViewportGesturesExample.kt#L57

yunikkk avatar May 06 '22 12:05 yunikkk