KrossMap is a Kotlin Multiplatform maps library for Compose Multiplatform. One Compose API draws Google Maps on Android and Apple MapKit on iOS, natively on each platform, with markers, shapes, camera control, location and native map controls.
Whether you're building a delivery app, ride tracker, or location-based feature, KrossMap simplifies the map experience with powerful abstractions and built-in utilities.
- 🧩 Declarative content:
Marker,Polyline,Polygon,CircleinsideKrossMap { } - 🧭 Animated markers that point along their heading, with labels
- 📷 Camera you can read, animate, and fit to bounds; follow mode like Google Maps / Apple Maps
- 📍 Location state with heading, permission status and errors, plus the native location dot
- 🔘 Native controls: Liquid Glass buttons on iOS 26, Material 3 on Android
- 👆 Map, marker and shape tap events
- 🌗 Map types, dark mode, custom styling, zoom limits, content padding
- 🌍 Kotlin Multiplatform: Android & iOS
To add KrossMap to your project, include the following in your shared module's build.gradle.kts:
dependencies {
implementation("io.github.farimarwat:krossmap:2.0")
}Requires Kotlin 2.3.21 or newer. On Android, add your Google Maps API key to the manifest
(com.google.android.geo.API_KEY). The library does not ask for location permission itself; request
it in your app (the demo uses moko-permissions).
val camera = rememberKrossCameraPositionState(latitude = 32.6037, longitude = 70.9217, zoom = 15f)
KrossMap(
modifier = Modifier.fillMaxSize(),
cameraPositionState = camera,
)Everything inside KrossMap { } is on the map; remove it from the composition and it leaves the map.
KrossMap(cameraPositionState = camera) {
Marker(
state = rememberKrossMarkerState(KrossCoordinate(32.6037, 70.9217)),
title = "Shop",
icon = KrossMarkerIcon.Vector(Icons.Default.Store, tint = Color.Red),
onClick = { println("Shop tapped"); true },
)
Polyline(points = route, color = Color.Blue, width = 6.dp)
Polyline(points = walk, color = Color.Gray, width = 4.dp, dashLength = 8.dp)
Polygon(points = area, fillColor = Color.Red.copy(alpha = 0.25f), strokeColor = Color.Red, holes = listOf(courtyard))
Circle(center = start, radiusMeters = 150.0, fillColor = Color.Green.copy(alpha = 0.2f))
}Marker icons can be PNG bytes (KrossMarkerIcon.Bytes), an ImageBitmap, an ImageVector or any Painter.
Set markerState.position to move a marker; the move is animated (animationMillis, default 1000).
val location = rememberKrossLocationState()
val player = rememberKrossMarkerState(start)
LaunchedEffect(location.currentLocation) { location.currentLocation?.let { player.position = it } }
KrossMap(
cameraPositionState = camera,
locationState = location,
properties = KrossMapProperties(showMyLocation = true),
controls = listOf(KrossMapControl.MyLocation, KrossMapControl.Toggle3D, KrossMapControl.Follow),
) {
Marker(state = player, title = "Me", icon = carIcon, rotation = location.currentLocation?.bearing ?: 0f)
}KrossMapControl.Followstarts location updates and makes the camera follow position and heading; dragging the map turns following off.location.currentLocation,isUpdating,hasPermissionandlocationErrorare Compose state. Updates pause in the background and stop when the state leaves composition.- Add your own buttons with
KrossMapControl.Custom(id, iosSymbol, icon, contentDescription, onClick = { }).
scope.launch { camera.animateCamera(latitude = lat, longitude = lng, zoom = 17f, tilt = 45f) }
camera.moveCamera(zoom = 12f) // no animation
scope.launch { camera.animateToBounds(route) } // fit points on screen
Text("zoom ${camera.position.zoom}") // live position; camera.isMoving tooKrossMap(
cameraPositionState = camera,
properties = KrossMapProperties(
mapType = KrossMapType.Hybrid,
colorScheme = KrossMapColorScheme.System, // or Light / Dark
maxZoom = 19f,
showTraffic = true,
),
contentPadding = PaddingValues(bottom = 120.dp), // keep controls and logo above a bottom sheet
onMapClick = { coordinate -> },
onMapLongClick = { coordinate -> },
onCameraIdle = { position -> },
)Platform extras: androidMapStyleJson (a Google Maps style) and iosPointOfInterestCategories
(for example setOf("MKPOICategoryRestaurant")).
- 🧩 Declarative map content:
Marker,Polyline(solid or dashed),Polygon(with holes) andCircle, each withzIndexandonClick, declared insideKrossMap { }. - 📍
KrossLocationState: location on its own, with heading,hasPermission,isUpdatingandlocationError;showMyLocationshows the native location dot. - 🔘 Native controls: My Location, 2D/3D, Follow and custom buttons. Liquid Glass with SF Symbols on iOS 26+ (blur material on earlier iOS), Material 3 on Android.
- 📷 Camera: live
positionandisMoving,moveCamera,animateToBounds; zoom means the same on both platforms;durationMillisis respected; following turns off when the user drags the map. - 🌗 Appearance: map types, dark mode, custom styles, POI filters,
minZoom/maxZoom,contentPadding. - 🏷️ Consistent markers: icons centered on their coordinate and rotated to their heading even when the map rotates or tilts; titles in a label underneath on both platforms.
- 🛠️ Reliability: iOS keeps markers and shapes in sync (add, update, remove); smooth heading without GPS jitter; location stops in the background; line widths in dp look the same on both platforms; no Activity leaks.
1.x code keeps compiling and working: KrossMapState, rememberKrossMapState() and KrossMap(mapState = …)
are deprecated wrappers over the 2.0 API. To migrate:
| 1.x | 2.0 |
|---|---|
rememberKrossMapState() |
rememberKrossLocationState() for location; markers and shapes go in KrossMap { } |
mapState.addOrUpdateMarker(KrossMarker(coordinate, title, icon)) |
Marker(state = rememberKrossMarkerState(coordinate), title = title, icon = KrossMarkerIcon.Bytes(icon)) and set state.position to move it |
mapState.removeMarker(marker) |
stop declaring the Marker |
mapState.addPolyLine(KrossPolyLine(points, color = c, width = w)) |
Polyline(points, color = c, width = w.dp) |
mapState.startLocationUpdate() / stopLocationUpdate() |
location.startUpdates() / stopUpdates(), or the Follow control |
mapState.onUpdateLocation = { } |
read location.currentLocation (Compose state) |
KrossMap(mapState = …, onMarkerClick = { }) |
KrossMap(locationState = …) { Marker(onClick = { }) } |
mapSettings = { MyButtons() } |
controls = listOf(…), or overlay your own UI in a Box |
Other changes from 1.3:
- Polyline width is in dp (1.3 used Android pixels: divide old values by about 2.75).
- Marker icons are centered on their coordinate (on Android they used to sit above it).
KrossCoordinate.bearingandKrossMarker.coordinateareval(usecopy());calculateBearingreturns 0–360°.showTrafficis off by default;KrossMapState.currentLocationis read-only.
-
🧭 Improved Camera Controls on iOS
- Enhanced support for camera tilting and direction handling on iOS.
-
⚙️ New Map Properties API
- Introduced
KrossMapPropertiesto control:- 🏙️
showBuildings– Toggle 3D building rendering - 📍
showPointOfInterest– Show points of interest (iOS only) - 🚗
showTraffic– Enable real-time traffic overlay - 🔄
enableRotationGesture– Allow user rotation - 🧭
enableTiltGesture– Allow tilting with gestures - 🖐️
enableScrollGesture– Enable panning/scrolling
- 🏙️
- Introduced
KrossMap is open-source and welcomes contributions!
If you find a bug, have a feature request, or want to improve the library, feel free to open an issue or submit a pull request.
Check the issues section for things you can help with.
Hi, I’m Farman Ullah Khan – a passionate Android & Kotlin Multiplatform developer.
I love building open-source tools that simplify cross-platform development and improve developer experience.
You can connect with me on LinkedIn or check out my other projects on GitHub.