loadedObjects = {
await start;
const map = newMap(mapContainer);
invalidation.then(() => map.remove());
const f = compressedBinaryToGeoJson(';');
let counter = 0;
const bufferSize = visualBatchSize;
const N = 10;
const buffer = [];
const heat = L.heatLayer([], {
gradient: {0.3: '#6a2c70', 0.5 : '#b83b5e', 0.75: '#f08a5d', 1: '#f9ed69'}
}).addTo(map);
heat.setLatLngs = function (list) {
this._latlngs = [...list];
return this.redraw();
}
invalidation.then(() => heat.remove());
const group = L.featureGroup().addTo(map);
invalidation.then(() => group.remove());
for await (let feature of f(await openFileStream())) {
const latlng = feature.geometry.coordinates;
const marker = L.circleMarker(latlng, {
stroke : true,
color: 'white',
opacity : 0.9,
weight : 1,
fillColor: 'red',
fillOpacity: 0.8,
radius: 3
})
group.addLayer(marker);
buffer.push(marker);
while (buffer.length > bufferSize) {
const toRemove = buffer.shift();
group.removeLayer(toRemove);
}
counter++;
if ((counter % N) !== 0) continue;
yield {
total : counter,
visible : [counter - buffer.length, counter]
}
let center = { lat : 0, lng : 0};
const coords = [];
let count = 0;
group.eachLayer(layer => {
const { lat, lng } = layer.getLatLng();
coords.push([lat, lng]);
center.lat += lat;
center.lng += lng;
count++;
});
if (count) {
center.lat /= count;
center.lng /= count;
map.panTo(center);
}
heat.setLatLngs(coords);
await Promises.delay(100);
}
yield {
total : counter,
visible : [counter - buffer.length, counter]
}
}