如何计算扑扑200米以内的附近居民名单?

时间:2019-11-10 18:55:33

标签: firebase flutter dart gps

我想显示附近的人的名单。如何使循环计算所有数据库的纬度和经度,并给我附近的人名单,以便我可以向他们发送通知。哪个API对此有帮助?以及如何实现所有这些东西?

1 个答案:

答案 0 :(得分:1)

选中geolocator

此插件具有一种计算两个位置之间距离的方法

double distanceInMeters = await Geolocator().distanceBetween(startLatitude,startLongitude,endLatitude,endLongitude);

您可以循环查看附近的人

for (var person in people) {
      double distanceInMeters = await Geolocator().distanceBetween(thisLatitude,thisLongitude,person.Latitude,person.Longitude);
      if(distanceInMeters<=200){
        notification();
      }
    }