Interactive interface for browsing global, full-resolution satellite imagery
prevent measure-tool error #2420
Benjamin King4fa119145ff6
diff --git a/web/js/containers/map-interactions.js b/web/js/containers/map-interactions.jsindex cd3f30a03..7166b7540 100644--- a/web/js/containers/map-interactions.js+++ b/web/js/containers/map-interactions.js@@ -23,7 +23,8 @@ export class MapInteractions extends React.Component {}singleClick(e, map) {- const { lastSelected, openVectorDiaglog, onCloseModal, selectVectorFeatures, modalState, getDialogObject } = this.props;+ const { lastSelected, openVectorDiaglog, onCloseModal, selectVectorFeatures, modalState, getDialogObject, measureIsActive } = this.props;+ if (measureIsActive) return;const isVectorModalOpen = modalState.id.includes('vector_dialog') && modalState.isOpen;const pixels = e.pixel;const clickObj = getDialogObject(pixels, map);@@ -47,13 +48,13 @@ export class MapInteractions extends React.Component {mouseMove(event, map, crs) {const pixels = map.getEventPixel(event);const coord = map.getCoordinateFromPixel(pixels);- const { isShowingClick, changeCursor } = this.props;+ const { isShowingClick, changeCursor, measureIsActive } = this.props;if (!coord) {this.clearCoord();return;}const hasFeatures = map.hasFeatureAtPixel(pixels);- if (hasFeatures && !isShowingClick) {+ if (hasFeatures && !isShowingClick && !measureIsActive) {changeCursor(true);} else if (!hasFeatures && isShowingClick) {changeCursor(false);@@ -107,17 +108,20 @@ const mapDispatchToProps = dispatch => ({}});function mapStateToProps(state) {+ const { modal, map, measure, vectorStyles } = state;return {- modalState: state.modal,- isShowingClick: state.map.isClickable,+ modalState: modal,+ isShowingClick: map.isClickable,getDialogObject: (pixels, map) => { return onMapClickGetVectorFeatures(pixels, map, state); },- lastSelected: state.vectorStyles.selected+ lastSelected: vectorStyles.selected,+ measureIsActive: measure.isActive};}MapInteractions.propTypes = {changeCursor: PropTypes.func.isRequired,getDialogObject: PropTypes.func.isRequired,isShowingClick: PropTypes.bool.isRequired,+ measureIsActive: PropTypes.bool.isRequired,modalState: PropTypes.object.isRequired,mouseEvents: PropTypes.object.isRequired,onCloseModal: PropTypes.func.isRequired,diff --git a/web/js/map/runningdata.js b/web/js/map/runningdata.jsindex b353794b0..49d78b8cf 100644--- a/web/js/map/runningdata.js+++ b/web/js/map/runningdata.js@@ -18,7 +18,7 @@ export function MapRunningData(models, compareUi, store) {/*** Clear running data value*/- self.clearAll = function() {+ self.clearAll = function () {if (!lodashIsEmpty(dataObj)) {dataObj = {};store.dispatch(clearRunningDataAction());@@ -31,7 +31,7 @@ export function MapRunningData(models, compareUi, store) {* @param {Array} coords | Coordinates of hover point* @param {Object} layerAttributes | Layer Properties*/- var isFromActiveCompareRegion = function(map, coords, layerAttributes) {+ var isFromActiveCompareRegion = function (map, coords, layerAttributes) {var compareModel = store.getState().compare;if (compareModel && compareModel.active) {if (compareModel.mode !== 'swipe') {@@ -65,7 +65,7 @@ export function MapRunningData(models, compareUi, store) {* @return {Void}**/- self.newPoint = function(coords, map) {+ self.newPoint = function (coords, map) {const state = store.getState();var activeLayerObj = {};map.forEachFeatureAtPixel(coords, (feature, layer) => {@@ -82,7 +82,7 @@ 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(function (c) { return c.toLowerCase().replace(/\s/g, ''); });const colorIndex = tooltips.indexOf(value.toLowerCase().replace(/\s/g, ''));color = legend.colors[colorIndex];} else if (legend.colors.length === 1) {@@ -90,7 +90,7 @@ export function MapRunningData(models, compareUi, store) {}activeLayerObj[layerId] = { paletteLegends: paletteLegends, paletteHex: color };});- map.forEachLayerAtPixel(coords, function(layer, data) {+ map.forEachLayerAtPixel(coords, function (layer, data) {if (!layer.wv) return;var paletteHex;var paletteLegends;diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex f052ae8e2..3ddced38d 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -96,7 +96,7 @@ export function mapui(models, config, store, ui) {* Suscribe to redux store and listen for* specific action types*/- const subscribeToStore = function(action) {+ const subscribeToStore = function (action) {switch (action.type) {case layerConstants.ADD_LAYER: {const def = lodashFind(action.layers, { id: action.id });@@ -168,10 +168,10 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var init = function() {+ var init = function () {// NOTE: iOS sometimes bombs if this is _.each instead. In that case,// it is possible that config.projections somehow becomes array-like.- lodashForOwn(config.projections, function(proj) {+ lodashForOwn(config.projections, function (proj) {var map = createMap(proj);self.proj[proj.id] = map;});@@ -189,7 +189,7 @@ export function mapui(models, config, store, ui) {updateProjection(true);};- const flyToNewExtent = function(extent, rotation) {+ const flyToNewExtent = function (extent, rotation) {const coordinateX = extent[0] + (extent[2] - extent[0]) / 2;const coordinateY = extent[1] + (extent[3] - extent[1]) / 2;const coordinates = [coordinateX, coordinateY];@@ -210,7 +210,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var updateProjection = function(start) {+ var updateProjection = function (start) {const state = store.getState();const { proj } = state;if (self.selected) {@@ -273,7 +273,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var onResize = function() {+ var onResize = function () {var map = self.selected;if (map.small !== util.browser.small) {if (util.browser.small) {@@ -297,7 +297,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var hideMap = function(map) {+ var hideMap = function (map) {$('#' + map.getTarget()).hide();};/*@@ -310,7 +310,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var showMap = function(map) {+ var showMap = function (map) {$('#' + map.getTarget()).show();};/*@@ -323,12 +323,12 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var clearLayers = function(map) {+ var clearLayers = function (map) {var activeLayers = map.getLayers().getArray().slice(0);- lodashEach(activeLayers, function(mapLayer) {+ lodashEach(activeLayers, function (mapLayer) {map.removeLayer(mapLayer);});removeGraticule('active');@@ -346,7 +346,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var reloadLayers = self.reloadLayers = function(map) {+ var reloadLayers = self.reloadLayers = function (map) {map = map || self.selected;const state = store.getState();const { layers, proj } = state;@@ -365,7 +365,7 @@ export function mapui(models, config, store, ui) {},state);- lodashEach(defs, function(def) {+ lodashEach(defs, function (def) {if (isGraticule(def, proj.id)) {addGraticule(def.opacity, layerGroupStr);} else {@@ -393,7 +393,7 @@ export function mapui(models, config, store, ui) {* Create a Layergroup given the date and layerGroups* @param {Array} arr | Array of date/layer group strings*/- var getCompareLayerGroup = function(arr, layersState, projId, state) {+ var getCompareLayerGroup = function (arr, layersState, projId, state) {return new OlLayerGroup({layers: getLayers(layersState[arr[0]],@@ -426,15 +426,15 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var updateLayerVisibilities = function() {+ var updateLayerVisibilities = function () {const state = store.getState();var renderable;var layers = self.selected.getLayers();var layersState = state.layers;var activeGroupStr = state.compare.activeString;var activeDateStr = state.compare.isCompareA ? 'selected' : 'selectedB';- var updateGraticules = function(defs, groupName) {- lodashEach(defs, function(def) {+ var updateGraticules = function (defs, groupName) {+ lodashEach(defs, function (def) {if (isGraticule(def, state.proj.id)) {renderable = isRenderableLayer(def.id,@@ -450,7 +450,7 @@ export function mapui(models, config, store, ui) {}});};- layers.forEach(function(layer) {+ layers.forEach(function (layer) {var group = layer.get('group');// Not in A|Bif (layer.wv) {@@ -494,7 +494,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var updateOpacity = function(action) {+ var updateOpacity = function (action) {const state = store.getState();const { layers, compare, proj } = state;const activeStr = compare.isCompareA ? 'active' : 'activeB';@@ -523,7 +523,7 @@ export function mapui(models, config, store, ui) {* @returns {void}*/- var addLayer = function(def, date, activeLayers) {+ var addLayer = function (def, date, activeLayers) {const state = store.getState();const { compare, layers, proj } = state;const activeDateStr = compare.isCompareA ? 'selected' : 'selectedB';@@ -571,7 +571,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var removeLayer = function(action) {+ var removeLayer = function (action) {const state = store.getState();const { compare, proj } = state;const activeLayerStr = compare.isCompareA ? 'active' : 'activeB';@@ -600,7 +600,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var updateDate = self.updateDate = function() {+ var updateDate = self.updateDate = function () {const state = store.getState();const { compare } = state;const layerState = state.layers;@@ -624,7 +624,7 @@ export function mapui(models, config, store, ui) {: null;}}- lodashEach(activeLayers, function(def) {+ lodashEach(activeLayers, function (def) {const layerName = def.layer || def.id;if (!['subdaily', 'daily', 'monthly', 'yearly'].includes(def.period)) {@@ -677,7 +677,7 @@ export function mapui(models, config, store, ui) {** @todo Check if this function can be combined with updateLayerOrder*/- var updateLookup = function(layerId) {+ var updateLookup = function (layerId) {reloadLayers();};@@ -692,7 +692,7 @@ export function mapui(models, config, store, ui) {** @returns {object} Layer object*/- var findLayer = function(def, layerGroupStr) {+ var findLayer = function (def, layerGroupStr) {var layers = self.selected.getLayers().getArray();var layer = lodashFind(layers, {wv: {@@ -728,7 +728,7 @@ export function mapui(models, config, store, ui) {** @returns {number} Index of layer in OpenLayers layer array*/- var findLayerIndex = function(def, layerGroup) {+ var findLayerIndex = function (def, layerGroup) {layerGroup = layerGroup || self.selected;var layers = layerGroup.getLayers().getArray();@@ -753,7 +753,7 @@ export function mapui(models, config, store, ui) {** @returns {boolean}*/- var isGraticule = function(def, proj) {+ var isGraticule = function (def, proj) {return (def.projections[proj].type === 'graticule' || def.type === 'graticule');@@ -770,7 +770,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var addGraticule = function(opacity, groupStr) {+ var addGraticule = function (opacity, groupStr) {groupStr = groupStr || 'active';opacity = opacity || 0.5;var graticule = self.selected['graticule-' + groupStr];@@ -802,7 +802,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var removeGraticule = function(groupStr) {+ var removeGraticule = function (groupStr) {groupStr = groupStr || 'active';var graticule = self.selected['graticule-' + groupStr];if (graticule) {@@ -812,7 +812,7 @@ export function mapui(models, config, store, ui) {};var triggerExtent = lodashThrottle(- function() {+ function () {self.events.trigger('extent');},500,@@ -830,7 +830,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var updateExtent = function() {+ var updateExtent = function () {const map = self.selected;const view = map.getView();const extent = view.calculateExtent(map.getSize());@@ -877,7 +877,7 @@ export function mapui(models, config, store, ui) {** @returns {object} OpenLayers Map Object*/- var createMap = function(proj, dateSelected) {+ var createMap = function (proj, dateSelected) {const state = store.getState();const { date, compare } = state;const activeDate = compare.isCompareA ? 'selected' : 'selectedB';@@ -977,11 +977,11 @@ export function mapui(models, config, store, ui) {map.getView().on('change:center', lodashDebounce(updateExtent, 300));map.getView().on('change:resolution', lodashDebounce(updateExtent, 300));map.getView().on('change:rotation', lodashThrottle(onRotate, 300));- map.on('pointerdrag', function() {+ map.on('pointerdrag', function () {self.mapIsbeingDragged = true;self.events.trigger('drag');});- map.getView().on('propertychange', function(e) {+ map.getView().on('propertychange', function (e) {switch (e.key) {case 'resolution':self.mapIsbeingZoomed = true;@@ -989,9 +989,9 @@ export function mapui(models, config, store, ui) {break;}});- map.on('moveend', function(e) {+ map.on('moveend', function (e) {self.events.trigger('moveend');- setTimeout(function() {+ setTimeout(function () {self.mapIsbeingDragged = false;self.mapIsbeingZoomed = false;}, 200);@@ -1021,7 +1021,7 @@ export function mapui(models, config, store, ui) {** @returns {void}*/- var createZoomButtons = function(map, proj) {+ var createZoomButtons = function (map, proj) {var $map = $('#' + map.getTarget());var $zoomOut = $('<div></div>')@@ -1068,7 +1068,7 @@ export function mapui(models, config, store, ui) {* @returns {void}**/- var onZoomChange = function() {+ var onZoomChange = function () {var maxZoom = proj.resolutions.length;var zoom = map.getView().getZoom();if (zoom === 0) {@@ -1083,13 +1083,13 @@ export function mapui(models, config, store, ui) {}};- map.getView().on('change:resolution', function() {+ map.getView().on('change:resolution', function () {onZoomChange();self.events.trigger('movestart');});onZoomChange();};- var onRotate = function(val) {+ var onRotate = function (val) {rotation.updateRotation(val);updateExtent();};@@ -1109,7 +1109,7 @@ export function mapui(models, config, store, ui) {** @todo move this component to another Location*/- var createMousePosSel = function(map, proj) {+ var createMousePosSel = function (map, proj) {var hoverThrottle;function onMouseMove(e) {@@ -1118,9 +1118,9 @@ export function mapui(models, config, store, ui) {const state = store.getState();if (compareMapUi && compareMapUi.dragging) return;// if mobile return- if (util.browser.small) {- return;- }+ if (util.browser.small) return;+ // if measure is active return+ if (state.measure.isActive) return;// if over coords returnif ($(e.relatedTarget).hasClass('map-coord') ||@@ -1155,7 +1155,7 @@ export function mapui(models, config, store, ui) {if (!self.mapIsbeingDragged && !self.mapIsbeingZoomed) dataRunner.newPoint(pixels, map);}$(map.getViewport())- .mouseout(function(e) {+ .mouseout(function (e) {if ($(e.relatedTarget).hasClass('map-coord') ||$(e.relatedTarget).hasClass('coord-btn')