根据屏幕边界查找附近的地方

问题描述

我想从中间点到达在可见地图f中显示的地方,

我使用这种方法来计算半径:

LatLngBounds bounds = await mapController.getVisibleRegion();

      center = LatLng(
        (bounds.northeast.latitude + bounds.southwest.latitude) / 2,(bounds.northeast.longitude + bounds.southwest.longitude) / 2,);

          var ne = bounds.northeast;
    
          var r = 3963.0;
    
          var lat1 = center.latitude / 57.2958;
          var lon1 = center.longitude / 57.2958;
          var lat2 = ne.latitude / 57.2958;
          var lon2 = ne.longitude / 57.2958;
    
    // distance = circle radius from center to northeast corner of bounds
          var radiuss= r *
              acos(
                  sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1));

我使用软件包 geoFlutterfire 从屏幕中心获取具有半径的文档集合。

String field = 'position';

Stream<List<DocumentSnapshot>> stream = geo.collection(collectionRef: collectionReference).within(center: center,radius: radiuss,field: field);

问题是,如果我的屏幕是矩形,则我的方法无法显示所有附近的地方:

建议根据屏幕边界显示所有地点

演示:我得到了什么

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)