【问题标题】:ios mylocationbutton missing on google map谷歌地图上缺少ios mylocationbutton
【发布时间】:2017-02-07 06:53:26
【问题描述】:

我正在尝试制作具有不同视图的滑出式导航应用。一种这样的观点是谷歌地图。但是,当我运行该应用程序时,会出现“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
    }
}

非常感谢任何帮助!

【问题讨论】:

    标签: ios google-maps swift


    【解决方案1】:

    位置按钮在调用mapView.settings.myLocationButton = true 时显示。

    所以,你应该把

    mapView.myLocationEnabled = true mapView.settings.myLocationButton = true

    viewDidLoad() 函数中。

    【讨论】:

    • 太棒了!它解决了我的问题!谢谢。
    【解决方案2】:

    事实证明,位置按钮始终位于视图上,但地图视图上的约束设置不正确,因此不可见。

    【讨论】:

      【解决方案3】:

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

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

      当然别忘了设置

      mapView.settings.myLocationButton = true
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-08-11
        • 2012-06-30
        • 2017-08-01
        • 2023-04-06
        • 2018-08-31
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多