Cheick Kante
12/28/2023, 9:05 PM@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