Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions lib-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ 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"
compileSdk = libs.versions.compileSdk.get().toInt()

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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ fun W3WMapBoxDrawGridLines(
}
}

val lineLayerState = remember {
val lineLayerState = remember(gridLineColor, gridLineWidth) {
LineLayerState().apply {
lineOcclusionOpacity = DoubleValue(0.0)
lineEmissiveStrength = DoubleValue(1.0)
Expand Down Expand Up @@ -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)
)
)
Expand All @@ -583,7 +595,7 @@ private fun DrawZoomInSelectedAddress(
}
}

val lineLayerState = remember {
val lineLayerState = remember(selectedMarkerColor) {
LineLayerState().apply {
lineOcclusionOpacity = DoubleValue(0.0)
lineEmissiveStrength = DoubleValue(1.0)
Expand Down