Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps -canOpenURL:对于URL:“失败”;谷歌地图:“谷歌地图”错误:";操作无法’;不可能完成_Google Maps_Swift3 - Fatal编程技术网

Google maps -canOpenURL:对于URL:“失败”;谷歌地图:“谷歌地图”错误:";操作无法’;不可能完成

Google maps -canOpenURL:对于URL:“失败”;谷歌地图:“谷歌地图”错误:";操作无法’;不可能完成,google-maps,swift3,Google Maps,Swift3,我知道这个问题以前被问过并回答过,但我仍然在调试器控制台中遇到这个错误 2018-07-10 12:55:15.173843+0300布雷克林纳[34011:2595874] -canOpenURL:URL:“comgooglemaps://”失败-错误:“操作无法完成。(OSStatus错误-10814)。” 环境:Xcode 9.4,Swift 3。 请告知如何修复我的实现。希望其他人也会发现它很有用 Info.plist文件 <key>NSLocationWhenInUseU

我知道这个问题以前被问过并回答过,但我仍然在调试器控制台中遇到这个错误

2018-07-10 12:55:15.173843+0300布雷克林纳[34011:2595874] -canOpenURL:URL:“comgooglemaps://”失败-错误:“操作无法完成。(OSStatus错误-10814)。”

环境:Xcode 9.4,Swift 3。
请告知如何修复我的实现。希望其他人也会发现它很有用

Info.plist文件

 <key>NSLocationWhenInUseUsageDescription</key>
<string>Will you allow myApp to know your location?</string>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>tel</string>
    <string>googlechromes</string>
    <string>comgooglemaps</string>
</array>

你是否在plist中添加了
comgooglemaps-x-callback
??将其添加到
LSApplicationQueriesSchemes

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>comgooglemapsurl</string>
        <string>comgooglemaps</string>
        <string>comgooglemaps-x-callback</string>
    </array>
LSApplicationQueriesSchemes
谷歌地图
谷歌地图
comgooglemaps-x-callback

是,您需要如上所述添加到LSApplicationQueriesString。那么您只需要以下几行:

var address = "..."
address = address.replacingOccurrences(of: " ", with: "+")
UIApplication.shared.open(URL(string:"comgooglemaps://?q=\(address)&views=traffic")!, options: [:]) { success in
   if !success {
       UIApplication.shared.open(URL(string: "http://maps.apple.com/?address=\(address)")!)
   }
}

你们解决了吗?我解决了,看到答案了吗below@NavNav我的回答解决了你的问题吗?
<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>comgooglemapsurl</string>
        <string>comgooglemaps</string>
        <string>comgooglemaps-x-callback</string>
    </array>
var address = "..."
address = address.replacingOccurrences(of: " ", with: "+")
UIApplication.shared.open(URL(string:"comgooglemaps://?q=\(address)&views=traffic")!, options: [:]) { success in
   if !success {
       UIApplication.shared.open(URL(string: "http://maps.apple.com/?address=\(address)")!)
   }
}