我正在使用谷歌地图。我已经知道了纬度和经度。我需要使用坐标在地图上显示位置。但我得到的错误是:
-canOpenURL: URL:"comgooglemaps://“失败-错误:”无法完成操作。(OSStatus错误-10814。)“并将else部分打印为:"Can't use comgooglemaps://“
在info.plist中我添加了: 1. LSApplicationQueriesSchemes Item 0 String googlechromes Item 1 String comgooglemaps
我的代码如下:
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://");
}
}
发布于 2018-09-14 08:00:40
在安装了谷歌地图应用程序的物理设备(而不是模拟器)上运行您的应用程序,它应该会使用您的代码正确启动。
https://stackoverflow.com/questions/52318206
复制相似问题