angular - Leaflet MarkerCluster removeOutsideVisibleBounds 不起作用

标签 angular leaflet leaflet.markercluster ngx-leaflet

我有一个使用Leaflet.markercluster的传单 map 插件。

簇在 map 上正确绘制,但我注意到即使我将 removeOutsideVisibleBounds 选项设置为 true, View 之外的簇仍在渲染。

我可以判断的是,如果我通过按住鼠标按钮来平移 map ,则在平移时所有簇仍然可见。

集群组的配置如下:

let myCluster = L.markerClusterGroup({ spiderfyOnMaxZoom: false, removeOutsideVisibleBounds: true });

为了确保删除 View 之外的簇,我还缺少什么?

该项目在 Angular 5 中使用 ngx-leaflet。

最佳答案

您可能刚刚错过了 removeOutsideVisibleBounds 选项说明的这一部分(重点是我的):

removeOutsideVisibleBounds: Clusters and markers too far from the viewport are removed from the map for performance.

这个“太远”的意思是,它仍然将标记和簇保留在每个方向 1 个视口(viewport)大小的“缓冲区”区域内;除移动设备外,其缓冲区为0,以便更轻地占用设备内存。

因此,在桌面浏览器上,您必须将 map 平移超过 1 个 map 视口(viewport)大小,然后才能看到丢失的标记和簇,只有当您停止平移(释放鼠标)时,这些标记和簇才会重新出现。

如果您检查 source code :

Gets the maps visible bounds expanded in each direction by the size of the screen (so the user cannot see an area we do not cover in one pan)

关于angular - Leaflet MarkerCluster removeOutsideVisibleBounds 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50418715/

相关文章:

javascript - "OuterSubscriber is not defined"使用 rollup.js 打包时

javascript - 如何根据 GeoJSON 属性中的 ID 号设置下拉列表项的顺序

javascript - 传单弹出窗口不会打开( react )

angular - 如何取消 FirebaseObjectObservable 订阅?

javascript - 如何在其他可观察对象完成时返回可观察对象

Leaflet.Deflate 与 Leaflet.markercluster 悬停时不显示集群覆盖范围

leaflet - 更改所有标记的拖动状态

javascript - 传单 map 标记簇不显示图标

javascript - 如何在表格单元格内放置 p-dropdown?

javascript - Angular2-Leafletjs : Defining style for L. geoJSON().addTo(myMap)