如何在 google 地图上显示内容?
How to display something over the google map?
我对 iOS 开发和使用 google 地图 sdk 都很陌生。我正在为我当前的项目使用 Xcode。我已经在适当的地方添加了我的 API 键。
到目前为止我有这个:
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
}
}
当我使用我的 phone 构建和 运行 应用程序时,应用程序安装 运行s,并显示 google 经纬度地图 I问它。我的问题是如何在地图上显示某些内容?我想在屏幕顶部附近添加一个显示 "Start" 的按钮。但是当我去 Main.storyboard 并添加一个按钮时它没有出现(大概是因为我的地图在上面?)
谢谢!
在情节提要视图层次结构中确保按钮位于地图视图之后(下方),您也可以像
这样编码
self.view.bringSubview(toFront: yourButton)
我对 iOS 开发和使用 google 地图 sdk 都很陌生。我正在为我当前的项目使用 Xcode。我已经在适当的地方添加了我的 API 键。
到目前为止我有这个:
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
}
}
当我使用我的 phone 构建和 运行 应用程序时,应用程序安装 运行s,并显示 google 经纬度地图 I问它。我的问题是如何在地图上显示某些内容?我想在屏幕顶部附近添加一个显示 "Start" 的按钮。但是当我去 Main.storyboard 并添加一个按钮时它没有出现(大概是因为我的地图在上面?)
谢谢!
在情节提要视图层次结构中确保按钮位于地图视图之后(下方),您也可以像
这样编码self.view.bringSubview(toFront: yourButton)