Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-canOpenURL: failed for URL: "comgooglemaps://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

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

  1. Privacy - Location When In Use Usage Description

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://");
    }
}
like image 845
Swift Guy Avatar asked Dec 10 '25 11:12

Swift Guy


1 Answers

Run your app on a physical device (NOT Simulator) that does have the google maps app and it should launch correctly using your code.

like image 144
Kosuke Ogawa Avatar answered Dec 14 '25 11:12

Kosuke Ogawa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!