From 1655349f7a6b07090ff089661f66a3f0cc7f1431 Mon Sep 17 00:00:00 2001 From: Jelmer van der Linde Date: Fri, 15 Sep 2017 11:44:50 +0200 Subject: [PATCH] Only update the visible features --- index.html | 2 +- leaflet.indexedfeaturelayer.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index f4ee73b..33c8069 100644 --- a/index.html +++ b/index.html @@ -111,7 +111,7 @@ lights.then(layer => { let draw = function(t) { - layer.eachLayer(marker => { + layer.eachVisibleLayer(marker => { try { marker.setState(marker.options.sequence.state(t)); } catch (e) { diff --git a/leaflet.indexedfeaturelayer.js b/leaflet.indexedfeaturelayer.js index 10f507f..dfcb186 100644 --- a/leaflet.indexedfeaturelayer.js +++ b/leaflet.indexedfeaturelayer.js @@ -106,13 +106,16 @@ L.IndexedFeatureLayer = L.GeoJSON.extend({ this._visible.removeFrom(map); }, + eachVisibleLayer: function(callback) { + return this._visible.eachLayer(callback); + }, + _getBounds: function() { return getBoundsWithPadding(this._map, this.options.padding); }, _redraw: function() { const layers = this.search(this._getBounds()); - console.log(layers.length, 'layers'); this._visible.updateLayers(layers); },