KMP Maps
KMP Maps provides a unified map component for Compose Multiplatform applications, offering seamless integration with native map APIs on both Android and iOS platforms.
🎯 Usage
@Composable
fun MyMapScreen() {
Map(
modifier = Modifier.fillMaxSize(),
properties = MapProperties(
isMyLocationEnabled = true,
mapType = MapType.NORMAL,
),
uiSettings = MapUISettings(
myLocationButtonEnabled = true,
compassEnabled = true
),
cameraPosition = CameraPosition(
coordinates = Coordinates(latitude = 50.0619, longitude = 19.9373),
zoom = 13f
),
markers = listOf(
Marker(
coordinates = Coordinates(latitude = 50.0486, longitude = 19.9654),
title = "Software Mansion",
androidSnippet = "Software house"
)
),
onMarkerClick = { marker ->
println("Marker clicked: ${marker.title}")
},
onMapClick = { coordinates ->
println("Map clicked at: ${coordinates.latitude}, ${coordinates.longitude}")
}
)
}
📦 Installation
✅ Recommended: Using Gradle Version Catalogs
First, add the library to your gradle/libs.versions.toml
file:
[versions]
kmpMaps = "0.1.0"
[libraries]
swmansion-kmpMaps = { module = "com.swmansion.kmpmaps:kmp-maps", version.ref = "kmpMaps" }
Then add it to your build.gradle.kts
:
dependencies {
implementation(libs.swmansion.kmpMaps)
}
🔧 Alternative: Direct Dependency Declaration
If you're not using Gradle version catalogs, you can add the library directly to your build.gradle.kts
:
dependencies {
implementation("com.swmansion.kmpmaps:kmp-maps:0.1.0")
}
🤖 Android Setup - Google Maps API Key
To use Google Maps on Android, you need to configure your API key in AndroidManifest.xml
:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY" />
☁️ Google Cloud API Setup
Before you can use Google Maps on Android, you need to register a Google Cloud API project and enable the Maps SDK for Android:
1. Register a Google Cloud API project and enable the Maps SDK for Android
Open your browser to the Google API Manager and create a project
Once it's created, go to the project and enable the Maps SDK for Android
2. Copy your app's SHA-1 certificate fingerprint
For Google Play Store:
Upload your app binary to Google Play Console at least once
Go to Google Play Console (your app) Release Setup App integrity App signing
Copy the value of SHA-1 certificate fingerprint
For development builds:
After the build is complete, go to your project's dashboard
Under Project settings click Credentials
Under Application Identifiers, click your project's package name
Under Android Keystore copy the value of SHA-1 Certificate Fingerprint
3. Create an API key
Go to Google Cloud Credential manager and click Create Credentials, then API Key
In the modal, click Edit API key
Under Key restrictions Application restrictions, choose Android apps
Under Restrict usage to your Android apps, click Add an item
Add your package name to the package name field
Then, add the SHA-1 certificate fingerprint's value from step 2
Click Done and then click Save
4. Add the API key to your project
Copy your API Key into your
AndroidManifest.xml
as shown aboveCreate a new build, and you can now use the Google Maps API on Android
🔐 Permissions
To display the user's location on the map, you need to declare and request location permissions:
Add the following permissions to your AndroidManifest.xml
:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
🍎 iOS Setup - Apple Maps
No additional configuration is required for Apple Maps on iOS.
🔐 Permissions
To display the user's location on the map, you need to declare location permissions:
Add the following key to your Info.plist
:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow this app to use your location</string>
KMP Maps provides a unified map component for Compose Multiplatform applications, offering seamless integration with native map APIs on both Android and iOS platforms.
🎯 Usage
@Composable
fun MyMapScreen() {
Map(
modifier = Modifier.fillMaxSize(),
properties = MapProperties(
isMyLocationEnabled = true,
mapType = MapType.NORMAL,
),
uiSettings = MapUISettings(
myLocationButtonEnabled = true,
compassEnabled = true
),
cameraPosition = CameraPosition(
coordinates = Coordinates(latitude = 50.0619, longitude = 19.9373),
zoom = 13f
),
markers = listOf(
Marker(
coordinates = Coordinates(latitude = 50.0486, longitude = 19.9654),
title = "Software Mansion",
androidSnippet = "Software house"
)
),
onMarkerClick = { marker ->
println("Marker clicked: ${marker.title}")
},
onMapClick = { coordinates ->
println("Map clicked at: ${coordinates.latitude}, ${coordinates.longitude}")
}
)
}
📦 Installation
✅ Recommended: Using Gradle Version Catalogs
First, add the library to your gradle/libs.versions.toml
file:
[versions]
kmpMaps = "0.1.0"
[libraries]
swmansion-kmpMaps = { module = "com.swmansion.kmpmaps:kmp-maps", version.ref = "kmpMaps" }
Then add it to your build.gradle.kts
:
dependencies {
implementation(libs.swmansion.kmpMaps)
}
🔧 Alternative: Direct Dependency Declaration
If you're not using Gradle version catalogs, you can add the library directly to your build.gradle.kts
:
dependencies {
implementation("com.swmansion.kmpmaps:kmp-maps:0.1.0")
}
🤖 Android Setup - Google Maps API Key
To use Google Maps on Android, you need to configure your API key in AndroidManifest.xml
:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY" />
☁️ Google Cloud API Setup
Before you can use Google Maps on Android, you need to register a Google Cloud API project and enable the Maps SDK for Android:
1. Register a Google Cloud API project and enable the Maps SDK for Android
Open your browser to the Google API Manager and create a project
Once it's created, go to the project and enable the Maps SDK for Android
2. Copy your app's SHA-1 certificate fingerprint
For Google Play Store:
Upload your app binary to Google Play Console at least once
Go to Google Play Console (your app) Release Setup App integrity App signing
Copy the value of SHA-1 certificate fingerprint
For development builds:
After the build is complete, go to your project's dashboard
Under Project settings click Credentials
Under Application Identifiers, click your project's package name
Under Android Keystore copy the value of SHA-1 Certificate Fingerprint
3. Create an API key
Go to Google Cloud Credential manager and click Create Credentials, then API Key
In the modal, click Edit API key
Under Key restrictions Application restrictions, choose Android apps
Under Restrict usage to your Android apps, click Add an item
Add your package name to the package name field
Then, add the SHA-1 certificate fingerprint's value from step 2
Click Done and then click Save
4. Add the API key to your project
Copy your API Key into your
AndroidManifest.xml
as shown aboveCreate a new build, and you can now use the Google Maps API on Android
🔐 Permissions
To display the user's location on the map, you need to declare and request location permissions:
Add the following permissions to your AndroidManifest.xml
:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
🍎 iOS Setup - Apple Maps
No additional configuration is required for Apple Maps on iOS.
🔐 Permissions
To display the user's location on the map, you need to declare location permissions:
Add the following key to your Info.plist
:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow this app to use your location</string>
KMP Maps provides a unified map component for Compose Multiplatform applications, offering seamless integration with native map APIs on both Android and iOS platforms.
🎯 Usage
@Composable
fun MyMapScreen() {
Map(
modifier = Modifier.fillMaxSize(),
properties = MapProperties(
isMyLocationEnabled = true,
mapType = MapType.NORMAL,
),
uiSettings = MapUISettings(
myLocationButtonEnabled = true,
compassEnabled = true
),
cameraPosition = CameraPosition(
coordinates = Coordinates(latitude = 50.0619, longitude = 19.9373),
zoom = 13f
),
markers = listOf(
Marker(
coordinates = Coordinates(latitude = 50.0486, longitude = 19.9654),
title = "Software Mansion",
androidSnippet = "Software house"
)
),
onMarkerClick = { marker ->
println("Marker clicked: ${marker.title}")
},
onMapClick = { coordinates ->
println("Map clicked at: ${coordinates.latitude}, ${coordinates.longitude}")
}
)
}
📦 Installation
✅ Recommended: Using Gradle Version Catalogs
First, add the library to your gradle/libs.versions.toml
file:
[versions]
kmpMaps = "0.1.0"
[libraries]
swmansion-kmpMaps = { module = "com.swmansion.kmpmaps:kmp-maps", version.ref = "kmpMaps" }
Then add it to your build.gradle.kts
:
dependencies {
implementation(libs.swmansion.kmpMaps)
}
🔧 Alternative: Direct Dependency Declaration
If you're not using Gradle version catalogs, you can add the library directly to your build.gradle.kts
:
dependencies {
implementation("com.swmansion.kmpmaps:kmp-maps:0.1.0")
}
🤖 Android Setup - Google Maps API Key
To use Google Maps on Android, you need to configure your API key in AndroidManifest.xml
:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY" />
☁️ Google Cloud API Setup
Before you can use Google Maps on Android, you need to register a Google Cloud API project and enable the Maps SDK for Android:
1. Register a Google Cloud API project and enable the Maps SDK for Android
Open your browser to the Google API Manager and create a project
Once it's created, go to the project and enable the Maps SDK for Android
2. Copy your app's SHA-1 certificate fingerprint
For Google Play Store:
Upload your app binary to Google Play Console at least once
Go to Google Play Console (your app) Release Setup App integrity App signing
Copy the value of SHA-1 certificate fingerprint
For development builds:
After the build is complete, go to your project's dashboard
Under Project settings click Credentials
Under Application Identifiers, click your project's package name
Under Android Keystore copy the value of SHA-1 Certificate Fingerprint
3. Create an API key
Go to Google Cloud Credential manager and click Create Credentials, then API Key
In the modal, click Edit API key
Under Key restrictions Application restrictions, choose Android apps
Under Restrict usage to your Android apps, click Add an item
Add your package name to the package name field
Then, add the SHA-1 certificate fingerprint's value from step 2
Click Done and then click Save
4. Add the API key to your project
Copy your API Key into your
AndroidManifest.xml
as shown aboveCreate a new build, and you can now use the Google Maps API on Android
🔐 Permissions
To display the user's location on the map, you need to declare and request location permissions:
Add the following permissions to your AndroidManifest.xml
:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
🍎 iOS Setup - Apple Maps
No additional configuration is required for Apple Maps on iOS.
🔐 Permissions
To display the user's location on the map, you need to declare location permissions:
Add the following key to your Info.plist
:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow this app to use your location</string>