mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-01 16:26:55 +02:00
add a simple progress bar to the 50K sample
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="progress"><div id="progress-bar"></div></div>
|
||||
<div id="map"></div>
|
||||
<span>Mouse over a cluster to see the bounds of its children and click a cluster to zoom to those bounds</span>
|
||||
<script type="text/javascript">
|
||||
@@ -28,7 +29,23 @@
|
||||
|
||||
var map = L.map('map', { center: latlng, zoom: 13, layers: [cloudmade] });
|
||||
|
||||
var markers = L.markerClusterGroup({ chunkedLoading: true });
|
||||
var progress = document.getElementById('progress');
|
||||
var progressBar = document.getElementById('progress-bar');
|
||||
|
||||
function updateProgressBar(processed, total, elapsed, layersArray) {
|
||||
if (elapsed > 1000) {
|
||||
// if it takes more than a second to load, display the progress bar:
|
||||
progress.style.display = 'block';
|
||||
progressBar.style.width = Math.round(processed/total*100) + '%';
|
||||
}
|
||||
|
||||
if (processed === total) {
|
||||
// all markers processed - hide the progress bar:
|
||||
progress.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
var markers = L.markerClusterGroup({ chunkedLoading: true, chunkProgress: updateProgressBar });
|
||||
|
||||
var markerList = [];
|
||||
|
||||
|
||||
@@ -3,3 +3,26 @@
|
||||
height: 600px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
#progress {
|
||||
display: none;
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
left: 400px;
|
||||
top: 300px;
|
||||
width: 200px;
|
||||
height: 20px;
|
||||
margin-top: -20px;
|
||||
margin-left: -100px;
|
||||
background-color: #fff;
|
||||
background-color: rgba(255, 255, 255, 0.7);
|
||||
border-radius: 4px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
#progress-bar {
|
||||
width: 0;
|
||||
height: 100%;
|
||||
background-color: #76A6FC;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user