I am using google maps. I have latitude and longitude given. I need to show location on maps using coordinates. But I get error as :
-canOpenURL: failed for URL: "comgooglemaps://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" And it prints the else part as: "Can't use comgooglemaps://"
In info.plist I have added : 1. LSApplicationQueriesSchemes Item 0 String googlechromes Item 1 String comgooglemaps
My code is given :
import UIKit
import MapKit
class MapViewController: UIViewController, MKMapViewDelegate {
var data7: String?
var data8: String?
override func viewDidLoad() {
super.viewDidLoad()
getAddress()
}
func getAddress() {
if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
UIApplication.shared.openURL(URL(string:"comgooglemaps://?saddr=&daddr=\(data7),\(data8)&directionsmode=driving")!)
}
else {
print("Can't use comgooglemaps://");
}
}
Run your app on a physical device (NOT Simulator) that does have the google maps app and it should launch correctly using your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With