MaplibreMap

@Composable
fun MaplibreMap(modifier: Modifier = Modifier, baseStyle: BaseStyle = BaseStyle.Companion.Demo, cameraState: CameraState = rememberCameraState(), zoomRange: ClosedRange<Float> = 0f..20f, pitchRange: ClosedRange<Float> = 0f..60f, boundingBox: BoundingBox? = null, styleState: StyleState = rememberStyleState(), onMapClick: MapClickHandler = { _, _ -> ClickResult.Pass }, onMapLongClick: MapClickHandler = { _, _ -> ClickResult.Pass }, onFrame: (framesPerSecond: Double) -> Unit = {}, options: MapOptions = MapOptions(), logger: Logger? = remember { Logger.withTag("maplibre-compose") }, onMapLoadFailed: (reason: String?) -> Unit = {}, onMapLoadFinished: () -> Unit = {}, content: @Composable () -> Unit = {})(source)

Displays a MapLibre based map.

Parameters

modifier

The modifier to be applied to the layout.

baseStyle

The URI or JSON of the map style to use. See MapLibre Style.

cameraState

The camera state specifies what position of the map is rendered, at what zoom, at what tilt, etc.

zoomRange

The allowable camera zoom range.

pitchRange

The allowable camera pitch range.

boundingBox

The allowable bounds for the camera position. On iOS and Web, it prevents the camera edges from going out of bounds. If null is provided, the bounds are reset. On Android, it prevents the camera center from going out of bounds. See this GH Issue.

onMapClick

Invoked when the map is clicked. A click callback can be defined per layer, too, see e.g. the onClick parameter for LineLayer. However, this callback is always called first and can thus prevent subsequent callbacks to be invoked by consuming the event.

onMapLongClick

Invoked when the map is long-clicked. See onMapClick.

onFrame

Invoked on every rendered frame.

logger

kermit logger to use.

onMapLoadFailed

Invoked when the map failed to load.

onMapLoadFinished

Invoked when the map finished loading.

content

The map content additional to what is already part of the map as defined in the base map style linked in baseStyle.

Additional sources can be added via:

A source that is already defined in the base map style can be referenced via getBaseSource.

The data from a source can then be used in layer definition(s), which define how that data is rendered, see:

  • BackgroundLayer

  • LineLayer

  • FillExtrusionLayer

  • FillLayer

  • HeatmapLayer

  • HillshadeLayer

  • LineLayer

  • RasterLayer

  • SymbolLayer

By default, the layers defined in this scope are put on top of the layers from the base style, in the order they are defined. Alternatively, it is possible to anchor layers at certain layers from the base style. This is done, for example, in order to add a layer just below the first symbol layer from the base style so that it isn't above labels. See: