Leaflet, это популярная гео-библиотека.
По некоторым причинам у меня возникают серьезные проблемы с производительностью при использовании этой библиотеки вместе с Vue.
Проблема 1:
Более 500 маркеров, и страница уже начинает спотыкаться, 2000 маркеров - сильно ломается, 10 000 маркеров - не загружается.
На веб-странице HTML 50 000 загружаются мирно.
Задача 2:
Плагин Leaflet.markercluster очень слабый, он не сворачивает маркеры.
mounted() {
this.initMap();
setTimeout(() => {
this.initLocation()
}, 100)
},
methods: {
initMap() {
this.map = L.map('map').setView([38.63, -90.23], 12);
this.tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
});
this.tileLayer.addTo(this.map);
},
initLocation() {
this.map.locate({
setView: true,
maxZoom: 17
});
//Leaflet.markercluster
let markers = L.markerClusterGroup();
function r(min, max) {
return Math.random() * (max - min) + min;
}
let icon = L.divIcon({
className: 'icon'
});
for (let i = 0; i < 500; i++) {
let marker = L.marker([r(53.82477192, 53.97365592), r(27.3878027, 27.70640622)], {
icon: icon
}).addTo(this.map);
markers.addLayer(marker);
}
this.map.addLayer(markers);
},
}