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

[Compose] Make cameraForCoordinates accessible into MapViewportState() #2341

Open
CoreFloDev opened this issue Apr 12, 2024 · 1 comment
Open
Assignees
Labels

Comments

@CoreFloDev
Copy link

New Feature

When you configure your map composable you can only

mapViewportState = MapViewportState().apply {
    setCameraOptions {
        zoom(9.5)
        center(state.polygonCenter.getCenter().let { Point.fromLngLat(it.long, it.lat) })
    }
}

Therefore, you need to then add something like that

MapEffect(state.polygonCenter) {
    val padding = 32.dp.value.toDouble()
    it.camera.flyTo(it.mapboxMap.cameraForCoordinates(path, EdgeInsets(padding, padding, padding, padding)))
}

The idea would be to be able to do something like

mapViewportState = MapViewportState().apply {
    val padding = 32.dp.value.toDouble()
    setCameraOptions(cameraForCoordinates(path, EdgeInsets(padding, padding, padding, padding)))
}

And therefore no to have to add a MapEffect to recenter the camera

@pengdev pengdev self-assigned this Apr 12, 2024
@pengdev
Copy link
Member

pengdev commented Apr 12, 2024

@CoreFloDev Thanks for the suggestion! It looks reasonable to be part of the MapViewportState API, we will consider adding it in upcoming releases.

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

No branches or pull requests

2 participants