Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

#2438 make sure tooltips for running data only show for the active layer group when in compare mode

Jason Kentf7faba9495d1
diff --git a/web/js/components/sidebar/paletteLegend.js b/web/js/components/sidebar/paletteLegend.js
index 64a78764c..8d765fb53 100644
--- a/web/js/components/sidebar/paletteLegend.js
+++ b/web/js/components/sidebar/paletteLegend.js
@@ -311,7 +311,7 @@ class PaletteLegend extends React.Component {
*/
renderClasses(legend, legendIndex) {
const { isRunningData, colorHex } = this.state;
- const { layer, parentLayer } = this.props;
+ const { layer, parentLayer, layerGroupName } = this.props;
const activeKeyObj = isRunningData && colorHex && this.getLegendObject(legend, colorHex, 5);
const legendClass = activeKeyObj
? 'wv-running wv-palettes-legend wv-palettes-classes'
@@ -329,7 +329,7 @@ class PaletteLegend extends React.Component {
const palletteClass = isActiveKey ? 'wv-active wv-palettes-class' : 'wv-palettes-class';
const isSubLayer = !!parentLayer;
const parentLayerId = isSubLayer ? parentLayer.id : '';
- const keyId = layer.id + '-' + legend.id + '-color-' + keyIndex + parentLayerId;
+ const keyId = layer.id + '-' + legend.id + '-color-' + keyIndex + parentLayerId + layerGroupName;
const keyLabel = activeKeyObj ? activeKeyObj.label : '';
return (
@@ -421,6 +421,7 @@ PaletteLegend.propTypes = {
isRunningDataEnabled: PropTypes.bool,
isSubLayer: PropTypes.bool,
layer: PropTypes.object,
+ layerGroupName: PropTypes.string,
paletteId: PropTypes.string,
paletteLegends: PropTypes.array,
parentLayer: PropTypes.object,
diff --git a/web/js/containers/sidebar/layer.js b/web/js/containers/sidebar/layer.js
index 13bfe219b..bb22c115e 100644
--- a/web/js/containers/sidebar/layer.js
+++ b/web/js/containers/sidebar/layer.js
@@ -41,7 +41,9 @@ class Layer extends React.Component {
getPaletteLegend = () => {
const {
+ compare,
layer,
+ layerGroupName,
runningObject,
paletteLegends,
checkerBoardPattern,
@@ -54,11 +56,14 @@ class Layer extends React.Component {
isMobile
} = this.props;
if (!lodashIsEmpty(renderedPalette)) {
- const isRunningData = !!runningObject;
+ const isRunningData = compare.active
+ ? (runningObject || {}).layerGroupName === layerGroupName
+ : !!runningObject;
const colorHex = isRunningData ? runningObject.paletteHex : null;
return (
<PaletteLegend
layer={layer}
+ layerGroupName={layerGroupName}
paletteId={palette.id}
getPalette={getPalette}
paletteLegends={paletteLegends}
@@ -280,6 +285,7 @@ Layer.defaultProps = {
};
Layer.propTypes = {
checkerBoardPattern: PropTypes.object,
+ compare: PropTypes.object,
getPalette: PropTypes.func,
hasPalette: PropTypes.bool,
hover: PropTypes.func,
@@ -316,7 +322,7 @@ function mapStateToProps(state, ownProps) {
index,
layerGroupName
} = ownProps;
- const { palettes, config, map, layers } = state;
+ const { palettes, config, map, layers, compare } = state;
const hasPalette = !lodashIsEmpty(layer.palette);
const renderedPalettes = palettes.rendered;
const paletteName = lodashGet(config, `layers['${layer.id}'].palette.id`);
@@ -329,6 +335,7 @@ function mapStateToProps(state, ownProps) {
});
return {
+ compare,
tracksForLayer,
layer,
isDisabled,
diff --git a/web/js/map/runningdata.js b/web/js/map/runningdata.js
index f43cba6a6..62e8a8ad1 100644
--- a/web/js/map/runningdata.js
+++ b/web/js/map/runningdata.js
@@ -67,7 +67,9 @@ export function MapRunningData(models, compareUi, store) {
*/
self.newPoint = function(pixels, map) {
const state = store.getState();
- var activeLayerObj = {};
+ const compareState = state.compare || {};
+ const layerGroupName = compareState.active && compareState.activeString;
+ const activeLayerObj = {};
const [lon, lat] = map.getCoordinateFromPixel(pixels);
if (!(lon < -180 || lon > 180 || lat < -90 || lat > 90)) {
map.forEachFeatureAtPixel(pixels, (feature, layer) => {
@@ -84,30 +86,29 @@ export function MapRunningData(models, compareUi, store) {
const properties = feature.getProperties();
const value = properties[identifier] || def.palette.unclassified;
if (!value) return;
- const tooltips = legend.tooltips.map(function(c) { return c.toLowerCase().replace(/\s/g, ''); });
+ const tooltips = legend.tooltips.map(c => c.toLowerCase().replace(/\s/g, ''));
const colorIndex = tooltips.indexOf(value.toLowerCase().replace(/\s/g, ''));
color = legend.colors[colorIndex];
} else if (legend.colors.length === 1) {
color = legend.colors[0];
}
- activeLayerObj[layerId] = { paletteLegends: paletteLegends, paletteHex: color };
+ activeLayerObj[layerId] = {
+ paletteLegends,
+ paletteHex: color,
+ layerGroupName
+ };
});
}
map.forEachLayerAtPixel(pixels, function(layer, data) {
if (!layer.wv) return;
- var paletteHex;
- var paletteLegends;
- var layerId;
- const def = layer.wv.def;
+ const { def } = layer.wv;
if (!isFromActiveCompareRegion(map, pixels, layer.wv)) return;
- if (
- (def.palette) &&
- !lodashGet(layer, 'wv.def.disableHoverValue')
- ) {
- layerId = def.id;
- paletteLegends = getPalette(layerId, undefined, undefined, state);
- paletteHex = util.rgbaToHex(data[0], data[1], data[2], data[3]);
- activeLayerObj[layerId] = { paletteLegends: paletteLegends, paletteHex: paletteHex };
+ if (def.palette && !lodashGet(layer, 'wv.def.disableHoverValue')) {
+ activeLayerObj[def.id] = {
+ paletteLegends: getPalette(def.id, undefined, undefined, state),
+ paletteHex: util.rgbaToHex(data[0], data[1], data[2], data[3]),
+ layerGroupName
+ };
}
});
if (!lodashIsEqual(activeLayerObj, dataObj)) {