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