diff --git a/src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt b/src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt index aa9018c..ca6bb99 100644 --- a/src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt +++ b/src/commonMain/kotlin/centre/sciprog/maps/compose/MapView.kt @@ -2,8 +2,6 @@ package centre.sciprog.maps.compose import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable -import androidx.compose.runtime.mutableStateMapOf -import androidx.compose.runtime.snapshots.SnapshotStateMap import androidx.compose.ui.Modifier import centre.sciprog.maps.GeodeticMapCoordinates import centre.sciprog.maps.MapViewPoint @@ -12,7 +10,7 @@ import centre.sciprog.maps.MapViewPoint expect fun MapView( initialViewPoint: MapViewPoint, mapTileProvider: MapTileProvider, - features: SnapshotStateMap = mutableStateMapOf(), + features: Map, onClick: (GeodeticMapCoordinates) -> Unit = {}, modifier: Modifier = Modifier.fillMaxSize(), ) @@ -21,9 +19,9 @@ expect fun MapView( fun MapView( initialViewPoint: MapViewPoint, mapTileProvider: MapTileProvider, - modifier: Modifier = Modifier.fillMaxSize(), onClick: (GeodeticMapCoordinates) -> Unit = {}, - addFeatures: @Composable FeatureBuilder.() -> Unit, + modifier: Modifier = Modifier.fillMaxSize(), + addFeatures: @Composable() (FeatureBuilder.() -> Unit) = {}, ) { val featuresBuilder = MapFeatureBuilder() featuresBuilder.addFeatures() diff --git a/src/jvmMain/kotlin/Main.kt b/src/jvmMain/kotlin/Main.kt index 5f6b67f..756d00d 100644 --- a/src/jvmMain/kotlin/Main.kt +++ b/src/jvmMain/kotlin/Main.kt @@ -43,27 +43,22 @@ fun App() { MapView(viewPoint, mapTileProvider, onClick = { gmc: GeodeticMapCoordinates -> coordinates = gmc }) { val pointOne = 55.568548 to 37.568604 val pointTwo = 55.929444 to 37.518434 + image(pointOne, Icons.Filled.Home) + + //remember feature Id val circleId: FeatureId = circle(pointTwo) + line(pointOne, pointTwo) text(pointOne, "Home") scope.launch { while (isActive){ delay(200) + //Overwrite a feature with new color circle(pointTwo, id = circleId, color = Color(Random.nextFloat(), Random.nextFloat(), Random.nextFloat())) } } - -// // test dynamic rendering -// scope.launch{ -// repeat(10000) { -// delay(10) -// val randomPoint = -// Random.nextDouble(55.568548, 55.929444) to Random.nextDouble(37.518434, 37.568604) -// circle(randomPoint) -// } -// } } } } diff --git a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt b/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt index ff2359b..2a20f10 100644 --- a/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt +++ b/src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt @@ -42,7 +42,7 @@ private val logger = KotlinLogging.logger("MapView") actual fun MapView( initialViewPoint: MapViewPoint, mapTileProvider: MapTileProvider, - features: SnapshotStateMap, + features: Map, onClick: (GeodeticMapCoordinates) -> Unit, modifier: Modifier, ) {