GeoFire圈子查询NSException

问题描述 投票:0回答:1

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

        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

还有其他人看到此问题和/或找到解决方案了吗?

swift firebase geofire
1个回答
0
投票

由于GeoFire显然确实以您想要的方式限制了纬度和经度,所以您有两个选择

    报告有关GeoFire仓库的问题,并可能自己提出PR。

  • 将值限制在您自己的应用程序代码中所需的范围内。
  • 我建议使用第二种方法,因为您将希望/需要显示您已经限制/限制了UI中的范围。
  • © www.soinside.com 2019 - 2024. All rights reserved.