Docs / Get started / MapLibre

Your first map with MapLibre

How to render a MapLibre map with MapConductor. Setup differs per platform, but the code that draws the map and its overlays follows the same model everywhere.

TIME
5 min
PROVIDER
MapLibre
API KEY
None
LICENSE
OSS
Platform
Only the setup differs

01 · Install

Add core and for-maplibre to your dependencies. Using another provider means swapping that one module.

settings.gradle.ktsKotlin
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}
app/build.gradle.ktsKotlin
dependencies {
    implementation(platform("com.mapconductor:mapconductor-bom:1.3.1"))
    implementation("com.mapconductor:core")
    implementation("com.mapconductor:for-maplibre")
    // optional: compose / icons / heatmap / marker-clustering / geojson / kml
}

02 · Choose your tiles

MapLibre itself needs no API key — how the map looks depends on where the tiles come from.

DEMO TILES

Start on demo tiles

Pass MapLibreDesign.DemoTiles or OpenMapTiles to get a working map with no key at all.

HOSTED TILES

Host tiles for production

For a hosted service such as MapTiler, put that service key in the style URL.

NOTE

Demo tiles are for verification only. Use your own or a commercial tile service in production.

03 · Hello Map

Create a state object holding the camera position and hand it to the map view. Overlays — the marker and its info bubble — are declared as children: tapping the marker shows the bubble, tapping the map dismisses it.

Keep the state object for the lifetime of the component. Updating its properties applies to the map without rebuilding the view.
SimpleMapScreen.kt · Jetpack Compose
@Composable
fun SimpleMapScreen(modifier: Modifier) {
    var selected by remember { mutableStateOf<MarkerState?>(null) }

    val mapState = rememberMapLibreMapViewState(
        cameraPosition = MapCameraPosition(
            position = GeoPoint(35.6812, 139.7671),
            zoom = 14.0,
        ),
        mapDesign = MapLibreDesign.OsmBright,
    )
    val markerState = remember {
        MarkerState(
            position = GeoPoint(35.6812, 139.7671),
            onClick = { selected = it },
        )
    }

    MapLibreMapView(
        modifier = modifier,
        state = mapState,
        onMapClick = { selected = null },
    ) {
        Marker(markerState)
        selected?.let {
            InfoBubble(marker = it) { Text("Hello, MapConductor") }
        }
    }
}

RESULT · What you should see

A map centred on Tokyo Station with a single marker. Tap the marker and a “Hello, MapConductor” bubble appears — that is the whole tutorial working.

MapLibre · Marker · InfoBubble

04 · Swap the provider

Keep the screen code and swap the dependency and view name to run on a different provider. What changes is the setup: obtaining a key, and how that SDK wants to be initialised.

Google Maps

Apple MapKit

Leaflet

OpenLayers

Azure Maps

Cesium

Open Mobile Maps

Related pages