Hi everybody, Does anybody know how to render a c...
# compose-ios
c
Hi everybody, Does anybody know how to render a composable as an annotation or Marker for MapKit in a Kotlin-Multiplatform-Mobile (iOS side) project ? In other words, how can I use my own composable instead of rendering the default marker/annotation view associated with the location below ?
@OptIn(ExperimentalForeignApi::class)
@Composable
actual fun LocationVisualizer(
modifier: Modifier,
gps: GpsPosition,
title: String,
parentScrollEnableState: MutableState<Boolean>
) {
val location = CLLocationCoordinate2DMake(gps.latitude, gps.longitude)
val annotation = remember {
MKPointAnnotation(
location,
title = null,
subtitle = null
)
}
val mkMapView = remember { MKMapView().apply { addAnnotation(annotation) } }
annotation.setTitle(title)
UIKitView(
modifier = modifier,
factory = {
mkMapView
},
update = {
mkMapView.setRegion(
MKCoordinateRegionMakeWithDistance(
centerCoordinate = location,
10_000.0, 10_000.0
),
animated = false
)
}
)
}
[~ sorry for the double post ~] Here’s the link to the code : https://github.com/JetBrains/compose-multiplatform/blob/master/examples/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/LocationVisualizer.ios.kt