Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

update branch on rebase

Ed Platoea8669265cc3
diff --git a/web/js/components/location-search/ol-coordinates-marker.js b/web/js/components/location-search/ol-coordinates-marker.js
index e0692f2e3..16d3cbc8e 100644
--- a/web/js/components/location-search/ol-coordinates-marker.js
+++ b/web/js/components/location-search/ol-coordinates-marker.js
@@ -6,7 +6,6 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { transform } from 'ol/proj';
import Alert from '../util/alert';
-import { changeCursor as changeCursorActionCreator } from '../../modules/map/actions';
import {
setPlaceMarker, toggleReverseGeocodeActive,
} from '../../modules/location-search/actions';
@@ -23,61 +22,20 @@ export class CoordinatesMarker extends Component {
this.state = {
showExtentAlert: false,
};
- this.mouseMove = this.mouseMove.bind(this);
this.singleClick = this.singleClick.bind(this);
this.rightClick = this.rightClick.bind(this);
}
componentDidMount() {
- events.on('map:mousemove', this.mouseMove);
events.on('map:singleclick', this.singleClick);
events.on('map:contextmenu', this.rightClick);
}
componentWillUnmount() {
- events.off('map:mousemove', this.mouseMove);
events.off('map:singleclick', this.singleClick);
events.off('map:contextmenu', this.rightClick);
}
- mouseMove(event, map, crs) {
- const {
- changeCursor,
- coordinates,
- isCoordinateSearchActive,
- isShowingClick,
- measureIsActive,
- } = this.props;
-
- if (measureIsActive
- || (!isCoordinateSearchActive && coordinates.length === 0)) {
- return;
- }
-
- const pixels = map.getEventPixel(event);
- const coord = map.getCoordinateFromPixel(pixels);
- if (!coord) {
- return;
- }
- const [lon, lat] = transform(coord, crs, 'EPSG:4326');
- if (lon < -250 || lon > 250 || lat < -90 || lat > 90) {
- return;
- }
- const hasFeatures = map.hasFeatureAtPixel(pixels);
- if (hasFeatures && !isShowingClick) {
- const featureCheck = (feature) => {
- if (feature.getId() === 'coordinates-map-marker') {
- changeCursor(true);
- }
- return true;
- };
- map.forEachFeatureAtPixel(pixels, featureCheck);
- }
- if (!hasFeatures && isShowingClick) {
- changeCursor(false);
- }
- }
-
rightClick(e) {
const {
isCoordinateSearchActive,
@@ -99,30 +57,28 @@ export class CoordinatesMarker extends Component {
toggleReverseGeocodeActive,
} = this.props;
- if (measureIsActive) return;
- const pixels = e.pixel;
+ if (measureIsActive || !isCoordinateSearchActive) return;
// handle reverse geocoding mouse click
- if (isCoordinateSearchActive) {
- const coord = map.getCoordinateFromPixel(pixels);
- const [lon, lat] = transform(coord, crs, 'EPSG:4326');
- const latitude = getCoordinateFixedPrecision(lat);
- const longitude = getCoordinateFixedPrecision(lon);
-
- // show alert warning and exit mode if outside current map extent
- const validNums = !lodashIsNaN(parseFloat(latitude)) && !lodashIsNaN(parseFloat(longitude));
- const withinExtent = areCoordinatesWithinExtent(proj, [longitude, latitude]);
- if (!validNums || !withinExtent) {
- this.setState({ showExtentAlert: true });
- toggleReverseGeocodeActive(false);
- return;
- }
- // get available reverse geocoding for coordinates and fly to point
- reverseGeocode([longitude, latitude], config).then((results) => {
- setPlaceMarker([longitude, latitude], results);
- });
- this.setState({ showExtentAlert: false });
+ const pixels = e.pixel;
+ const coord = map.getCoordinateFromPixel(pixels);
+ const [lon, lat] = transform(coord, crs, 'EPSG:4326');
+ const latitude = getCoordinateFixedPrecision(lat);
+ const longitude = getCoordinateFixedPrecision(lon);
+
+ // show alert warning and exit mode if outside current map extent
+ const validNums = !lodashIsNaN(parseFloat(latitude)) && !lodashIsNaN(parseFloat(longitude));
+ const withinExtent = areCoordinatesWithinExtent(proj, [longitude, latitude]);
+ if (!validNums || !withinExtent) {
+ this.setState({ showExtentAlert: true });
+ toggleReverseGeocodeActive(false);
+ return;
}
+ // get available reverse geocoding for coordinates and fly to point
+ reverseGeocode([longitude, latitude], config).then((results) => {
+ setPlaceMarker([longitude, latitude], results);
+ });
+ this.setState({ showExtentAlert: false });
}
// render Location Search extent alert for selecting points outside of the current map extent
@@ -171,9 +127,6 @@ function mapStateToProps(state) {
}
const mapDispatchToProps = (dispatch) => ({
- changeCursor: (bool) => {
- dispatch(changeCursorActionCreator(bool));
- },
setPlaceMarker: (coordinates, reverseGeocodeResults) => {
dispatch(setPlaceMarker(coordinates, reverseGeocodeResults));
},
@@ -182,11 +135,8 @@ const mapDispatchToProps = (dispatch) => ({
},
});
CoordinatesMarker.propTypes = {
- changeCursor: PropTypes.func.isRequired,
config: PropTypes.object.isRequired,
- coordinates: PropTypes.array,
isCoordinateSearchActive: PropTypes.bool.isRequired,
- isShowingClick: PropTypes.bool.isRequired,
measureIsActive: PropTypes.bool.isRequired,
proj: PropTypes.object,
setPlaceMarker: PropTypes.func.isRequired,
diff --git a/web/js/containers/map-interactions/ol-vector-interactions.js b/web/js/containers/map-interactions/ol-vector-interactions.js
index cf001b24a..9e386c7a9 100644
--- a/web/js/containers/map-interactions/ol-vector-interactions.js
+++ b/web/js/containers/map-interactions/ol-vector-interactions.js
@@ -16,7 +16,7 @@ import { onMapClickGetVectorFeatures } from '../../modules/vector-styles/util';
import { openCustomContent, onClose } from '../../modules/modal/actions';
import { selectVectorFeatures as selectVectorFeaturesActionCreator } from '../../modules/vector-styles/actions';
import { changeCursor as changeCursorActionCreator } from '../../modules/map/actions';
-import { ACTIVATE_VECTOR_ZOOM_ALERT, ACTIVATE_VECTOR_EXCEEDED_ALERT } from '../../modules/alerts/constants';
+import { ACTIVATE_VECTOR_ZOOM_ALERT, ACTIVATE_VECTOR_EXCEEDED_ALERT, DISABLE_VECTOR_EXCEEDED_ALERT } from '../../modules/alerts/constants';
import util from '../../util/util';
const { events } = util;
@@ -57,9 +57,6 @@ export class VectorInteractions extends React.Component {
if (hasFeatures && !isShowingClick && !measureIsActive) {
let isActiveLayer = false;
map.forEachFeatureAtPixel(pixels, (feature, layer) => {
- if (isActiveLayer) {
- return true;
- }
const def = lodashGet(layer, 'wv.def');
if (!def || lodashIncludes(def.clickDisabledFeatures, feature.getType())) return;
const isWrapped = proj.id === 'geographic' && (def.wrapadjacentdays || def.wrapX);
@@ -68,7 +65,10 @@ export class VectorInteractions extends React.Component {
isActiveLayer = true;
}
});
- if (isActiveLayer) changeCursor(true);
+ if (isActiveLayer) {
+ changeCursor(true);
+ return true;
+ }
} else if (!hasFeatures && isShowingClick) {
changeCursor(false);
}
@@ -78,7 +78,8 @@ export class VectorInteractions extends React.Component {
const {
browser, lastSelected, openVectorDialog, onCloseModal, selectVectorFeatures,
modalState, getDialogObject, measureIsActive, activeLayers, isCoordinateSearchActive,
- activateVectorZoomAlert, activateVectorExceededResultsAlert, proj, isEmbedModeActive, isMobile,
+ activateVectorZoomAlert, activateVectorExceededResultsAlert, clearVectorExceededResultsAlert,
+ proj, isEmbedModeActive, isMobile,
} = this.props;
if (measureIsActive || isCoordinateSearchActive) return;
@@ -89,13 +90,9 @@ export class VectorInteractions extends React.Component {
const selected = clickObj.selected || {};
const offsetLeft = clickObj.offsetLeft || 10;
const offsetTop = clickObj.offsetTop || 100;
- const isCoordinatesMarker = clickObj.isCoordinatesMarker || false;
const exceededLengthLimit = clickObj.exceededLengthLimit || false;
const dialogId = isVectorModalOpen ? modalState.id : `vector_dialog${pixels[0]}${pixels[1]}`;
- if (isCoordinatesMarker) {
- return;
- }
const mapRes = map.getView().getResolution();
const hasNonClickableVectorLayerType = hasNonClickableVectorLayer(activeLayers, mapRes, proj.id, isMobile);
@@ -106,6 +103,8 @@ export class VectorInteractions extends React.Component {
openVectorDialog(dialogId, metaArray, offsetLeft, offsetTop, browser, isEmbedModeActive);
if (exceededLengthLimit) {
activateVectorExceededResultsAlert();
+ } else {
+ clearVectorExceededResultsAlert();
}
}
} else if (hasNonClickableVectorLayerType) {
@@ -172,6 +171,7 @@ const mapDispatchToProps = (dispatch) => ({
},
activateVectorZoomAlert: () => dispatch({ type: ACTIVATE_VECTOR_ZOOM_ALERT }),
activateVectorExceededResultsAlert: () => dispatch({ type: ACTIVATE_VECTOR_EXCEEDED_ALERT }),
+ clearVectorExceededResultsAlert: () => dispatch({ type: DISABLE_VECTOR_EXCEEDED_ALERT }),
openVectorDialog: (dialogId, metaArray, offsetLeft, offsetTop, browser, isEmbedModeActive) => {
const { screenHeight, screenWidth } = browser;
const isMobile = browser.lessThan.medium;
@@ -218,6 +218,7 @@ VectorInteractions.propTypes = {
selectVectorFeatures: PropTypes.func.isRequired,
activateVectorZoomAlert: PropTypes.func,
activateVectorExceededResultsAlert: PropTypes.func,
+ clearVectorExceededResultsAlert: PropTypes.func,
activeLayers: PropTypes.array,
browser: PropTypes.object,
compareState: PropTypes.object,
diff --git a/web/js/map/runningdata.js b/web/js/map/runningdata.js
index 82b5ef4ed..1f60b1ded 100644
--- a/web/js/map/runningdata.js
+++ b/web/js/map/runningdata.js
@@ -38,11 +38,7 @@ export default function MapRunningData(compareUi, store) {
*/
self.newPoint = function(pixels, map) {
const state = store.getState();
- const { locationSearch, proj } = state;
- const { isCoordinateSearchActive } = locationSearch;
- if (isCoordinateSearchActive) {
- return;
- }
+ const { proj } = state;
const activeLayerObj = {};
const [lon, lat] = map.getCoordinateFromPixel(pixels);
diff --git a/web/js/map/ui.js b/web/js/map/ui.js
index 3ba5e2435..aadfe95f1 100644
--- a/web/js/map/ui.js
+++ b/web/js/map/ui.js
@@ -1090,14 +1090,11 @@ export default function mapui(models, config, store, ui) {
*
* @param {object} map - OpenLayers Map Object
*
- * @param {object} proj - Projection properties
- *
- *
* @returns {void}
*
* @todo move this component to another Location
*/
- function createMousePosSel(map, proj) {
+ function createMousePosSel(map) {
const throttledOnMouseMove = lodashThrottle((e) => {
const state = store.getState();
const { browser, locationSearch, sidebar } = state;
diff --git a/web/js/modules/vector-styles/util.js b/web/js/modules/vector-styles/util.js
index 38926c8e7..057c46808 100644
--- a/web/js/modules/vector-styles/util.js
+++ b/web/js/modules/vector-styles/util.js
@@ -210,14 +210,14 @@ function getModalOffset(dimensionProps) {
/**
* Get Organized data for each feature at pixel
* @param {Object} mapProps
- * @param Object*} config
+ * @param {Object} config
* @param {Object} compareState
+ * @param {Boolean} isMobile
*/
function getModalContentsAtPixel(mapProps, config, compareState, isMobile) {
const metaArray = [];
const selected = {};
let exceededLengthLimit = false;
- let isCoordinatesMarker = false;
const { pixels, map, swipeOffset } = mapProps;
const featureOptions = isMobile ? { hitTolerance: 5 } : {};
map.forEachFeatureAtPixel(pixels, (feature, layer) => {
@@ -226,12 +226,6 @@ function getModalContentsAtPixel(mapProps, config, compareState, isMobile) {
exceededLengthLimit = true;
return true;
}
- const featureId = feature.getId();
- if (featureId === 'coordinates-map-marker') {
- isCoordinatesMarker = true;
- return;
- }
-
const def = lodashGet(layer, 'wv.def');
if (!def) {
return;
@@ -271,7 +265,7 @@ function getModalContentsAtPixel(mapProps, config, compareState, isMobile) {
}
}, featureOptions);
return {
- selected, metaArray, isCoordinatesMarker, exceededLengthLimit,
+ selected, metaArray, exceededLengthLimit,
};
}
/**
@@ -297,14 +291,13 @@ export function onMapClickGetVectorFeatures(pixels, map, state, swipeOffset) {
const mapProps = { pixels, map, swipeOffset };
const { offsetLeft, offsetTop } = getModalOffset(modalOffsetProps);
const {
- selected, metaArray, isCoordinatesMarker, exceededLengthLimit,
+ selected, metaArray, exceededLengthLimit,
} = getModalContentsAtPixel(mapProps, config, compare, isMobile);
return {
selected, // Object containing unique identifiers of selected features
metaArray, // Organized metadata for modal
offsetLeft, // Modal default offsetLeft
offsetTop, // Modal default offsetTop
- isCoordinatesMarker,
exceededLengthLimit,
};
}