Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1.1 KiB
1.1 KiB
LatLngBounds API
{{ activity_source_note("LatLngBoundsActivity.kt") }}
This example demonstrates setting the camera to some bounds defined by some features. It sets these bounds when the map is initialized and when the bottom sheet is opened or closed.
Here you can see how the feature collection is loaded and how MapLibreMap.getCameraForLatLngBounds is used to set the bounds during map initialization:
--8<-- "MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/activity/camera/LatLngBoundsActivity.kt:featureCollection"
The createBounds function uses the LatLngBounds API to include all points within the bounds:
--8<-- "MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/activity/camera/LatLngBoundsActivity.kt:createBounds"