我很难从iPhone应用程序中启动Google应用程序。当应用程序安装在设备上时,代码会在Safari中启动Google的Web版本。另一方面,Apple Maps本地应用程序成功发布。
下面是我使用的代码:
@IBAction func openMap(_ sender: Any) {
let lat: Double = -37.8218956215849
let long: Double = 144.9599325656891
let appleString = "https://maps.apple.com/?daddr=\(lat),\(long)" // Apple Maps - successfully launches an app
let googleString = "https://www.google.com/maps/dir/?api=1&destination=\(lat)%2C\(long)" // Google Maps - launches a Web version
let selectedString: String = googleString // Change accordingly
let url = URL(string: selectedString)!
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
我想,这个问题非常简单,但是我仍然没有想出如何解决它。
更新
即使是谷歌的例子也不适用于iOS 12 Beta 2:https://developers.google.com/maps/documentation/urls/ios-urlscheme
,这个问题可能与Beta软件的使用有关。
发布于 2018-12-18 17:27:40
这个问题似乎在上一次iOS发行版(12.1.2)上得到了解决。现在,下面的链接在iPhone上工作:
https://www.google.com/maps/dir/Current+Location/51.5230369,-0.08225500000003194
作为在iOs上工作的/dir api的替代解决方案,您可以使用/search:
https://www.google.com/maps/search/?api=1&query={your_lat},{your_lon}
https://www.google.com/maps/search/?api=1&query=28.6139,77.2090
https://stackoverflow.com/questions/51154042
复制相似问题