diff --git a/AutoCat/Screens/EventsScreen/EventsScreen.swift b/AutoCat/Screens/EventsScreen/EventsScreen.swift index 163fe66..fd15fae 100644 --- a/AutoCat/Screens/EventsScreen/EventsScreen.swift +++ b/AutoCat/Screens/EventsScreen/EventsScreen.swift @@ -129,6 +129,10 @@ struct EventsScreen: View { } label: { Label("Open in Maps", systemImage: "map") } + + if let link = viewModel.getMapLink(for: event) { + ShareLink(item: link) + } } } } diff --git a/AutoCat/Screens/EventsScreen/EventsViewModel.swift b/AutoCat/Screens/EventsScreen/EventsViewModel.swift index 138b1a8..9b2c928 100644 --- a/AutoCat/Screens/EventsScreen/EventsViewModel.swift +++ b/AutoCat/Screens/EventsScreen/EventsViewModel.swift @@ -132,9 +132,9 @@ class EventsViewModel: ACHudContainer { } } - func getMapLink(for event: VehicleEventDto) -> URL? { - var urlString = "http://maps.apple.com/?sll=\(event.latitude),\(event.longitude)" - if let address = event.address?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { + func getMapLink(for event: EventModel) -> URL? { + var urlString = "http://maps.apple.com/?sll=\(event.coordinate.latitude),\(event.coordinate.longitude)" + if let address = event.address.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { urlString = urlString + "&address=" + address } return URL(string: urlString) @@ -146,7 +146,7 @@ class EventsViewModel: ACHudContainer { } let sharedData: [String: Any?] = [ - UTType.url.identifier: getMapLink(for: eventDto), + UTType.url.identifier: getMapLink(for: event), UTType.vehicleEvent.identifier: try? JSONEncoder().encode(eventDto) ]