Manos Chorianopoulos

fix webview open maps

......@@ -469,6 +469,26 @@ var timer2: DispatchSourceTimer?
decisionHandler(.cancel)
return
}
// Example Deeplink: maps://?q=37.96951649191105,23.72242553856438
if redirectedUrl.absoluteString.contains("maps:") {
// Extract the latitude and longitude from the query string
if let query = redirectedUrl.query {
let coordinates = query.replacingOccurrences(of: "q=", with: "").split(separator: ",")
if coordinates.count == 2,
let lat = coordinates.first,
let lon = coordinates.last {
// Create a new Apple Maps URL
if let appleMapsUrl = URL(string: "http://maps.apple.com/?daddr=\(lat),\(lon)") {
// Open Apple Maps with the generated URL
UIApplication.shared.open(appleMapsUrl, options: [:], completionHandler: nil)
decisionHandler(.cancel)
return
}
}
}
}
}
// }
......