better performance when adding thousands of markers to bettermap.

This commit is contained in:
byron pezan 2013-11-15 11:14:56 -05:00
parent 5fc0f39474
commit 8c2816a7c6

View File

@ -213,14 +213,18 @@ function (angular, app, _, L, localRequire) {
layerGroup.clearLayers();
}
var markerList = [];
_.each(scope.data, function(p) {
if(!_.isUndefined(p.tooltip) && p.tooltip !== '') {
layerGroup.addLayer(L.marker(p.coordinates).bindLabel(p.tooltip));
markerList.push(L.marker(p.coordinates).bindLabel(p.tooltip));
} else {
layerGroup.addLayer(L.marker(p.coordinates));
markerList.push(L.marker(p.coordinates));
}
});
layerGroup.addLayers(markerList);
layerGroup.addTo(map);
map.fitBounds(_.pluck(scope.data,'coordinates'));