我正在尝试制作一个具有不同 View 的滑出式导航应用程序。一种这样的 View 是谷歌地图。但是,当我运行该应用程序时,会出现“Google”水印,但缺少“我的位置”按钮。这与这篇文章非常相似google map sdk ios 7 mylocationbutton disappear但是 self.edgesForExtendedLayout = UIRectEdge.None;
除了提供额外的空格外没有任何改变。此外,为什么出现谷歌水印而不是位置按钮也没有意义。
在 ViewController.swift
中
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
mapView.delegate = self
mapView.settings.rotateGestures = false;
mapView.settings.compassButton = true;
}
func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
if status == .AuthorizedWhenInUse {
locationManager.startUpdatingLocation()
mapView.myLocationEnabled = true
mapView.settings.myLocationButton = true
}
}
非常感谢任何帮助!
最佳答案
位置按钮在 mapView.settings.myLocationButton = true
被调用时显示。
所以,你可能应该把
mapView.myLocationEnabled = true
mapView.settings.myLocationButton = true
在 viewDidLoad()
函数中。
关于谷歌地图上缺少 ios mylocationbutton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28160451/