2022-07-11 09:36:43 +03:00
|
|
|
package centre.sciprog.maps.compose
|
|
|
|
|
|
|
|
import androidx.compose.foundation.layout.fillMaxSize
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import centre.sciprog.maps.GeodeticMapCoordinates
|
|
|
|
import centre.sciprog.maps.MapViewPoint
|
|
|
|
|
2022-07-13 11:36:02 +03:00
|
|
|
|
|
|
|
data class MapViewConfig(
|
|
|
|
val zoomSpeed: Double = 1.0 / 3.0,
|
|
|
|
)
|
|
|
|
|
2022-07-11 09:36:43 +03:00
|
|
|
@Composable
|
|
|
|
expect fun MapView(
|
|
|
|
initialViewPoint: MapViewPoint,
|
|
|
|
mapTileProvider: MapTileProvider,
|
2022-07-11 18:43:05 +03:00
|
|
|
features: Map<FeatureId, MapFeature>,
|
2022-07-11 18:32:36 +03:00
|
|
|
onClick: (GeodeticMapCoordinates) -> Unit = {},
|
2022-07-13 11:36:02 +03:00
|
|
|
//TODO consider replacing by modifier
|
|
|
|
config: MapViewConfig = MapViewConfig(),
|
2022-07-11 18:32:36 +03:00
|
|
|
modifier: Modifier = Modifier.fillMaxSize(),
|
|
|
|
)
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun MapView(
|
|
|
|
initialViewPoint: MapViewPoint,
|
|
|
|
mapTileProvider: MapTileProvider,
|
2022-07-11 09:36:43 +03:00
|
|
|
onClick: (GeodeticMapCoordinates) -> Unit = {},
|
2022-07-13 11:36:02 +03:00
|
|
|
config: MapViewConfig = MapViewConfig(),
|
2022-07-11 18:43:05 +03:00
|
|
|
modifier: Modifier = Modifier.fillMaxSize(),
|
|
|
|
addFeatures: @Composable() (FeatureBuilder.() -> Unit) = {},
|
2022-07-11 18:32:36 +03:00
|
|
|
) {
|
|
|
|
val featuresBuilder = MapFeatureBuilder()
|
|
|
|
featuresBuilder.addFeatures()
|
2022-07-13 11:36:02 +03:00
|
|
|
MapView(initialViewPoint, mapTileProvider, featuresBuilder.build(), onClick, config, modifier)
|
2022-07-11 18:32:36 +03:00
|
|
|
}
|