mapbox / mapbox/mapbox-maps-android
[Compose] Make cameraForCoordinates accessible into MapViewportState()
Open
@pengdev is already working on this.
Since Apr 12, 2024.
auto-triaged
compose
feature :green_apple:
- Dominant language
- Kotlin
- Stars
- 578
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.