如何解决根据屏幕边界查找附近的地方
我想从中间点到达在可见地图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);
问题是,如果我的屏幕是矩形,则我的方法无法显示所有附近的地方:
建议根据屏幕边界显示所有地点
演示:我得到了什么
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。