Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add right click cancel reverse geocode, fix mouse event changes

Ed Plato46ef97267c65
diff --git a/web/css/tooltip.css b/web/css/tooltip.css
index bbdd37835..4fbe1855b 100644
--- a/web/css/tooltip.css
+++ b/web/css/tooltip.css
@@ -152,6 +152,7 @@
}
.close-tooltip,
.minimize-tooltip {
+ padding-left: 6px;
margin-left: 8px;
border-left: 1px solid #777;
&.close-coordinates-tooltip,
diff --git a/web/js/combine-ui.js b/web/js/combine-ui.js
index 08bc6f7f8..0ddaefe91 100644
--- a/web/js/combine-ui.js
+++ b/web/js/combine-ui.js
@@ -69,6 +69,9 @@ function registerMapMouseHandlers(maps, events) {
map.on('singleclick', (event) => {
events.trigger('singleclick', event, map, crs);
});
+ map.on('contextmenu', (event) => {
+ events.trigger('contextmenu', event, map, crs);
+ });
element.addEventListener('click', (event) => {
events.trigger('click', event, map, crs);
});
diff --git a/web/js/components/geosearch/geosearch-input.js b/web/js/components/geosearch/geosearch-input.js
index 97d31529b..6bcf54bbf 100644
--- a/web/js/components/geosearch/geosearch-input.js
+++ b/web/js/components/geosearch/geosearch-input.js
@@ -54,14 +54,14 @@ class SearchBox extends Component {
}
// render search result menu item container
- renderMenu= (children) => (
+ renderMenu = (children) => (
<div className="geosearch-results-menu">
{children}
</div>
)
// render individual menu items with conditional styling
- renderItem=(item, isHighlighted) => {
+ renderItem = (item, isHighlighted) => {
if (isHighlighted) {
this.highlightedItem = item;
}
@@ -218,8 +218,7 @@ class SearchBox extends Component {
onKeyPress={this.handleKeyPress}
>
<Autocomplete
- // eslint-disable-next-line no-return-assign
- ref={(el) => this.geosearchInput = el}
+ ref={(el) => { this.geosearchInput = el; }}
inputProps={{
className: 'form-control geosearch-autocomplete dark-input',
id: 'geosearch-autocomplete',
diff --git a/web/js/components/geosearch/geosearch-modal.js b/web/js/components/geosearch/geosearch-modal.js
index 2b8cfe87b..e8310d5bd 100644
--- a/web/js/components/geosearch/geosearch-modal.js
+++ b/web/js/components/geosearch/geosearch-modal.js
@@ -77,7 +77,7 @@ class SearchComponent extends Component {
}
// handle selecting menu item in search results
- onSelect=(value, item) => {
+ onSelect = (value, item) => {
const {
isCoordinatePairWithinExtent,
selectCoordinatesToFly,
@@ -114,7 +114,7 @@ class SearchComponent extends Component {
}
// handle input value change including text/coordinates typing, pasting, cutting
- onChange=(e, value) => {
+ onChange = (e, value) => {
e.preventDefault();
const {
updateSearchResults, updateValue, updatePendingCoordinates,
@@ -198,13 +198,13 @@ class SearchComponent extends Component {
isTouchDevice,
showReverseGeocodeAlert,
} = this.state;
- const message = `${isTouchDevice ? 'Tap' : 'Click'} on map to identify a location.`;
+ const message = `${isTouchDevice ? 'Tap' : 'Click'} on map to identify a location.${isTouchDevice ? '' : ' Right click to cancel.'}`;
return showReverseGeocodeAlert && (
<Alert
id="geosearch-select-coordinates-alert"
isOpen
- iconClassName="faMapMarkerAlt"
+ icon="map-marker-alt"
title="Geosearch Select Coordinates"
timeout={6000}
message={message}
diff --git a/web/js/components/geosearch/ol-coordinates-marker.js b/web/js/components/geosearch/ol-coordinates-marker.js
index 3dfec62b3..59e46ceb7 100644
--- a/web/js/components/geosearch/ol-coordinates-marker.js
+++ b/web/js/components/geosearch/ol-coordinates-marker.js
@@ -21,23 +21,23 @@ export class CoordinatesMarker extends Component {
showExtentAlert: false,
};
this.mouseMove = lodashDebounce(this.mouseMove.bind(this), 8);
- this.mouseClick = this.mouseClick.bind(this);
- this.singleClick = this.singleClick.bind(this);
+ this.singleclick = this.singleclick.bind(this);
+ this.rightClick = this.rightClick.bind(this);
this.registerMouseListeners();
}
componentWillUnmount() {
const { mouseEvents } = this.props;
mouseEvents.off('mousemove', this.mouseMove);
- mouseEvents.off('click', this.mouseClick);
- mouseEvents.OFF('singleclick', this.singleClick);
+ mouseEvents.off('singleclick', this.singleclick);
+ mouseEvents.off('contextmenu', this.rightClick);
}
registerMouseListeners() {
const { mouseEvents } = this.props;
mouseEvents.on('mousemove', this.mouseMove);
- mouseEvents.on('click', this.mouseClick);
- mouseEvents.on('singleclick', this.singleClick);
+ mouseEvents.on('singleclick', this.singleclick);
+ mouseEvents.on('contextmenu', this.rightClick);
}
mouseMove(event, map, crs) {
@@ -73,18 +73,18 @@ export class CoordinatesMarker extends Component {
this.setState({ latitude: lat, longitude: lon });
}
- singleClick(e, map) {
- e.stopPropagation();
+ rightClick(e) {
const {
- measureIsActive,
+ isCoordinateSearchActive,
+ toggleReverseGeocodeActive,
} = this.props;
- if (measureIsActive) return;
- const pixels = e.pixel;
- this.getCoordinatesDialog(pixels, map);
+ if (!isCoordinateSearchActive) return;
+ e.preventDefault();
+ toggleReverseGeocodeActive(false);
}
- mouseClick(e, map) {
+ singleclick(e, map) {
const {
config,
measureIsActive,
@@ -113,6 +113,11 @@ export class CoordinatesMarker extends Component {
selectCoordinatesToFly([longitude, latitude], results);
});
this.setState({ showExtentAlert: false });
+ } else {
+ // handle clicking on pixel and/or map marker
+ e.stopPropagation();
+ const pixels = e.pixel;
+ this.getCoordinatesDialog(pixels, map);
}
}
diff --git a/web/js/components/map/ol-coordinates.test.js b/web/js/components/map/ol-coordinates.test.js
index c286cd91c..d6ad1d7e9 100644
--- a/web/js/components/map/ol-coordinates.test.js
+++ b/web/js/components/map/ol-coordinates.test.js
@@ -14,12 +14,13 @@ beforeEach(() => {
document.body.appendChild(container);
registerProjections();
events = util.events();
+
map = {
getEventPixel: jest.fn(),
getCoordinateFromPixel: () => [0, 0],
};
act(() => {
- render(<OlCoordinates mouseEvents={events} />, container);
+ render(<OlCoordinates mouseEvents={events} isDistractionFreeModeActive={false} />, container);
});
});
diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.js
index 8a1799567..a6cca4cad 100644
--- a/web/js/containers/toolbar.js
+++ b/web/js/containers/toolbar.js
@@ -161,8 +161,7 @@ class toolbarContainer extends Component {
}
renderShareButton() {
- const { openModal, isDistractionFreeModeActive, isMobile } = this.props;
- const faSize = isMobile ? '2x' : '1x';
+ const { faSize, openModal, isDistractionFreeModeActive } = this.props;
const buttonId = 'wv-link-button';
const labelText = 'Share this map';
return !isDistractionFreeModeActive && (
@@ -183,9 +182,8 @@ class toolbarContainer extends Component {
renderProjectionButton() {
const {
- config, openModal, isDistractionFreeModeActive, isMobile,
+ config, faSize, openModal, isDistractionFreeModeActive,
} = this.props;
- const faSize = isMobile ? '2x' : '1x';
const buttonId = 'wv-proj-button';
const labelText = 'Switch projection';
return config.ui && config.ui.projections && !isDistractionFreeModeActive && (
@@ -208,6 +206,7 @@ class toolbarContainer extends Component {
renderGeosearchButtonComponent = () => {
const {
config,
+ faSize,
isGeosearchExpanded,
isMobile,
openModal,
@@ -215,7 +214,6 @@ class toolbarContainer extends Component {
toggleShowGeosearch,
} = this.props;
const { features: { geocodeSearch: isFeatureEnabled } } = config;
- const faSize = isMobile ? '2x' : '1x';
const buttonId = 'wv-geosearch-button';
const labelText = 'Search places by location';
@@ -251,10 +249,10 @@ class toolbarContainer extends Component {
renderSnapshotsButton () {
const {
+ faSize,
isImageDownloadActive,
isCompareActive,
isDistractionFreeModeActive,
- isMobile,
} = this.props;
const buttonId = 'wv-image-button';
const labelText = isCompareActive
@@ -262,7 +260,6 @@ class toolbarContainer extends Component {
: !isImageDownloadActive
? 'You must exit data download mode to use the snapshot feature'
: 'Take a snapshot';
- const faSize = isMobile ? '2x' : '1x';
return !isDistractionFreeModeActive && (
<div id="snapshot-btn-wrapper">
@@ -287,16 +284,15 @@ class toolbarContainer extends Component {
renderInfoButton() {
const {
+ faSize,
openModal,
notificationType,
notificationContentNumber,
isDistractionFreeModeActive,
- isMobile,
} = this.props;
const notificationClass = notificationType
? ` wv-status-${notificationType}`
: ' wv-status-hide';
- const faSize = isMobile ? '2x' : '1x';
const buttonId = 'wv-info-button';
const labelText = 'Information';
@@ -348,6 +344,7 @@ const mapStateToProps = (state) => {
state,
);
const isMobile = browser.lessThan.medium;
+ const faSize = isMobile ? '2x' : '1x';
const isCompareActive = compare.active;
const isDataDownloadActive = data.active;
const isGeosearchExpanded = geosearch.isExpanded;
@@ -358,6 +355,7 @@ const mapStateToProps = (state) => {
const shouldBeCollapsed = snapshotModalOpen || measure.isActive || animation.gifActive;
return {
+ faSize,
notificationType: type,
notificationContentNumber: number,
config: state.config,
@@ -453,6 +451,7 @@ export default connect(
toolbarContainer.propTypes = {
activePalettes: PropTypes.object,
config: PropTypes.object,
+ faSize: PropTypes.string,
hasCustomPalette: PropTypes.bool,
hasGraticule: PropTypes.bool,
isCompareActive: PropTypes.bool,
diff --git a/web/js/modules/geosearch/reducers.js b/web/js/modules/geosearch/reducers.js
index c184179c2..eda00fbf2 100644
--- a/web/js/modules/geosearch/reducers.js
+++ b/web/js/modules/geosearch/reducers.js
@@ -1,4 +1,3 @@
-import { assign as lodashAssign } from 'lodash';
import {
CLEAR_COORDINATES,
SELECT_COORDINATES_TO_FLY,
@@ -20,31 +19,36 @@ export const geosearchState = {
export function geosearchReducer(state = geosearchState, action) {
switch (action.type) {
case UPDATE_ACTIVE_MARKER:
- return lodashAssign({}, state, {
+ return {
+ ...state,
activeMarker: action.value,
reverseGeocodeResults: action.reverseGeocodeResults,
- });
+ };
case TOGGLE_SHOW_GEOSEARCH:
- return lodashAssign({}, state, {
+ return {
+ ...state,
isExpanded: action.value,
- });
+ };
case SELECT_COORDINATES_TO_FLY:
- return lodashAssign({}, state, {
+ return {
+ ...state,
isCoordinateSearchActive: action.value,
coordinates: action.coordinates,
activeMarker: action.activeMarker,
reverseGeocodeResults: action.reverseGeocodeResults,
- });
+ };
case CLEAR_COORDINATES:
- return lodashAssign({}, state, {
+ return {
+ ...state,
coordinates: [],
activeMarker: null,
reverseGeocodeResults: null,
- });
+ };
case TOGGLE_REVERSE_GEOCODE_ACTIVE:
- return lodashAssign({}, state, {
+ return {
+ ...state,
isCoordinateSearchActive: action.value,
- });
+ };
default:
return state;
}