ios - 在谷歌地图 View 上放置按钮

标签 ios swift google-maps

我试图在 iOS 上的 Google map View 顶部显示一个按钮。我正在使用 Xcode 并尝试了以下代码:

let mapView = GMSMapView() 

 override func loadView(){
    view = mapView

    do{
        if let styleURL = Bundle.main.url(forResource: "style", withExtension: "json"){
            mapView.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
        }
    } catch {
    }

    let marker = GMSMarker()
    marker.position = CLLocationCoordinate2D(latitude: 45.45, longitude: -73.6)
    marker.title = "Montreal"
    marker.snippet = "Canada"
    marker.map = mapView

    onMapReady()

}

加载 map 时我没有看到任何按钮。 这是 Storyboard的样子:

Main Storyboard

约束条件如下: enter image description here

如何让这个按钮出现?

最佳答案

如果您在父 View 中添加了按钮,您可以像这样管理约束:

enter image description here

相反,如果按钮位于父 View 的外部和上方,您可以使用:

enter image description here

关于ios - 在谷歌地图 View 上放置按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47614490/

相关文章:

ios - 更改 map 坐标(MapKit)

iOS 8扩展和app目标的使用代码

ios - 在 Base ViewController 中展开 Optional 值时意外发现 nil

ios - 嵌套的 SplitviewController

ios - 升级到 Xcode 10 + Mac OS Mojave 后无法调试所选 View

ios - swift 中的自定义 UIBezierPath(Arc 麻烦)

ios - 有没有办法安排对 firebase 数据库的编辑?

google-maps - Google Maps API Referer 403错误

python - 将来自 Python 的 Google map 地理编码器与 urllib2 结合使用

javascript - 如何使用 javascript api v3 在 flash 中显示 Google map ?