diff --git a/lib/maplibre-compose/src/androidMain/kotlin/dev/sargunv/maplibrecompose/core/AndroidMap.kt b/lib/maplibre-compose/src/androidMain/kotlin/dev/sargunv/maplibrecompose/core/AndroidMap.kt index 94dac8ac..7696f9c3 100644 --- a/lib/maplibre-compose/src/androidMain/kotlin/dev/sargunv/maplibrecompose/core/AndroidMap.kt +++ b/lib/maplibre-compose/src/androidMain/kotlin/dev/sargunv/maplibrecompose/core/AndroidMap.kt @@ -188,6 +188,30 @@ internal class AndroidMap( override var onFpsChanged: (Double) -> Unit = { _ -> } + override var minPitch + get() = map.minPitch + set(value) { + map.setMinPitchPreference(value) + } + + override var maxPitch + get() = map.maxPitch + set(value) { + map.setMaxPitchPreference(value) + } + + override var minZoom + get() = map.minZoomLevel + set(value) { + map.setMinZoomPreference(value) + } + + override var maxZoom + get() = map.maxZoomLevel + set(value) { + map.setMaxZoomPreference(value) + } + override val visibleBoundingBox: BoundingBox get() = map.projection.visibleRegion.latLngBounds.toBoundingBox() diff --git a/lib/maplibre-compose/src/commonMain/kotlin/dev/sargunv/maplibrecompose/compose/MaplibreMap.kt b/lib/maplibre-compose/src/commonMain/kotlin/dev/sargunv/maplibrecompose/compose/MaplibreMap.kt index 09d7272f..fd8b106d 100644 --- a/lib/maplibre-compose/src/commonMain/kotlin/dev/sargunv/maplibrecompose/compose/MaplibreMap.kt +++ b/lib/maplibre-compose/src/commonMain/kotlin/dev/sargunv/maplibrecompose/compose/MaplibreMap.kt @@ -26,6 +26,8 @@ import kotlin.math.roundToInt * @param modifier The modifier to be applied to the layout. * @param styleUri The URI of the map style specification JSON to use, see * [MapLibre Style](https://maplibre.org/maplibre-style-spec/). + * @param zoomRange The allowable bounds for the camera zoom level. + * @param pitchRange The allowable bounds for the camera pitch. * @param gestureSettings Defines which user map gestures are enabled. * @param ornamentSettings Defines which additional UI elements are displayed on top of the map. * @param cameraState The camera state specifies what position of the map is rendered, at what zoom, @@ -83,6 +85,8 @@ import kotlin.math.roundToInt public fun MaplibreMap( modifier: Modifier = Modifier, styleUri: String = "https://demotiles.maplibre.org/style.json", + zoomRange: ClosedRange = 0f..20f, + pitchRange: ClosedRange = 0f..60f, gestureSettings: GestureSettings = GestureSettings.AllEnabled, ornamentSettings: OrnamentSettings = OrnamentSettings.AllEnabled, cameraState: CameraState = rememberCameraState(), @@ -165,6 +169,10 @@ public fun MaplibreMap( cameraState.map = map map.onFpsChanged = onFrame map.isDebugEnabled = isDebugEnabled + map.minZoom = zoomRange.start.toDouble() + map.maxZoom = zoomRange.endInclusive.toDouble() + map.minPitch = pitchRange.start.toDouble() + map.maxPitch = pitchRange.endInclusive.toDouble() map.setGestureSettings(gestureSettings) map.setOrnamentSettings(ornamentSettings) map.setMaximumFps(maximumFps) diff --git a/lib/maplibre-compose/src/commonMain/kotlin/dev/sargunv/maplibrecompose/core/MaplibreMap.kt b/lib/maplibre-compose/src/commonMain/kotlin/dev/sargunv/maplibrecompose/core/MaplibreMap.kt index c173b96b..34fc392f 100644 --- a/lib/maplibre-compose/src/commonMain/kotlin/dev/sargunv/maplibrecompose/core/MaplibreMap.kt +++ b/lib/maplibre-compose/src/commonMain/kotlin/dev/sargunv/maplibrecompose/core/MaplibreMap.kt @@ -11,8 +11,19 @@ import kotlin.time.Duration internal interface MaplibreMap { var styleUri: String + var isDebugEnabled: Boolean + var cameraPosition: CameraPosition + + var maxZoom: Double + + var minZoom: Double + + var maxPitch: Double + + var minPitch: Double + var onFpsChanged: (Double) -> Unit val visibleBoundingBox: BoundingBox diff --git a/lib/maplibre-compose/src/iosMain/kotlin/dev/sargunv/maplibrecompose/core/IosMap.kt b/lib/maplibre-compose/src/iosMain/kotlin/dev/sargunv/maplibrecompose/core/IosMap.kt index 1363abaf..a5527b6d 100644 --- a/lib/maplibre-compose/src/iosMain/kotlin/dev/sargunv/maplibrecompose/core/IosMap.kt +++ b/lib/maplibre-compose/src/iosMain/kotlin/dev/sargunv/maplibrecompose/core/IosMap.kt @@ -259,6 +259,30 @@ internal class IosMap( else 0uL } + override var minPitch + get() = mapView.minimumPitch + set(value) { + mapView.minimumPitch = value + } + + override var maxPitch + get() = mapView.maximumPitch + set(value) { + mapView.maximumPitch = value + } + + override var minZoom + get() = mapView.minimumZoomLevel + set(value) { + mapView.minimumZoomLevel = value + } + + override var maxZoom + get() = mapView.maximumZoomLevel + set(value) { + mapView.maximumZoomLevel = value + } + override val visibleBoundingBox: BoundingBox get() = mapView.visibleCoordinateBounds.toBoundingBox()