watch: use MapKit directions handoff
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Foundation
|
import Foundation
|
||||||
import WatchKit
|
import MapKit
|
||||||
|
|
||||||
private enum WatchFuelType: String, CaseIterable, Identifiable, Codable {
|
private enum WatchFuelType: String, CaseIterable, Identifiable, Codable {
|
||||||
case e10
|
case e10
|
||||||
@@ -580,8 +580,14 @@ struct ContentView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func openMaps(latitude: Double, longitude: Double) {
|
private func openMaps(latitude: Double, longitude: Double) {
|
||||||
guard let url = URL(string: "maps://?daddr=\(latitude),\(longitude)&t=d") else { return }
|
let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
|
||||||
WKExtension.shared().openSystemURL(url)
|
let destination = MKMapItem(placemark: MKPlacemark(coordinate: coordinate))
|
||||||
|
_ = MKMapItem.openMaps(
|
||||||
|
with: [MKMapItem.forCurrentLocation(), destination],
|
||||||
|
launchOptions: [
|
||||||
|
MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving
|
||||||
|
]
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user