-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Javier Manrique
committed
Dec 1, 2024
1 parent
689346f
commit e49c44c
Showing
4 changed files
with
27 additions
and
20 deletions.
There are no files selected for viewing
22 changes: 12 additions & 10 deletions
22
...esentation/src/iosMain/kotlin/com/jmp/wayback/presentation/app/platform/MapActuals.ios.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
package com.jmp.wayback.presentation.app.platform | ||
|
||
import kotlinx.cinterop.ExperimentalForeignApi | ||
import platform.CoreLocation.CLLocationCoordinate2DMake | ||
import platform.MapKit.MKMapItem | ||
import platform.MapKit.MKPlacemark | ||
import platform.Foundation.NSURL | ||
import platform.UIKit.UIApplication | ||
|
||
@OptIn(ExperimentalForeignApi::class) | ||
actual fun openMap(latitude: Double, longitude: Double) { | ||
val coordinate = CLLocationCoordinate2DMake(latitude, longitude) | ||
val placemark = MKPlacemark(coordinate) | ||
val mapItem = MKMapItem(placemark = placemark) | ||
mapItem.name = "Wayback pin" | ||
mapItem.openInMapsWithLaunchOptions(null) | ||
val urlString = "http://maps.apple.com/?ll=${latitude},${longitude}&q=${"Wayback pin"}" | ||
val url = NSURL.URLWithString(urlString) ?: return | ||
|
||
if (UIApplication.sharedApplication.canOpenURL(url)) { | ||
UIApplication.sharedApplication.openURL( | ||
url = url, | ||
options = emptyMap<Any?, Any>(), | ||
completionHandler = null | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters