Quick fix for feature builder
This commit is contained in:
parent
ed4b603077
commit
792a755682
@ -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<FeatureId, MapFeature> = mutableStateMapOf(),
|
||||
features: Map<FeatureId, MapFeature>,
|
||||
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()
|
||||
|
@ -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)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ private val logger = KotlinLogging.logger("MapView")
|
||||
actual fun MapView(
|
||||
initialViewPoint: MapViewPoint,
|
||||
mapTileProvider: MapTileProvider,
|
||||
features: SnapshotStateMap<FeatureId, MapFeature>,
|
||||
features: Map<FeatureId, MapFeature>,
|
||||
onClick: (GeodeticMapCoordinates) -> Unit,
|
||||
modifier: Modifier,
|
||||
) {
|
||||
|
Loading…
Reference in New Issue
Block a user