Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centering on aircraft without setMapCenterLock? #56

Open
bbenson09 opened this issue Feb 23, 2022 · 1 comment
Open

Centering on aircraft without setMapCenterLock? #56

bbenson09 opened this issue Feb 23, 2022 · 1 comment

Comments

@bbenson09
Copy link

bbenson09 commented Feb 23, 2022

Hi, I'm trying to center the MapWidget on the aircraft WITHOUT locking it. After centering, I want to be able to drag the map without it popping back to the aircraft.

This does not work reliably:

public void centerMap() {
   mapWidget.setMapCenterLock(MapWidget.MapCenterLock.AIRCRAFT);
   mapWidget.setMapCenterLock(MapWidget.MapCenterLock.NONE);
}

Is there a way to do this? It seems like this should be a simple thing to implement if it's not already.

@kenargo
Copy link
Contributor

kenargo commented Jun 28, 2022

This is easily done by creating a key listener for aircraft location:

private val aircraftLocationKey =
FlightControllerKey.create(FlightControllerKey.AIRCRAFT_LOCATION)

creating a listener to this event and using the map's moveCamera or animateCamera like this:

val djiCameraPosition =
DJICameraPosition.Builder().bearing(currentBearing).target(djiLatLng).zoom(20f)
.build()

    val cameraUpdate = DJICameraUpdateFactory.newCameraPosition(djiCameraPosition)

    if (!snapToPosition) {
        binding.mapViewFragmentCommonMapWidget.map!!.animateCamera(cameraUpdate)
    } else {
        binding.mapViewFragmentCommonMapWidget.map!!.moveCamera(cameraUpdate)
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants