gpt4 book ai didi

swift - 如何快速将地址从应用程序传递到谷歌地图,而不仅仅是纬度和经度

转载 作者:行者123 更新时间:2023-11-28 13:29:06 25 4
gpt4 key购买 nike

我是 swift 的新手,在谷歌地图中显示地址时遇到问题。我只能显示纬度和经度。

if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
UIApplication.shared.openURL(NSURL(string: "comgooglemaps://?saddr=&daddr=\(Float(self.lat)!),\(Float(self.lon)!)&directionsmode=driving")! as URL)
}

enter image description here

此代码显示地址,如图所示。

最佳答案

您可以像这样将查询参数 qcomgooglemaps 方案一起使用

let address = "" //Replace with address to open

//Replace line breaks and white spaces in the address with queryable values
let queryableAddress = address.replacingOccurrences(of: "\n", with: " ").replacingOccurrences(of: " ", with: "%20")

if let url = URL(string: "comgooglemaps://?q=\(queryableAddress)"), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

关于swift - 如何快速将地址从应用程序传递到谷歌地图,而不仅仅是纬度和经度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57782471/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com