首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GeoFire循环查询NSException

GeoFire循环查询NSException
EN

Stack Overflow用户
提问于 2019-12-27 08:12:56
回答 1查看 40关注 0票数 0

我在我的Swift应用程序中使用Firebase和GeoFire 3.0 Cocoapod来填充世界各地的标记地图。以下是执行圆查询以获取地图上当前显示区域内的标记的代码:

代码语言:javascript
复制
        dbRef = Database.database().reference()
        let geoRef = GeoFire(firebaseRef: dbRef.child("markers"))
        let center = CLLocation(latitude: currentLocation.latitude, longitude: currentLocation.longitude)
        print("Center: "," Lat: ",currentLocation.latitude," Long: ",currentLocation.longitude )
        let circleQuery = geoRef.query(at: center, withRadius: 100)
        circleQuery.observe(.keyEntered, with: { key, location in
            print("key: ",key,"Location: ",location)
            let markerKey = key
            let markerLat = location.coordinate.latitude
            let markerLong = location.coordinate.longitude
            //read "verified" flag from firebase record "key"
            self.dbRef.child(markerKey).observeSingleEvent(of: .value, with: { (snapshot) in
                let value = snapshot.value as? NSDictionary
                let verified = value?["verified"] as? Bool
                print("key: ",key,"Location: ",location,"verified: ",verified as Any)
                ...
            })
         })

当用户缩小圆查询以显示整个世界的地图(半径为8000 Km (4791 MI))时,查询将中止,并显示NSException。

Xcode调试器显示GeoFire计算出的纬度为105.9793939...经度为-112.05707936..。

Geofire应该将纬度限制为+/- 90,将经度限制为+/- 180,在这种情况下,应该从查询中返回所有GeoFire数据。

下面是Xcode中错误的屏幕截图:Xcode Error Screenshot

是否有其他人看到此问题并/或找到解决方案?

EN

回答 1

Stack Overflow用户

发布于 2019-12-27 09:38:40

由于GeoFire显然没有按您希望的方式对纬度和经度进行限制,因此您有两种选择

  1. 报告有关GeoFire存储库的问题,并可能建议PR将值添加到您自己的应用程序代码中所需的范围。

我建议使用第二种方法,因为您希望/需要显示您在UI中裁剪/限制了范围。

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

https://stackoverflow.com/questions/59494688

复制
相关文章

相似问题

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