Files
MapLibreParticleLab/platform/android/docs/camera/lat-lng-bounds.md
Bart Louwers c79b6dcf52 Add end-of-file-fixer pre-commit hook (#3176)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-01-24 20:43:50 +01:00

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"