diff --git a/gradle.properties b/gradle.properties index a45b531..4aafe80 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,5 +23,5 @@ android.nonTransitiveRClass=true kotlin.code.style=official android.nonFinalResIds=false LIBRARY_VERSION=2.1.0 -LIBRARY_COMPOSE_VERSION=2.1.0 +LIBRARY_COMPOSE_VERSION=2.1.1 MAPBOX_DOWNLOADS_TOKEN = "YOUR_MAPBOX_DOWNLOADS_TOKEN" \ No newline at end of file diff --git a/lib-compose/build.gradle.kts b/lib-compose/build.gradle.kts index dda5a9f..312e4d5 100644 --- a/lib-compose/build.gradle.kts +++ b/lib-compose/build.gradle.kts @@ -19,7 +19,7 @@ plugins { */ val isSnapshotRelease = findProperty("IS_SNAPSHOT_RELEASE") == "true" version = - if (isSnapshotRelease) "${findProperty("LIBRARY_VERSION")}-SNAPSHOT" else "${findProperty("LIBRARY_VERSION")}" + if (isSnapshotRelease) "${findProperty("LIBRARY_COMPOSE_VERSION")}-SNAPSHOT" else "${findProperty("LIBRARY_COMPOSE_VERSION")}" android { namespace = "com.what3words.map.components.compose" @@ -27,7 +27,7 @@ android { defaultConfig { minSdk = libs.versions.minSdk.get().toInt() - buildConfigField("String", "LIBRARY_VERSION", "\"${findProperty("LIBRARY_VERSION")}\"") + buildConfigField("String", "LIBRARY_VERSION", "\"${findProperty("LIBRARY_COMPOSE_VERSION")}\"") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles("consumer-rules.pro") diff --git a/lib-compose/src/main/java/com/what3words/components/compose/maps/providers/mapbox/W3WMapBox.kt b/lib-compose/src/main/java/com/what3words/components/compose/maps/providers/mapbox/W3WMapBox.kt index 5b8fdd9..ac8b585 100644 --- a/lib-compose/src/main/java/com/what3words/components/compose/maps/providers/mapbox/W3WMapBox.kt +++ b/lib-compose/src/main/java/com/what3words/components/compose/maps/providers/mapbox/W3WMapBox.kt @@ -9,15 +9,10 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalDensity import com.mapbox.common.toValue import com.mapbox.maps.CameraBoundsOptions -import com.mapbox.maps.CameraChanged -import com.mapbox.maps.CameraChangedCallback import com.mapbox.maps.CameraOptions import com.mapbox.maps.EdgeInsets -import com.mapbox.maps.MapIdle -import com.mapbox.maps.MapIdleCallback import com.mapbox.maps.MapView import com.mapbox.maps.MapboxMap import com.mapbox.maps.extension.compose.MapEffect @@ -83,10 +78,6 @@ fun W3WMapBox( val mapViewportState = (state.cameraState as W3WMapboxCameraState).cameraState - var lastProcessedCameraState by remember { mutableStateOf(mapViewportState.cameraState) } - - val density = LocalDensity.current.density - LaunchedEffect(mapViewportState.cameraState) { snapshotFlow { mapViewportState.cameraState } .filterNotNull() @@ -96,7 +87,6 @@ fun W3WMapBox( mapboxMap, mapConfig.gridLineConfig, onCameraBoundUpdate = { gridBound, visibleBound -> - lastProcessedCameraState = currentCameraState state.cameraState.gridBound = gridBound state.cameraState.visibleBound = visibleBound onCameraUpdated(state.cameraState) @@ -230,23 +220,19 @@ fun W3WMapBox( it.mapboxMap.setBounds(cameraBounds) } - it.mapboxMap.subscribeMapIdle(object : MapIdleCallback { - override fun run(mapIdle: MapIdle) { - if (state.cameraState.isCameraMoving == true) { - state.cameraState.isCameraMoving = false - onCameraUpdated(state.cameraState) - } + it.mapboxMap.subscribeMapIdle { + if (state.cameraState.isCameraMoving) { + state.cameraState.isCameraMoving = false + onCameraUpdated(state.cameraState) } - }) + } - it.mapboxMap.subscribeCameraChanged(object : CameraChangedCallback { - override fun run(cameraChanged: CameraChanged) { - if (state.cameraState.isCameraMoving == false) { - state.cameraState.isCameraMoving = true - onCameraUpdated(state.cameraState) - } + it.mapboxMap.subscribeCameraChanged { + if (!state.cameraState.isCameraMoving) { + state.cameraState.isCameraMoving = true + onCameraUpdated(state.cameraState) } - }) + } if (mapConfig.buttonConfig.isRecallFeatureEnabled || onMapProjectionUpdated != null) { mapView?.mapboxMap?.let { map -> diff --git a/lib-compose/src/main/java/com/what3words/components/compose/maps/providers/mapbox/W3WMapBoxDrawer.kt b/lib-compose/src/main/java/com/what3words/components/compose/maps/providers/mapbox/W3WMapBoxDrawer.kt index 8721ce4..5838466 100644 --- a/lib-compose/src/main/java/com/what3words/components/compose/maps/providers/mapbox/W3WMapBoxDrawer.kt +++ b/lib-compose/src/main/java/com/what3words/components/compose/maps/providers/mapbox/W3WMapBoxDrawer.kt @@ -237,7 +237,7 @@ fun W3WMapBoxDrawGridLines( } } - val lineLayerState = remember { + val lineLayerState = remember(gridLineColor, gridLineWidth) { LineLayerState().apply { lineOcclusionOpacity = DoubleValue(0.0) lineEmissiveStrength = DoubleValue(1.0) @@ -569,10 +569,22 @@ private fun DrawZoomInSelectedAddress( Feature.fromGeometry( LineString.fromLngLats( listOf( - Point.fromLngLat(square.southwest.lng, square.northeast.lat), - Point.fromLngLat(square.northeast.lng, square.northeast.lat), - Point.fromLngLat(square.northeast.lng, square.southwest.lat), - Point.fromLngLat(square.southwest.lng, square.southwest.lat), + Point.fromLngLat( + square.southwest.lng, + square.northeast.lat + ), + Point.fromLngLat( + square.northeast.lng, + square.northeast.lat + ), + Point.fromLngLat( + square.northeast.lng, + square.southwest.lat + ), + Point.fromLngLat( + square.southwest.lng, + square.southwest.lat + ), Point.fromLngLat(square.southwest.lng, square.northeast.lat) ) ) @@ -583,7 +595,7 @@ private fun DrawZoomInSelectedAddress( } } - val lineLayerState = remember { + val lineLayerState = remember(selectedMarkerColor) { LineLayerState().apply { lineOcclusionOpacity = DoubleValue(0.0) lineEmissiveStrength = DoubleValue(1.0)