Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add a/b conditional dates to opacity and spy compare, filter event prelim fix, style fixes

Ed Platof2a6fc197eeb
diff --git a/web/css/compare.css b/web/css/compare.css
index 4437d418e..0d4dafbdb 100644
--- a/web/css/compare.css
+++ b/web/css/compare.css
@@ -57,7 +57,6 @@
left: 0;
right: 0;
bottom: 195px;
- width: 232px;
text-align: center;
background: rgba(40, 40, 40, 0.85);
border-radius: 3px;
@@ -65,21 +64,19 @@
height: 36px;
}
.ab-slider-case .input-range {
- width: 146px;
+ width: 110px;
display: inline-block;
- margin: 6px 17px;
+ margin: 6px 14px;
}
.ab-slider-case .wv-slider-label {
display: inline-block;
vertical-align: top;
margin-top: 12px;
- width: 15px;
- font-size: 16px;
- text-align: center;
+ text-align: left;
+ white-space: nowrap;
}
.ab-slider-case .wv-slider-label h4 {
- font-weight: 700;
- font-size: 16px;
+ font-weight: 400;
}
.ab-slider-case .input-range__slider {
height: 20px;
@@ -106,6 +103,7 @@
background: rgba(40, 40, 40, 0.8);
color: rgba(255, 255, 255, 0.9);
display: block;
+ white-space: nowrap;
font-size: 14px;
border-radius: 3px;
border: 1px solid #000;
diff --git a/web/css/embed.css b/web/css/embed.css
index 95d901e86..2bf7f83ec 100644
--- a/web/css/embed.css
+++ b/web/css/embed.css
@@ -127,6 +127,16 @@
right: 12px;
}
+ /* ANIMATION WIDGET */
+ .wv-animation-widget-wrapper.minimized {
+ bottom: 64px;
+ }
+ #wv-animation-widget .wv-close {
+ opacity: 0.3;
+ user-select: none;
+ pointer-events: none;
+ }
+
/* MISC */
#wv-toolbar {
display: none;
@@ -134,8 +144,11 @@
#wv-measure-button {
display: none;
}
- .wv-animation-widget-wrapper.minimized {
- bottom: 64px;
+
+ @media only screen and (max-width: 576px) {
+ .ab-slider-case {
+ bottom: 120px;
+ }
}
@media only screen and (max-width: 350px) {
.wv-animation-widget-wrapper.minimized {
diff --git a/web/js/components/compare/opacity-slider.js b/web/js/components/compare/opacity-slider.js
index a689d9c0a..895eb184b 100644
--- a/web/js/components/compare/opacity-slider.js
+++ b/web/js/components/compare/opacity-slider.js
@@ -21,6 +21,7 @@ class OpacitySlider extends React.Component {
value: props.value,
};
this.onSlide = this.onSlide.bind(this);
+ this.getDateTextOptions = this.getDateTextOptions.bind(this);
this.debounceOpacityUpdate = lodashDebounce(this.onSlide, 100);
}
@@ -39,12 +40,34 @@ class OpacitySlider extends React.Component {
onSlide(value);
}
+ getDateTextOptions() {
+ const { dateA, dateB } = this.props;
+ const isSameDate = dateA === dateB;
+ let dateAText = 'A';
+ let dateBText = 'B';
+ if (!isSameDate) {
+ dateAText += `: ${dateA}`;
+ dateBText += `: ${dateB}`;
+ }
+ const labelStyle = isSameDate ? {} : { width: '105px', paddingLeft: '3px' };
+ const caseStyle = { width: isSameDate ? '178px' : '356px' };
+ return {
+ dateAText,
+ dateBText,
+ caseStyle,
+ labelStyle,
+ };
+ }
+
render() {
const { value } = this.state;
+ const {
+ dateAText, dateBText, caseStyle, labelStyle,
+ } = this.getDateTextOptions();
return (
- <div id="ab-slider-case" className="ab-slider-case">
- <label className="wv-slider-label left">
- <h4>A</h4>
+ <div id="ab-slider-case" className="ab-slider-case" style={caseStyle}>
+ <label className="wv-slider-label left" style={labelStyle}>
+ <h4>{dateAText}</h4>
</label>
<div className="input-range ">
<SliderWithTooltip
@@ -54,8 +77,8 @@ class OpacitySlider extends React.Component {
onAfterChange={this.onSlide}
/>
</div>
- <label className="wv-slider-label right">
- <h4>B</h4>
+ <label className="wv-slider-label right" style={labelStyle}>
+ <h4>{dateBText}</h4>
</label>
</div>
);
@@ -65,6 +88,8 @@ OpacitySlider.defaultProps = {
value: 50,
};
OpacitySlider.propTypes = {
+ dateA: PropTypes.string,
+ dateB: PropTypes.string,
onSlide: PropTypes.func,
value: PropTypes.number,
};
diff --git a/web/js/containers/sidebar/events.js b/web/js/containers/sidebar/events.js
index 9fd5bf317..60b347a93 100644
--- a/web/js/containers/sidebar/events.js
+++ b/web/js/containers/sidebar/events.js
@@ -48,7 +48,10 @@ function Events(props) {
const dropdownHeight = 34;
const maxHeight = Math.max(height - dropdownHeight, 166);
const scrollbarMaxHeight = isEmbedModeActive ? '50vh' : `${maxHeight}px`;
- let showInactiveEventAlert = selected.id && !selected.date;
+
+ const missingEventDate = selected.id && !selected.date;
+ const selectedEventNotInData = !isLoading && (eventsData || []).filter((event) => event.id === selected.id).length === 0;
+ let showInactiveEventAlert = missingEventDate || selectedEventNotInData;
const errorOrLoadingText = isLoading
? 'Loading...'
diff --git a/web/js/map/compare/compare.js b/web/js/map/compare/compare.js
index 1832f5e20..e85894d5a 100644
--- a/web/js/map/compare/compare.js
+++ b/web/js/map/compare/compare.js
@@ -46,7 +46,8 @@ export default function mapCompare(store) {
});
};
- self.update = (state, group) => {
+ self.update = function (group) {
+ const state = store.getState();
if (comparison) {
comparison.update(state, group);
}
diff --git a/web/js/map/compare/opacity.js b/web/js/map/compare/opacity.js
index 1745959b8..20414e888 100644
--- a/web/js/map/compare/opacity.js
+++ b/web/js/map/compare/opacity.js
@@ -2,6 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import OpacitySlider from '../../components/compare/opacity-slider';
import util from '../../util/util';
+import { getFormattedDates } from './util';
const { events } = util;
@@ -9,14 +10,17 @@ let slider;
let value = 50;
export default class Opacity {
- constructor(olMap, isAactive, eventListenerStringObj, valueOverride) {
+ constructor(olMap, state, eventListenerStringObj, valueOverride) {
this.map = olMap;
this.sliderCase = document.createElement('div');
value = Number(valueOverride) || value;
- this.create();
+ this.create(state);
}
- create() {
+ create(state) {
+ const { dateA, dateB } = getFormattedDates(state);
+ this.dateA = dateA;
+ this.dateB = dateB;
slider = this.createSlider(this.map.getLayers().getArray());
this.oninput(value);
}
@@ -24,9 +28,15 @@ export default class Opacity {
/**
* Refresh secondLayer layer group (after date change for example)
*/
- update() {
- [this.firstLayer, this.secondLayer] = this.map.getLayers().getArray();
- this.oninput(value);
+ update(state) {
+ const { dateA, dateB } = getFormattedDates(state);
+ if (dateA !== this.dateA || dateB !== this.dateB) {
+ this.destroy();
+ this.create(state);
+ } else {
+ [this.firstLayer, this.secondLayer] = this.map.getLayers().getArray();
+ this.oninput(value);
+ }
}
/**
@@ -48,6 +58,8 @@ export default class Opacity {
const Props = {
onSlide: this.oninput.bind(this),
value,
+ dateA: this.dateA,
+ dateB: this.dateB,
};
this.mapCase.appendChild(this.sliderCase);
ReactDOM.render(React.createElement(OpacitySlider, Props), this.sliderCase);
diff --git a/web/js/map/compare/spy.js b/web/js/map/compare/spy.js
index 6c41e08f2..0533e9786 100644
--- a/web/js/map/compare/spy.js
+++ b/web/js/map/compare/spy.js
@@ -1,5 +1,6 @@
import { each as lodashEach } from 'lodash';
import { getRenderPixel } from 'ol/render';
+import { getFormattedDates } from './util';
let mousePosition = null;
let spy = null;
@@ -8,35 +9,43 @@ const bottomLayers = [];
const DEFAULT_RADIUS = 140;
let radius = DEFAULT_RADIUS;
let label = null;
-// state.compare.isCompareA
-const isCompareA = (state) => state.compare.isCompareA;
export default class Spy {
constructor(olMap, state) {
this.mapCase = document.getElementById('wv-map');
this.map = olMap;
- const isBInside = isCompareA(state);
- this.create(isBInside);
+ const isBInside = state.compare.isCompareA;
+ this.isBInside = isBInside;
+ this.create(state);
}
/**
* Init spy
* @param {Boolean} isBInside | B is the spy value -- true|false
*/
- create(isBInside) {
- spy = this.addSpy(this.map, isBInside);
+ create(state) {
+ const isBInside = isCompareA(state);
+ spy = this.addSpy(this.map, state);
this.isBInside = isBInside;
- this.update(isBInside);
+ this.update(state);
}
/**
* Update spy
* @param {Boolean} isBInside | B is the spy value -- true|false
*/
- update(isBInside) {
+ update(state) {
+ const isBInside = isCompareA(state);
+ const { dateA, dateB } = getFormattedDates(state);
+ if (dateA !== this.dateA || dateB !== this.dateB || dateA === dateB) {
+ const insideText = getDateText(state);
+ label.innerText = insideText;
+ }
+ this.dateA = dateA;
+ this.dateB = dateB;
if (this.isBInside !== isBInside) {
this.destroy();
- this.create(isBInside);
+ this.create(state);
} else {
const mapLayers = this.map.getLayers().getArray();
applyEventsToBaseLayers(
@@ -98,8 +107,8 @@ export default class Spy {
* @param {Object} map | OL Map Object
* @param {Boolean} isBInside | B is the spy value -- true|false
*/
- addSpy(map, isBInside) {
- const insideText = !isBInside ? 'A' : 'B';
+ addSpy(map, state) {
+ const insideText = getDateText(state);
label = document.createElement('span');
label.className = 'ab-spy-span inside-label';
label.style.display = 'none';
@@ -115,7 +124,7 @@ export default class Spy {
}
}
/**
- * Layers need to be inversly clipped so that they can't be seen through
+ * Layers need to be inversely clipped so that they can't be seen through
* the other layergroup in cases where the layergroups layer opacity is < 100%
* @param {Object} layer | Ol Layer object
*/
@@ -213,3 +222,17 @@ const applyEventsToBaseLayers = function(layer, map, callback) {
callback(layer);
}
};
+
+const getDateText = function(state) {
+ const isBInside = isCompareA(state);
+ let insideText = isBInside ? 'B' : 'A';
+ const { dateA, dateB } = getFormattedDates(state);
+ const isSameDate = dateA === dateB;
+ if (!isSameDate) {
+ const dateText = isBInside ? dateB : dateA;
+ insideText += `: ${dateText}`;
+ }
+ return insideText;
+};
+
+const isCompareA = (state) => state.compare.isCompareA;
diff --git a/web/js/map/compare/swipe.js b/web/js/map/compare/swipe.js
index d9c8f7b3b..007c8f592 100644
--- a/web/js/map/compare/swipe.js
+++ b/web/js/map/compare/swipe.js
@@ -4,6 +4,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import lodashEach from 'lodash/each';
import lodashRound from 'lodash/round';
import util from '../../util/util';
+import { getFormattedDates } from './util';
const { events } = util;
@@ -37,10 +38,9 @@ export default class Swipe {
}
create(state) {
- const { date } = state;
- const { selected, selectedB } = date;
- this.dateA = util.toISOStringDateMonthAbbrev(selected);
- this.dateB = util.toISOStringDateMonthAbbrev(selectedB);
+ const { dateA, dateB } = getFormattedDates(state);
+ this.dateA = dateA;
+ this.dateB = dateB;
line = addLineOverlay(this.map, this.dateA, this.dateB);
this.update(state);
}
@@ -64,10 +64,7 @@ export default class Swipe {
}
update(state, groupName) {
- const { date } = state;
- const { selected, selectedB } = date;
- const dateA = util.toISOStringDateMonthAbbrev(selected);
- const dateB = util.toISOStringDateMonthAbbrev(selectedB);
+ const { dateA, dateB } = getFormattedDates(state);
if (dateA !== this.dateA || dateB !== this.dateB) {
this.destroy();
this.create(state);
diff --git a/web/js/map/compare/util.js b/web/js/map/compare/util.js
new file mode 100644
index 000000000..2e8b27671
--- /dev/null
+++ b/web/js/map/compare/util.js
@@ -0,0 +1,9 @@
+import util from '../../util/util';
+// eslint-disable-next-line import/prefer-default-export
+export const getFormattedDates = (state) => {
+ const { date } = state;
+ const { selected, selectedB } = date;
+ const dateA = util.toISOStringDateMonthAbbrev(selected);
+ const dateB = util.toISOStringDateMonthAbbrev(selectedB);
+ return { dateA, dateB };
+};
diff --git a/web/js/map/ui.js b/web/js/map/ui.js
index 9a71689c1..d9c0a1ca0 100644
--- a/web/js/map/ui.js
+++ b/web/js/map/ui.js
@@ -796,7 +796,7 @@ export default function mapui(models, config, store, ui) {
previousLayer: layerValue ? layerValue.wv : null,
}),
);
- compareMapUi.update(state);
+ compareMapUi.update(compare.activeString);
}
} else {
const index = findLayerIndex(def);
diff --git a/web/js/modules/embed/util.js b/web/js/modules/embed/util.js
index e7befe12b..cf3d5cdca 100644
--- a/web/js/modules/embed/util.js
+++ b/web/js/modules/embed/util.js
@@ -33,10 +33,17 @@ export function mapLocationToEmbedState(
layersClone.activeB.layers = activeBFiltered;
layersClone.activeB.overlayGroups = activeBOverlayGroups;
- stateFromLocation = lodashAssign({}, stateFromLocation, {
+ const updatedState = {
embed: { isEmbedModeActive: true },
layers: layersClone,
- });
+ };
+
+ // revert to 'layers' tab if 'events' tab with no event selected
+ if (parameters.e === 'true') {
+ updatedState.sidebar = { activeTab: 'layers' };
+ }
+
+ stateFromLocation = lodashAssign({}, stateFromLocation, updatedState);
}
return stateFromLocation;