【问题标题】:-canOpenURL: failed for URL: "comgooglemaps://" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"-canOpenURL:URL 失败:“comgooglemaps://” - 错误:“操作无法完成。(OSStatus 错误 -10814。)”
【发布时间】:2019-02-18 10:54:18
【问题描述】:

我正在使用谷歌地图。我已经给出了纬度和经度。我需要使用坐标在地图上显示位置。但我得到错误:

-canOpenURL:URL 失败:“comgooglemaps://” - 错误:“操作无法完成。(OSStatus 错误 -10814。)” 并将 else 部分打印为:“Can't use comgooglemaps://”

在 info.plist 我添加了: 1. LSApplicationQueriesSchemes 项目 0 字符串 googlechromes 项目 1 字符串 comgooglemaps

  1. 隐私 - 使用时的位置使用说明

我的代码已给出:

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://");
    }
}

【问题讨论】:

  • 为什么要投反对票?我没有得到搜索的解决方案?

标签: google-maps mapkit swift4


【解决方案1】:

在具有 google maps 应用程序的物理设备(不是模拟器)上运行您的应用程序,并且它应该使用您的代码正确启动。

【讨论】:

    猜你喜欢
    • 2019-02-10
    • 1970-01-01
    • 1970-01-01
    • 2020-07-24
    • 1970-01-01
    • 2018-03-01
    • 2018-04-05
    • 2019-01-28
    • 1970-01-01
    相关资源
    最近更新 更多