I have this app and I want to use google maps or apple maps to open when the user presses a button in my app. How would I be able to do this? Is there like a link to the map
At button click (in action) call function "directions()" with following code :
func directions() {
// if GoogleMap installed
if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
UIApplication.shared.openURL(NSURL(string:
"comgooglemaps://?saddr=&daddr=\(Float(event.addressLat)!),\(Float(event.addressLong)!)&directionsmode=driving")! as URL)
} else {
// if GoogleMap App is not installed
UIApplication.shared.openURL(NSURL(string:
"https://maps.google.com/?q=@\(Float(event.addressLat)!),\(Float(event.addressLong)!)")! as URL)
}
}
Edit your info.plist for LSApplicationQueriesSchemes :
Hope will help!