【问题标题】:Recenter Google Map when app is returned to foreground using Swift使用 Swift 将应用程序返回到前台时重新定位 Google 地图
【发布时间】:2016-10-05 20:48:27
【问题描述】:

我正在为我正在开发的应用程序使用 Google Maps iOS SDK。当应用程序返回前台或用户返回地图视图时,我现在需要在用户当前位置重新定位地图。我已经搜索和搜索并尝试了一些东西,但是没有任何效果。

我曾尝试将代码放置在 CoreLocation 堆栈的“didUpdateLocations”处理程序中,但这不起作用。同时,当应用程序重新回到前台时,viewWillAppear 函数没有被调用,所以也没有工作。

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {        
    let camera = GMSCameraPosition.camera(withLatitude: (manager.location!.coordinate.latitude), longitude: (manager.location!.coordinate.longitude), zoom: 16.0)
    self.mapView?.animate(to: camera)
}

感谢任何帮助。

【问题讨论】:

    标签: ios iphone swift3 google-maps-sdk-ios


    【解决方案1】:

    您是否尝试过使用通知中心?在带有地图的视图控制器中添加观察者,然后在 applicationDidBecomeActive 中的 AppDelegate 中发布通知。 (由于我的声誉,我不能发布 cmets)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-02
      • 2018-05-16
      • 2020-11-27
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多