无法打开 google 地图
Can't open google map
我使用以下 swift 代码,但它每次都打印 "Can't use comgooglemaps://"。我在真实 iphone7 中测试它并且 google 地图应用程序已经安装。
请大家帮忙
if UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
UIApplication.shared.open(URL(string:"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic")!)
} else {
print("Can't use comgooglemaps://")
}
必须定义密钥 LSApplicationQueriesSchemes
,因此在您的 Info.plist
中您应该具有以下内容:
如果您想手动更改它,您可以添加:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
</array>
您可以在Step 7: Declare the URL schemes used by the API查看官方文档:
Beginning with iOS 9 and Xcode 7, apps must declare the URL schemes that they intend to open, by specifying the schemes in the app's Info.plist file. The Google Maps SDK for iOS opens the Google Maps mobile app when the user clicks the Google logo on the map, and your app therefore needs to declare the relevant URL schemes.
我使用以下 swift 代码,但它每次都打印 "Can't use comgooglemaps://"。我在真实 iphone7 中测试它并且 google 地图应用程序已经安装。 请大家帮忙
if UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!) {
UIApplication.shared.open(URL(string:"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic")!)
} else {
print("Can't use comgooglemaps://")
}
必须定义密钥 LSApplicationQueriesSchemes
,因此在您的 Info.plist
中您应该具有以下内容:
如果您想手动更改它,您可以添加:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
</array>
您可以在Step 7: Declare the URL schemes used by the API查看官方文档:
Beginning with iOS 9 and Xcode 7, apps must declare the URL schemes that they intend to open, by specifying the schemes in the app's Info.plist file. The Google Maps SDK for iOS opens the Google Maps mobile app when the user clicks the Google logo on the map, and your app therefore needs to declare the relevant URL schemes.