From 8c2816a7c6c51a13f3e4378272ce8ac1ed6e1090 Mon Sep 17 00:00:00 2001 From: byron pezan Date: Fri, 15 Nov 2013 11:14:56 -0500 Subject: [PATCH] better performance when adding thousands of markers to bettermap. --- src/app/panels/bettermap/module.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/panels/bettermap/module.js b/src/app/panels/bettermap/module.js index c6b070319fa..ef11c47a9b0 100644 --- a/src/app/panels/bettermap/module.js +++ b/src/app/panels/bettermap/module.js @@ -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'));