如何使用掉针打开Goog​​le Maps应用程序? -斯威夫特 [英] How to open google maps app with a dropped pin ? - Swift

查看:52
本文介绍了如何使用掉针打开Goog​​le Maps应用程序? -斯威夫特的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码可以打开具有特定位置的Google Maps App,并且可以正常工作,但是我需要在该位置放置图钉,有可能吗?

I have this code to open Google Maps App with specific location and it's working but what I need is to drop a pin on that location, is it possible ?

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:用于搜索的查询字符串.

q: The query string for your search.

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

It creates a marker in given coordinates. Try this

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://")
    }
}

这篇关于如何使用掉针打开Goog​​le Maps应用程序? -斯威夫特的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆