ios - 如何使用掉落的图钉打开谷歌地图应用程序? - swift

标签 ios swift google-maps google-maps-sdk-ios

我有这段代码可以打开带有特定位置的 Google map 应用程序,它可以正常工作,但我需要在该位置放置一个图钉,这可能吗?

if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {

                UIApplication.shared.openURL(URL(string:
                    "comgooglemaps://?center=\(self.location.coordinate.latitude),\(self.location.coordinate.longitude)&zoom=14&views=traffic")!)
            } else {
                print("Can't use comgooglemaps://");
            }

如何做到这一点?

最佳答案

q: The query string for your search.

它在给定的坐标中创建一个标记。试试这个

if (UIApplication.shared.canOpenURL(URL(string:"comgooglemaps://")!)) {
        UIApplication.shared.open(URL(string:"comgooglemaps://?center=\(self.location.coordinate.latitude),\(self.location.coordinate.longitude)&zoom=14&views=traffic&q=\(self.location.coordinate.latitude),\(self.location.coordinate.longitude)")!, options: [:], completionHandler: nil)
    } else {
        print("Can't use comgooglemaps://")
    }
}

关于ios - 如何使用掉落的图钉打开谷歌地图应用程序? - swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43276530/

相关文章:

ios - 分配周末 FSCalendar

google-maps - 生成动态谷歌地图标记的库?

javascript - Google map 路线 - 了解路线是否包含收费站

ios - 在两个按钮之间居中 View

ios - 如何设置 Xamarin iOS SDK 版本以在 Azure Devops 上构建

ios - Swift:从 url 检索音频文件标记列表?

ios - 文件更改时 Xcode 停止读取文本文件

ios - 通过目标成员身份而不是目录指定 Cocoapod 源文件

ios - 从数组 swift 访问图像

ios - 如何使用谷歌地图获取 map 可见区域中注释/标记的数量?