Getting started¶
This documentation assumes you already have a Compose Multiplatform project set up. If you haven't already, follow the official JetBrains documentation to set up a project.
Add the library to your app¶
This library is published via Maven Central, and snapshot builds of
main
are additionally available on GitHub Packages.
The latest release is v0.3.0. In your Gradle version catalog, add:
[libraries]
maplibre-compose = { module = "dev.sargunv.maplibre-compose:maplibre-compose", version = "0.3.0" }
Warning
The published documentation is for the latest release, and may not match the snapshot version. If using snapshots, always refer to the latest source code for the most accurate information.
First, follow GitHub's guide for authenticating to GitHub Packages. Your settings.gradle.kts should have something like this:
repositories {
maven {
url = uri("https://maven.pkg.github.com/sargunv/maplibre-compose")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GH_USERNAME")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GH_TOKEN")
}
}
}
The latest snapshot is v0.3.1-SNAPSHOT. In your Gradle version catalog, add:
[libraries]
maplibre-compose = { module = "dev.sargunv.maplibre-compose:maplibre-compose", version = "0.3.1-SNAPSHOT" }
In your Gradle build script, add:
commonMain.dependencies {
implementation(libs.maplibre.compose)
}
Set up iOS¶
For iOS, you'll additionally need to add the MapLibre framework to your build. The easiest way to do this in Kotlin Multiplatform is with the CocoaPods Gradle plugin:
cocoapods {
pod("MapLibre", "6.9.0")
}
Set up Vulkan on Android (Optional)¶
By default, we ship with the standard version of MapLibre for Android, which uses the OpenGL backend. If you'd prefer to use the Vulkan backend, you can update your build.
First, add the Vulkan build of MapLibre to your version catalog:
[libraries]
maplibre-android-vulkan = { module = "org.maplibre.gl:android-sdk-vulkan", version = "11.7.1" }
Then, exclude the standard MapLibre build from your dependency tree, and add the Vulkan build to your Android dependencies:
commonMain.dependencies {
implementation(libs.maplibre.compose) {
exclude(group = "org.maplibre.gl", module = "android-sdk")
}
}
androidMain.dependencies {
implementation(libs.maplibre.android.vulkan)
}
Display your first map¶
In your Composable UI, add a map:
@Composable
fun MyApp() {
MaplibreMap()
}
When you run your app, you should see the default demotiles map. To learn how to get a detailed map with all the features you'd expect, proceed to Styling.