From 8b98fe3544f0f10317fd187e62d2a5abd9cc9251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 18 May 2020 11:47:53 +0200 Subject: [PATCH] maps: add javascript functions to disable/enable layers (#42994) --- combo/apps/maps/static/js/combo.map.js | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/combo/apps/maps/static/js/combo.map.js b/combo/apps/maps/static/js/combo.map.js index 16218910..2380cecc 100644 --- a/combo/apps/maps/static/js/combo.map.js +++ b/combo/apps/maps/static/js/combo.map.js @@ -147,6 +147,36 @@ $(function() { } }, + disable_layer: function(slug) { + var layer = this.geojson_layers[slug]; + var group = this.clustered_markers || this; + if (layer) { + group.removeLayer(layer.leaflet_layer); + } + }, + + enable_layer: function(slug) { + var layer = this.geojson_layers[slug]; + var group = this.clustered_markers || this; + if (layer) { + group.addLayer(layer.leaflet_layer); + } + }, + + disable_all_layers: function() { + var layer_slugs = Object.keys(this.geojson_layers); + for (var i=0; i