diff --git a/demo/maps/src/jvmMain/kotlin/Main.kt b/demo/maps/src/jvmMain/kotlin/Main.kt index fd88814..a70da7c 100644 --- a/demo/maps/src/jvmMain/kotlin/Main.kt +++ b/demo/maps/src/jvmMain/kotlin/Main.kt @@ -59,7 +59,7 @@ fun App() { MapView( mapTileProvider = mapTileProvider, - initialViewPoint = viewPoint,// use null to infer view point from features + initialViewPoint = null,// use null to infer view point from features config = MapViewConfig( onViewChange = { centerCoordinates = focus }, ) diff --git a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapView.kt b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapView.kt index 2993716..4006f55 100644 --- a/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapView.kt +++ b/maps-kt-compose/src/commonMain/kotlin/center/sciprog/maps/compose/MapView.kt @@ -62,7 +62,6 @@ public data class MapViewConfig( val onViewChange: MapViewPoint.() -> Unit = {}, val onSelect: (GmcRectangle) -> Unit = {}, val zoomOnSelect: Boolean = true, - val resetViewPoint: Boolean = false, ) @Composable diff --git a/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt b/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt index f814ed3..b8951fe 100644 --- a/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt +++ b/maps-kt-compose/src/jvmMain/kotlin/center/sciprog/maps/compose/MapViewJvm.kt @@ -56,16 +56,8 @@ public actual fun MapView( ) { var canvasSize by remember { mutableStateOf(DpSize(512.dp, 512.dp)) } - var viewPointInternal: MapViewPoint? by remember { - mutableStateOf(null) - } - - if (config.resetViewPoint) { - viewPointInternal = null - } - - val viewPoint: MapViewPoint by derivedStateOf { - viewPointInternal ?: computeViewPoint(canvasSize) + var viewPoint: MapViewPoint by remember { + mutableStateOf(computeViewPoint(canvasSize)) } val zoom: Int by derivedStateOf { @@ -153,7 +145,7 @@ public actual fun MapView( +dragAmount.y.toDp().value / tileScale ) config.onViewChange(newViewPoint) - viewPointInternal = newViewPoint + viewPoint = newViewPoint } } @@ -169,7 +161,7 @@ public actual fun MapView( val newViewPoint = gmcBox.computeViewPoint(mapTileProvider).invoke(canvasSize) config.onViewChange(newViewPoint) - viewPointInternal = newViewPoint + viewPoint = newViewPoint } selectRect = null } @@ -183,7 +175,7 @@ public actual fun MapView( val invariant = DpOffset(xPos.toDp(), yPos.toDp()).toGeodetic() val newViewPoint = viewPoint.zoom(-change.scrollDelta.y.toDouble() * config.zoomSpeed, invariant) config.onViewChange(newViewPoint) - viewPointInternal = newViewPoint + viewPoint = newViewPoint }.fillMaxSize()