Getting started
This page assumes you have a Compose Multiplatform project. To create one,
follow the official JetBrains documentation or run
kotlin init compose-multiplatform.
Add the library
Section titled “Add the library”The library is published on Maven Central. The latest release is v0.15.0. Add it to the version catalog:
[libraries]maplibre-compose = { module = "org.maplibre.compose:maplibre-compose", version = "0.15.0" }Declare the dependency in the shared source set:
commonMain.dependencies { implementation(libs.maplibre.compose)}dependencies: - $libs.maplibre.composeUse the same version for the library and for every runtime artifact below.
Snapshots
Section titled “Snapshots”Snapshot builds of main are available from Central Portal
Snapshots. This site documents the latest release, which may not
match the snapshot. If you use snapshots, read the
documentation for the latest main
instead.
Add the snapshot repository, then set the catalog version to v0.15.1-SNAPSHOT.
repositories { maven { name = "Central Portal Snapshots" url = uri("https://central.sonatype.com/repository/maven-snapshots/") mavenContent { snapshotsOnly() } content { includeGroup("org.maplibre.compose") includeGroup("org.maplibre.nativeffi") } }}repositories: - id: central-portal-snapshots url: https://central.sonatype.com/repository/maven-snapshots/[libraries]maplibre-compose = { module = "org.maplibre.compose:maplibre-compose", version = "0.15.1-SNAPSHOT" }Configure your targets
Section titled “Configure your targets”Complete the section for each target that your app supports.
Android
Section titled “Android”Alongside the library, add a runtime for one render backend.
androidMain { dependencies { runtimeOnly("org.maplibre.compose:maplibre-compose-runtime-vulkan-android:0.15.0") }}dependencies: - //shared - org.maplibre.compose:maplibre-compose-runtime-vulkan-android:0.15.0: scope: runtime-onlyAvailable runtimes:
| Render backend | Runtime |
|---|---|
| OpenGL | maplibre-compose-runtime-opengl-android |
| Vulkan | maplibre-compose-runtime-vulkan-android |
Both Android runtimes support armeabi-v7a, arm64-v8a, and x86_64.
The runtime’s system libraries link when Xcode links your app. Add them to your iOS app target’s Other Linker Flags build setting:
-l"c++"-lz-framework CoreFoundation-framework CoreGraphics-framework CoreText-framework Foundation-framework ImageIO-framework Metal-framework QuartzCoreDesktop (JVM)
Section titled “Desktop (JVM)”Desktop requires Java 25. The native bindings use the FFM API, so the desktop target cannot run on an older JVM.
Alongside the library, add a runtime for your platform and one render backend.
sourceSets { val jvmMain by getting { dependencies { implementation(compose.desktop.currentOs) implementation("org.maplibre.compose:maplibre-compose:0.15.0")
// Linux x64 with Vulkan, for example. runtimeOnly("org.maplibre.compose:maplibre-compose-runtime-vulkan-linux-x64:0.15.0") } }}Available runtimes:
| Platform | Runtime |
|---|---|
| Linux x64 | maplibre-compose-runtime-vulkan-linux-x64 |
| Linux arm64 | maplibre-compose-runtime-vulkan-linux-arm64 |
| macOS arm64 | maplibre-compose-runtime-metal-macos-arm64 |
| Windows x64 | maplibre-compose-runtime-vulkan-windows-x64 |
| Windows arm64 | maplibre-compose-runtime-vulkan-windows-arm64 |
On desktop, a ComposeMapPresentationHost supplies the window’s
graphics context. For Java AWT windows, use
rememberAwtComposeMapPresentationHost. For an alternative Compose
host, implement ComposeMapPresentationHost yourself.
fun main() { singleWindowApplication { ProvideMapPresentationHost(host = rememberAwtComposeMapPresentationHost(window)) { App() } }}The native bindings make FFM downcalls. Enable native access when you run the app:
compose.desktop { application { jvmArgs += "--enable-native-access=ALL-UNNAMED" }}Web (JS)
Section titled “Web (JS)”Compile the JS target to ES modules. Non-ESM builds are not supported.
kotlin { js { useEsModules() browser() }}product: type: kmp/lib platforms: [jvm, android, iosArm64, iosSimulatorArm64, js]product: js/app
dependencies: - //sharedInstall the browser graphics integration inside onWasmReady, before Compose
starts. The integration captures Compose’s graphics context.
fun main() { onWasmReady { installMapLibreCompose() ComposeViewport(document.body!!) { App() } }}Display your first map
Section titled “Display your first map”In your Composable UI, add a map:
@Composablefun MyApp() { MaplibreMap()}When you run your app, the map shows the default demotiles style. To load a full-featured style, proceed to Styling.