ios google 地图上缺少 mylocationbutton

ios mylocationbutton missing on google map

我正在尝试制作一个具有不同视图的滑出式导航应用程序。 google 地图就是这样一种视图。但是,当我 运行 应用程序时,会出现 "Google" 水印,但 "My location" 按钮 缺失 。它与 post google map sdk ios 7 mylocationbutton disappear 非常相似,但是 self.edgesForExtendedLayout = UIRectEdge.None; 除了提供额外的空格外没有任何改变。此外,为什么出现 google 水印而不是位置按钮也没有意义。

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() 函数中。

事实证明,位置按钮一直在视图上,但地图视图上的约束设置不正确,所以它不可见。

我在 UINavigationController ViewController 中使用地图,导航栏不是半透明的,按钮也没有出现。

我把它设置为半透明,然后它就出现了。不知道为什么,但我希望这可能有所帮助。

当然别忘了设置

mapView.settings.myLocationButton = true