我想以下列方式向地图添加进度条:http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.50000.html
问题是我在父群集组中使用子功能组,以便我可以在保持群集显示的同时轻松删除和添加图层。 我尝试了以下两种方法:
Leaflet.MarkerCluster.LayerSupport:当我尝试时,加载栏根本不起作用:
var mcgLayerSupportGroup = L.markerClusterGroup.layerSupport({chunkedLoading:true, chunkProgress:updateProgressBar});
Leaflet.FeatureGroup.SubGroup:显示加载栏,但不会显示添加的整体标记。相反,它是针对每个标记子组计算的。加载栏可能会消失,然后再次出现,等等。
var parentGroup = L.markerClusterGroup({chunkedLoading:true, chunkProgress:updateProgressBar});
到目前为止,我最好的尝试是调整updateProgressBar,但我的代码远没有效果(缓慢并近似于进度条的行为):
var tot_processed=0;
//this total_markers variable is computed when I call my API endpoints and compute the total number of markers
var total_markers;
function updateProgressBar(processed, total, elapsed, layersArray) {
tot_processed += processed;
if (total_trees - tot_processed > 1000) {
progress.style.display = 'block';
progressBar.style.width = Math.round(tot_processed/total_trees*100) + '%';
} else {
if (processed === total) {
// all markers processed - hide the progress bar:
progress.style.display = 'none';
}
}
}
非常感谢!