谷歌地图上缺少 ios mylocationbutton

标签 ios google-maps swift

我正在尝试制作一个具有不同 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/

相关文章:

swift - 如何在 swift 4 中正确使用 sqlite3 数据库中的追加函数

Swift JSON to Dictionary<String : Any>. Then cast "Any"as NSMutableArray

swift - MVP - 在 iOS 中解散时从 View Controller 中销毁 Presenter 对象

java - 如何在开始时设置位置 - Google Maps API V2

database - Postgis ST_DIstance 查询返回不准确的结果

ios - 使 UILabel 出现在故事​​板中的 UIImageView 之上

ios - 制作一个 Sprite 节点 "jump"spritekit iOS

ios - 将 Google map 添加到我的应用程序时出现问题

iphone - 将 int 转换为 NSInteger

iphone - iOS : comparing the two images