如何在Google地图上显示内容? [英] How to display something over the google map?

查看:106
本文介绍了如何在Google地图上显示内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对iOS开发和使用Google Maps sdk都是新手.我正在为当前项目使用Xcode.我已经在适当的位置添加了API密钥.

I am very new to both iOS developing and using the google maps sdk. I am using Xcode for my current project. I have added my API keys in the appropriate place.

到目前为止,我有这个:

So far I have this:

import UIKit
import GoogleMaps
import GooglePlaces

class MyViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    override func loadView() {
        // Create a GMSCameraPosition that tells the map to display the
        // coordinate -33.86,151.20 at zoom level 6.
        let camera = GMSCameraPosition.cameraWithLatitude(36.2108, longitude: -81.6774, zoom: 17.0)
        let mapView = GMSMapView.mapWithFrame(CGRect.zero, camera: camera)
        mapView.myLocationEnabled = true
        self.view = mapView
    }

}

当我使用手机构建和运行该应用程序时,该应用程序会安装,运行并显示我要求的经纬度的google地图.我的问题是如何在地图上显示内容?我想添加一个按钮,在屏幕顶部附近居中显示开始".但是当我转到Main.storyboard并添加按钮时,它没有出现(大概是因为我的地图在上面吗?)

When I build and run the app using my phone, the app installs, runs, and displays the google map of the latitude and longitude I asked it to. My question is how do i display something over the map? I want to add a button that says "Start" centered near the top of the screen. But when i go to Main.storyboard and add a button it does not appear (presumably because my map is over it?)

谢谢!

推荐答案

在情节提要视图层次结构中,请确保按钮位于地图视图之后(下方),您也可以像

in storyboard views hierarchy make sure the button goes after (below) the map view, also you can code like

self.view.bringSubview(toFront: yourButton)

这篇关于如何在Google地图上显示内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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