Error[8]: Undefined offset: 2, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我有以下Firebase数据库结构, "-KSupX7CppMD1zbqIy0y" : { "addedByUser" : "zQpb7o18VzYsSoTQtT9DNhOqTUn2", "content" : "Post 1", "cost" : "20", "duration" : "Weekly", "latitude" : "40.7594479995956", " 我有以下Firebase数据库结构,

"-KSupX7CppMD1zbqIy0y" : {  "addedByUser" : "zQpb7o18VzYsSoTQtT9DNhOqTUn2","content" : "Post 1","cost" : "20","duration" : "Weekly","latitude" : "40.7594479995956","longitude" : "-73.9838934062393","timestamp" : "Fri 30 Sep"},"-KSuphuqO6a0lnrJYUkt" : {  "addedByUser" : "zQpb7o18VzYsSoTQtT9DNhOqTUn2","content" : "Post 2","cost" : "10","duration" : "Daily","latitude" : "40.7594329996462","longitude" : "-73.9846261181847","timestamp" : "Fri 30 Sep"}

我需要在一定的距离参数(小于50米,100米,150米和200米)内过滤帖子.我可以从“经度”和“经度”获得坐标. “纬度”,但我正在努力过滤帖子.任何帮助将不胜感激.

提前谢谢了.新手到Firebase&迅速.

解决方法 以下是您可以尝试的解决方案.这假设您已将所有帖子从Firebase下载到应用程序并存储在数组中.你也可以考虑使用我没有亲自使用的GeoFire(但我想).我相信它允许您按位置查询Firebase,因此您不必首先将所有帖子下载到用户的设备并在客户端进行过滤.

// assumes you have set up the app to get the user's current locationvar currentLocation: CLLocation?// Your array of posts downloaded from Firebasevar postArray = [post]()let metersInTwentyFiveMiles = 40233.6// You Could put this in vIEwDIDAppear after you load the post array from Firebasefor post in postArray {    var distanceInMeters: CLLocationdistance = 0    let postLocation = CLLocation(latitude: post.latitude,longitude: post.longitude)    if let currentLocation = self.currentLocation {         // Set distanceInMeters to the distance between the user's current location and the location of the post.         distanceInMeters = currentLocation.distanceFromLocation(postLocation)         // If this distance is not within 25 miles,remove this post from the array         if self.metersInTwentyFiveMiles < distanceInMeters {            self.posts = self.posts.filter{ [+++] != post }       }    }}
总结

以上是内存溢出为你收集整理的swift – 根据位置半径过滤Firebase数据库全部内容,希望文章能够帮你解决swift – 根据位置半径过滤Firebase数据库所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
swift – 根据位置半径过滤Firebase数据库_app_内存溢出

swift – 根据位置半径过滤Firebase数据库

swift – 根据位置半径过滤Firebase数据库,第1张

概述我有以下Firebase数据库结构, "-KSupX7CppMD1zbqIy0y" : { "addedByUser" : "zQpb7o18VzYsSoTQtT9DNhOqTUn2", "content" : "Post 1", "cost" : "20", "duration" : "Weekly", "latitude" : "40.7594479995956", " 我有以下Firebase数据库结构,

"-KSupX7CppMD1zbqIy0y" : {  "addedByUser" : "zQpb7o18VzYsSoTQtT9DNhOqTUn2","content" : "Post 1","cost" : "20","duration" : "Weekly","latitude" : "40.7594479995956","longitude" : "-73.9838934062393","timestamp" : "Fri 30 Sep"},"-KSuphuqO6a0lnrJYUkt" : {  "addedByUser" : "zQpb7o18VzYsSoTQtT9DNhOqTUn2","content" : "Post 2","cost" : "10","duration" : "Daily","latitude" : "40.7594329996462","longitude" : "-73.9846261181847","timestamp" : "Fri 30 Sep"}

我需要在一定的距离参数(小于50米,100米,150米和200米)内过滤帖子.我可以从“经度”和“经度”获得坐标. “纬度”,但我正在努力过滤帖子.任何帮助将不胜感激.

提前谢谢了.新手到Firebase&迅速.

解决方法 以下是您可以尝试的解决方案.这假设您已将所有帖子从Firebase下载到应用程序并存储在数组中.你也可以考虑使用我没有亲自使用的GeoFire(但我想).我相信它允许您按位置查询Firebase,因此您不必首先将所有帖子下载到用户的设备并在客户端进行过滤.

// assumes you have set up the app to get the user's current locationvar currentLocation: CLLocation?// Your array of posts downloaded from Firebasevar postArray = [post]()let metersInTwentyFiveMiles = 40233.6// You Could put this in vIEwDIDAppear after you load the post array from Firebasefor post in postArray {    var distanceInMeters: CLLocationdistance = 0    let postLocation = CLLocation(latitude: post.latitude,longitude: post.longitude)    if let currentLocation = self.currentLocation {         // Set distanceInMeters to the distance between the user's current location and the location of the post.         distanceInMeters = currentLocation.distanceFromLocation(postLocation)         // If this distance is not within 25 miles,remove this post from the array         if self.metersInTwentyFiveMiles < distanceInMeters {            self.posts = self.posts.filter{  != post }       }    }}
总结

以上是内存溢出为你收集整理的swift – 根据位置半径过滤Firebase数据库全部内容,希望文章能够帮你解决swift – 根据位置半径过滤Firebase数据库所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1015442.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存