Merge branch 'main' into limit-parallel-requests

# Conflicts:
#	src/jvmMain/kotlin/Main.kt
#	src/jvmMain/kotlin/centre/sciprog/maps/compose/MapViewJvm.kt
This commit is contained in:
Lev Shagalov 2022-07-15 10:41:03 +03:00
commit e56ed96fdb
4 changed files with 8 additions and 8 deletions

0
README.md Normal file
View File

View File

@ -20,7 +20,7 @@ expect fun MapView(
mapTileProvider: MapTileProvider, mapTileProvider: MapTileProvider,
computeViewPoint: (canvasSize: DpSize) -> MapViewPoint, computeViewPoint: (canvasSize: DpSize) -> MapViewPoint,
features: Map<FeatureId, MapFeature>, features: Map<FeatureId, MapFeature>,
onClick: (GeodeticMapCoordinates) -> Unit = {}, onClick: MapViewPoint.() -> Unit = {},
//TODO consider replacing by modifier //TODO consider replacing by modifier
config: MapViewConfig = MapViewConfig(), config: MapViewConfig = MapViewConfig(),
modifier: Modifier = Modifier.fillMaxSize(), modifier: Modifier = Modifier.fillMaxSize(),
@ -31,7 +31,7 @@ fun MapView(
mapTileProvider: MapTileProvider, mapTileProvider: MapTileProvider,
initialViewPoint: MapViewPoint, initialViewPoint: MapViewPoint,
features: Map<FeatureId, MapFeature> = emptyMap(), features: Map<FeatureId, MapFeature> = emptyMap(),
onClick: (GeodeticMapCoordinates) -> Unit = {}, onClick: MapViewPoint.() -> Unit = {},
config: MapViewConfig = MapViewConfig(), config: MapViewConfig = MapViewConfig(),
modifier: Modifier = Modifier.fillMaxSize(), modifier: Modifier = Modifier.fillMaxSize(),
buildFeatures: @Composable (FeatureBuilder.() -> Unit) = {}, buildFeatures: @Composable (FeatureBuilder.() -> Unit) = {},
@ -46,7 +46,7 @@ fun MapView(
mapTileProvider: MapTileProvider, mapTileProvider: MapTileProvider,
box: GmcBox, box: GmcBox,
features: Map<FeatureId, MapFeature> = emptyMap(), features: Map<FeatureId, MapFeature> = emptyMap(),
onClick: (GeodeticMapCoordinates) -> Unit = {}, onClick: MapViewPoint.() -> Unit = {},
config: MapViewConfig = MapViewConfig(), config: MapViewConfig = MapViewConfig(),
modifier: Modifier = Modifier.fillMaxSize(), modifier: Modifier = Modifier.fillMaxSize(),
buildFeatures: @Composable (FeatureBuilder.() -> Unit) = {}, buildFeatures: @Composable (FeatureBuilder.() -> Unit) = {},

View File

@ -48,7 +48,7 @@ fun App() {
MapView( MapView(
mapTileProvider = mapTileProvider, mapTileProvider = mapTileProvider,
initialViewPoint = viewPoint, initialViewPoint = viewPoint,
onClick = { gmc -> coordinates = gmc }, onClick = { coordinates = focus },
config = MapViewConfig(inferViewBoxFromFeatures = true) config = MapViewConfig(inferViewBoxFromFeatures = true)
) { ) {
val pointOne = 55.568548 to 37.568604 val pointOne = 55.568548 to 37.568604

View File

@ -39,14 +39,14 @@ actual fun MapView(
mapTileProvider: MapTileProvider, mapTileProvider: MapTileProvider,
computeViewPoint: (canvasSize: DpSize) -> MapViewPoint, computeViewPoint: (canvasSize: DpSize) -> MapViewPoint,
features: Map<FeatureId, MapFeature>, features: Map<FeatureId, MapFeature>,
onClick: (GeodeticMapCoordinates) -> Unit, onClick: MapViewPoint.() -> Unit,
config: MapViewConfig, config: MapViewConfig,
modifier: Modifier, modifier: Modifier,
) { ) {
var canvasSize by remember { mutableStateOf(DpSize(512.dp, 512.dp)) } var canvasSize by remember { mutableStateOf(DpSize(512.dp, 512.dp)) }
var viewPointOverride by remember { var viewPointOverride: MapViewPoint? by remember {
mutableStateOf<MapViewPoint?>( mutableStateOf(
if (config.inferViewBoxFromFeatures) { if (config.inferViewBoxFromFeatures) {
features.values.computeBoundingBox(1)?.let { box -> features.values.computeBoundingBox(1)?.let { box ->
val zoom = log2( val zoom = log2(
@ -124,7 +124,7 @@ actual fun MapView(
} else { } else {
val dragStart = change.position val dragStart = change.position
val dpPos = DpOffset(dragStart.x.toDp(), dragStart.y.toDp()) val dpPos = DpOffset(dragStart.x.toDp(), dragStart.y.toDp())
onClick(dpPos.toGeodetic()) onClick(MapViewPoint(dpPos.toGeodetic(), viewPoint.zoom))
drag(change.id) { dragChange -> drag(change.id) { dragChange ->
val dragAmount = dragChange.position - dragChange.previousPosition val dragAmount = dragChange.position - dragChange.previousPosition
viewPointOverride = viewPoint.move( viewPointOverride = viewPoint.move(