Interactive interface for browsing global, full-resolution satellite imagery
Properly remove layers from OL layer groups #1182
Benjamin King673a73957f2d
diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex 5e99719b9..b48cfcfdb 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -29,7 +29,7 @@ import { mapDateLineBuilder } from './datelinebuilder';import { mapLayerBuilder } from './layerbuilder';import { MapRunningData } from './runningdata';import { mapPrecacheTile } from './precachetile';-import { mapUtilZoomAction } from './util';+import { mapUtilZoomAction, getActiveLayerGroup } from './util';import { mapCompare } from './compare/compare';import Cache from 'cachai';@@ -445,11 +445,17 @@ export function mapui(models, config) {* @returns {void}*/var removeLayer = function(def) {+ var activeLayerString = models.layers.activeLayers;if (isGraticule(def)) {- removeGraticule(models.layers.activeLayers);+ removeGraticule(activeLayerString);} else {- var layer = findLayer(def, models.layers.activeLayers);- self.selected.removeLayer(layer);+ var layer = findLayer(def, activeLayerString);+ if (models.compare && models.compare.active) {+ let layerGroup = getActiveLayerGroup(self.selected, activeLayerString);+ layerGroup.getLayers().remove(layer);+ } else {+ self.selected.removeLayer(layer);+ }}updateLayerVisibilities();};diff --git a/web/js/map/util.js b/web/js/map/util.jsindex 7f92d8984..1967c529f 100644--- a/web/js/map/util.js+++ b/web/js/map/util.js@@ -1,4 +1,5 @@const ZOOM_DURATION = 250;+/** Setting a zoom action*@@ -24,3 +25,16 @@ export function mapUtilZoomAction(map, amount, duration, center) {center: centerPoint});};+export function getActiveLayerGroup (map, layerGroupString) {+ var group = null;+ var array = map.getLayers().getArray();+ for (var i = 0, len = array.length; i < len; i++) {+ let layerGroup = array[i];+ console.log(layerGroup.get('group'), layerGroupString);+ if (layerGroup.get('group') === layerGroupString) {+ group = layerGroup;+ break;+ }+ };+ return group;+};