在iphone中打开谷歌地图无法正常工作

时间:2018-06-09 00:14:42

标签: ios swift google-maps

我正在使用此代码在Swift中打开Goog​​le地图,但它无效。

if (UIApplication.sharedApplication().canOpenURL(NSURL(string:"comgooglemaps://")!)) {
    UIApplication.sharedApplication().openURL(NSURL(string:
        "comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic")!)
} else {
    print("Can't use comgooglemaps://");
}

它始终显示消息“无法使用comgooglemaps://”

  • 我已将comgooglemaps添加到plist文件
  • 我已多次重启Xcode
  • 我已重新启动笔记本电脑
  • 我试过模拟器和真实设备

任何人都可以告诉我这是什么问题吗?

修改

info.plist文件

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>comgooglemaps</string>
        <string>googlechromes</string>
            <string>googlephotos</string>
        <string>telprompt</string>
        <string>tel</string>
        <string>http</string>
        <string>https</string>
    </array>

EDIT2

let url1:NSURL = NSURL(string:"comgooglemaps://")!;
         let url2:NSURL = NSURL(string:"comgooglemaps://?saddr=&daddr=\(self.selectedItem.latitude),\(self.selectedItem.longitude)&directionsmode=driving")!;
         let url3:NSURL = NSURL(string:"https://www.google.com/maps?saddr=&daddr=\(self.selectedItem.latitude),\(self.selectedItem.longitude)&directionsmode=driving")!;


        if (UIApplication.sharedApplication().canOpenURL(url1))
        {
            UIApplication.sharedApplication().openURL(url2)
        } else {
            UIApplication.sharedApplication().openURL(url3)
        }

1 个答案:

答案 0 :(得分:0)

试试这个

TO_NUMBER()

需要密钥

SUM()

<强>输出

enter image description here