Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

Split palette and vectorStyles in serializeLayers

ZachTRice4f938d14b4e0
diff --git a/web/js/components/layer/settings/settings.js b/web/js/components/layer/settings/settings.js
index 578739336..61c2814b2 100644
--- a/web/js/components/layer/settings/settings.js
+++ b/web/js/components/layer/settings/settings.js
@@ -17,7 +17,7 @@ import {
getCustomPalette,
getPaletteLegends,
getPalette,
- getLegend,
+ getPaletteLegend,
isPaletteAllowed
} from '../../../modules/palettes/selectors';
import {
@@ -192,7 +192,7 @@ class LayerSettings extends React.Component {
}
<Palette
setCustomPalette={setCustomPalette}
- clearCustom={clearCustomPalette}
+ clearCustomPalette={clearCustomPalette}
getDefaultLegend={getDefaultLegend}
getCustomPalette={getCustomPalette}
palettesTranslate={palettesTranslate}
diff --git a/web/js/modules/layers/reducers.js b/web/js/modules/layers/reducers.js
index 658628a8c..1a32e7635 100644
--- a/web/js/modules/layers/reducers.js
+++ b/web/js/modules/layers/reducers.js
@@ -12,7 +12,7 @@ import {
import {
SET_CUSTOM as SET_CUSTOM_PALETTE,
CLEAR_CUSTOM as CLEAR_CUSTOM_PALETTE,
- SET_RANGE_AND_SQUASH
+ SET_THRESHOLD_RANGE_AND_SQUASH
} from '../palettes/constants';
import {
SET_VECTORSTYLE,
diff --git a/web/js/modules/layers/util.js b/web/js/modules/layers/util.js
index 6f9c7bedd..119a4a81a 100644
--- a/web/js/modules/layers/util.js
+++ b/web/js/modules/layers/util.js
@@ -46,26 +46,28 @@ export function serializeLayers(currentLayers, state, groupName) {
});
}
- if (def.custom || def.min || def.max || def.min || def.squash) {
- // If has palette attr
+ if (def.palette && (def.custom || def.min || def.max || def.squash)) {
+ // If layer has palette and palette attributes
const paletteAttributeArray = getPaletteAttributeArray(
def.id,
palettes,
state
);
+
+ item.attributes = paletteAttributeArray.length
+ ? item.attributes.concat(paletteAttributeArray)
+ : item.attributes;
+ } else if (def.vectorStyle && (def.custom || def.min || def.max)) {
+ // If layer has vectorStyle and vectorStyle attributes
const vectorStyleAttributeArray = getVectorStyleAttributeArray(
def.id,
vectorStyles,
state
);
- if (paletteAttributeArray.length) {
- item.attributes = item.attributes.concat(paletteAttributeArray);
- } else if (vectorStyleAttributeArray.length) {
- item.attributes = item.attributes.concat(vectorStyleAttributeArray);
- } else {
- item.attributes = item.attributes;
- }
+ item.attributes = vectorStyleAttributeArray.length
+ ? item.attributes.concat(vectorStyleAttributeArray)
+ : item.attributes;
}
return util.appendAttributesForURL(item);
diff --git a/web/js/modules/palettes/selectors.js b/web/js/modules/palettes/selectors.js
index 75b2b23ee..50832a52f 100644
--- a/web/js/modules/palettes/selectors.js
+++ b/web/js/modules/palettes/selectors.js
@@ -310,7 +310,7 @@ export function setRange(layerId, props, index, palettes, state) {
return updateLookup(layerId, newPalettes, state);
}
-export function clearCustom(layerId, index, palettes, state) {
+export function clearCustomSelector(layerId, index, palettes, state) {
index = lodashIsUndefined(index) ? 0 : index;
var active = palettes[layerId];
if (!active) {