Stabilize beta release with warning cleanup and edge-case fixes
This commit is contained in:
@@ -51,11 +51,8 @@ struct AppleMapsLauncher {
|
||||
return .noWaypoints
|
||||
}
|
||||
|
||||
let mapItems = waypoints.map { waypoint -> MKMapItem in
|
||||
let placemark = MKPlacemark(coordinate: waypoint.coordinate)
|
||||
let item = MKMapItem(placemark: placemark)
|
||||
item.name = waypoint.name
|
||||
return item
|
||||
let mapItems = waypoints.map { waypoint in
|
||||
makeMapItem(name: waypoint.name, coordinate: waypoint.coordinate)
|
||||
}
|
||||
|
||||
if mapItems.count <= maxWaypoints {
|
||||
@@ -90,9 +87,7 @@ struct AppleMapsLauncher {
|
||||
/// - coordinate: Location to display
|
||||
/// - name: Display name for the pin
|
||||
static func openLocation(coordinate: CLLocationCoordinate2D, name: String) {
|
||||
let placemark = MKPlacemark(coordinate: coordinate)
|
||||
let mapItem = MKMapItem(placemark: placemark)
|
||||
mapItem.name = name
|
||||
let mapItem = makeMapItem(name: name, coordinate: coordinate)
|
||||
mapItem.openInMaps(launchOptions: nil)
|
||||
}
|
||||
|
||||
@@ -108,13 +103,8 @@ struct AppleMapsLauncher {
|
||||
to: CLLocationCoordinate2D,
|
||||
toName: String
|
||||
) {
|
||||
let fromPlacemark = MKPlacemark(coordinate: from)
|
||||
let fromItem = MKMapItem(placemark: fromPlacemark)
|
||||
fromItem.name = fromName
|
||||
|
||||
let toPlacemark = MKPlacemark(coordinate: to)
|
||||
let toItem = MKMapItem(placemark: toPlacemark)
|
||||
toItem.name = toName
|
||||
let fromItem = makeMapItem(name: fromName, coordinate: from)
|
||||
let toItem = makeMapItem(name: toName, coordinate: to)
|
||||
|
||||
MKMapItem.openMaps(with: [fromItem, toItem], launchOptions: [
|
||||
MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving
|
||||
@@ -169,4 +159,17 @@ struct AppleMapsLauncher {
|
||||
Array(items[start..<min(start + size, items.count)])
|
||||
}
|
||||
}
|
||||
|
||||
private static func makeMapItem(name: String, coordinate: CLLocationCoordinate2D) -> MKMapItem {
|
||||
let location = CLLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)
|
||||
let item: MKMapItem
|
||||
if #available(iOS 26.0, *) {
|
||||
item = MKMapItem(location: location, address: nil)
|
||||
} else {
|
||||
let placemark = MKPlacemark(coordinate: coordinate)
|
||||
item = MKMapItem(placemark: placemark)
|
||||
}
|
||||
item.name = name
|
||||
return item
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user