首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >didUpdate userLocation:谷歌地图ios swyft的MKUserLocation

didUpdate userLocation:谷歌地图ios swyft的MKUserLocation
EN

Stack Overflow用户
提问于 2019-01-05 20:16:06
回答 1查看 129关注 0票数 0

我最近把我的地图从mapkit换成了google地图。然而,我正准备将用户位置坐标更新为firebase。谷歌相当于MKUserLocation是什么?

代码语言:javascript
复制
func mapView(_ mapView: GMSMapView, didUpdate userLocation: MKUserLocation) {
        UpdateService.instance.updateALocation(withCoordinate: userLocation.coordinate)
        UpdateService.instance.updateBLocation(withCoordinate: userLocation.coordinate)

我希望能够实时更新坐标到firebase的坐标

EN

回答 1

Stack Overflow用户

发布于 2019-01-05 20:43:33

简单的答案是谷歌地图没有一个等价的方法。从iOS的角度来看,谷歌地图是第三方。因此,就像所有其他应用程序一样,它们也必须使用苹果的核心位置库来获取用户位置。即使是MKMapView也在内部使用CLLocationManager。您需要使用locationManager:didUpdateLocations:委托方法。

你可以参考这个答案来了解核心位置在谷歌地图中的使用。https://stackoverflow.com/a/38627279/4637057

因此,在您的示例中,如果您想要将位置坐标发送到Firebase,那么在locationManager:didUpdateLocations:内部访问locations.last?.coordinate.latitude!locations.last?.coordinate.longitude!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54051906

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档