Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

add crosshairs cursor when reverse geocoding click event

Ed Platoce259ecabb1f
diff --git a/web/css/geosearch.css b/web/css/geosearch.css
index 3df905d77..828500635 100644
--- a/web/css/geosearch.css
+++ b/web/css/geosearch.css
@@ -87,6 +87,7 @@
/* Geosearch Component Minimize Button */
.geosearch-search-minimize-button {
background: rgba(40, 40, 40, 0.15);
+ width: 21px;
margin-right: 2px;
border: none;
overflow: hidden;
@@ -108,15 +109,16 @@
.geosearch-search-minimize-button-chevron {
position: absolute;
- background: url('../images/icon-sprite.svg') -206px -3px no-repeat;
+ background: url('../images/icon-sprite.svg') -201px -5px no-repeat;
-webkit-box-sizing: border-box;
box-sizing: border-box;
- width: 57px;
- left: -18px;
- height: 30px;
+ width: 42px;
+ top: 9px;
+ left: -9px;
+ height: 24px;
transform: rotate(90deg);
&:hover {
- background-position: -206px -63px;
+ background-position: -201px -65px;
}
}
diff --git a/web/images/map-pin.png b/web/images/map-pin.png
index 6ec75b1d8..68837e667 100644
Binary files a/web/images/map-pin.png and b/web/images/map-pin.png differ
diff --git a/web/images/o.png b/web/images/o1.png
similarity index 100%
rename from web/images/o.png
rename to web/images/o1.png
diff --git a/web/images/o2.png b/web/images/o2.png
deleted file mode 100644
index 68837e667..000000000
Binary files a/web/images/o2.png and /dev/null differ
diff --git a/web/images/y.png b/web/images/y.png
new file mode 100644
index 000000000..6ec75b1d8
Binary files /dev/null and b/web/images/y.png differ
diff --git a/web/js/components/geosearch/geosearch-modal.js b/web/js/components/geosearch/geosearch-modal.js
index 72dc0a8e1..32439fc54 100644
--- a/web/js/components/geosearch/geosearch-modal.js
+++ b/web/js/components/geosearch/geosearch-modal.js
@@ -22,7 +22,6 @@ class SearchComponent extends Component {
inputValue: '',
isTouchDevice: false,
searchResults: [],
- selectingCoordinatesOnMap: false,
coordinatesPending: [],
showAlert: false,
};
@@ -31,7 +30,7 @@ class SearchComponent extends Component {
componentDidUpdate(prevProps) {
const { coordinates } = this.props;
- const { selectingCoordinatesOnMap, showAlert } = this.state;
+ const { showAlert } = this.state;
if (showAlert && coordinates.length > 0) {
const [prevLong, prevLat] = prevProps.coordinates;
@@ -56,19 +55,19 @@ class SearchComponent extends Component {
// handle submitting search after inputing coordinates
onCoordinateInputSelect = () => {
- const { selectCoordinatesToFly } = this.props;
+ const { handleSelectCordinatesToFly } = this.props;
const { coordinatesPending } = this.state;
const [longitude, latitude] = coordinatesPending;
reverseGeocode([longitude, latitude]).then((results) => {
- selectCoordinatesToFly([longitude, latitude], results);
+ handleSelectCordinatesToFly([longitude, latitude], results);
});
this.updatePendingCoordinates([]);
}
// handle selecting menu item in search results
onSelect=(value, item) => {
- const { selectCoordinatesToFly } = this.props;
+ const { handleSelectCordinatesToFly } = this.props;
this.updateSearchResults([item]);
this.updateValue(value);
@@ -86,7 +85,7 @@ class SearchComponent extends Component {
const { x, y } = location;
const parsedX = parseFloat(x.toPrecision(9));
const parsedY = parseFloat(y.toPrecision(9));
- selectCoordinatesToFly([parsedX, parsedY], addressAttributes);
+ handleSelectCordinatesToFly([parsedX, parsedY], addressAttributes);
}
});
}
@@ -121,30 +120,30 @@ class SearchComponent extends Component {
}
}
- // initiate instruction alert and activate store level toggleReverseGeocodeActive
+ // initiate instruction alert and activate store level handleReverseGeocodeActive
selectCoordinatesFromMap = (e) => {
e.preventDefault();
const isTouchDevice = e.type === 'touchend';
- const { toggleReverseGeocodeActive } = this.props;
- toggleReverseGeocodeActive(true);
+ const { handleReverseGeocodeActive } = this.props;
+ handleReverseGeocodeActive(true);
this.setState({
- selectingCoordinatesOnMap: true,
isTouchDevice,
showAlert: true,
inputValue: '',
});
}
- // coordinates in array, addressAttributes with address key: object value
- selectCoordinatesToFly = (coordinates, addressAttributes) => {
- const { selectCoordinatesToFly } = this.props;
- selectCoordinatesToFly(coordinates, addressAttributes);
+ // clear selected marker/coordinates from map
+ clearCoordinatesMarker = (e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ const { handleClearCoordinatesClick } = this.props;
+ handleClearCoordinatesClick();
}
render() {
const {
coordinates,
- clearCoordinates,
geosearchMobileModalOpen,
isExpanded,
isMobile,
@@ -207,7 +206,6 @@ class SearchComponent extends Component {
>
<ButtonGroup
className="geosearch-coordinate-button-group"
-
>
<Button
onTouchEnd={this.selectCoordinatesFromMap}
@@ -221,8 +219,8 @@ class SearchComponent extends Component {
{hasCoordinates
&& (
<Button
- onTouchEnd={clearCoordinates}
- onMouseDown={clearCoordinates}
+ onTouchEnd={this.clearCoordinatesMarker}
+ onMouseDown={this.clearCoordinatesMarker}
className="geosearch-coordinate-button-remove"
title="Clear coordinates marker from map"
>
@@ -240,13 +238,13 @@ class SearchComponent extends Component {
}
SearchComponent.propTypes = {
- clearCoordinates: PropTypes.func,
+ handleClearCoordinatesClick: PropTypes.func,
coordinates: PropTypes.array,
geosearchMobileModalOpen: PropTypes.bool,
isExpanded: PropTypes.bool,
isMobile: PropTypes.bool,
- selectCoordinatesToFly: PropTypes.func,
- toggleReverseGeocodeActive: PropTypes.func,
+ handleSelectCordinatesToFly: PropTypes.func,
+ handleReverseGeocodeActive: PropTypes.func,
toggleShowGeosearch: PropTypes.func,
};
diff --git a/web/js/components/geosearch/geosearch.js b/web/js/components/geosearch/geosearch.js
index cf0895c95..fec8f52ea 100644
--- a/web/js/components/geosearch/geosearch.js
+++ b/web/js/components/geosearch/geosearch.js
@@ -9,6 +9,9 @@ import {
toggleShowGeosearch,
toggleReverseGeocodeActive,
} from '../../modules/geosearch/actions';
+import {
+ onToggle,
+} from '../../modules/modal/actions';
class Geosearch extends React.Component {
constructor(props) {
@@ -24,26 +27,47 @@ class Geosearch extends React.Component {
}
}
+ handleClearCoordinatesClick = () => {
+ const { clearCoordinates, coordinatesDialogOpen, onToggle } = this.props;
+ if (coordinatesDialogOpen) {
+ onToggle();
+ }
+ clearCoordinates();
+ }
+
+ handleSelectCordinatesToFly = (coordinates, addressAttributes) => {
+ const { selectCoordinatesToFly, coordinatesDialogOpen, onToggle } = this.props;
+ if (coordinatesDialogOpen) {
+ onToggle();
+ }
+ selectCoordinatesToFly(coordinates, addressAttributes);
+ }
+
+ handleReverseGeocodeActive = (isActive) => {
+ const { toggleReverseGeocodeActive, coordinatesDialogOpen, onToggle } = this.props;
+ if (coordinatesDialogOpen) {
+ onToggle();
+ }
+ toggleReverseGeocodeActive(isActive);
+ }
+
renderSearchComponent = (isMobile) => {
const {
- clearCoordinates,
coordinates,
geosearchMobileModalOpen,
isExpanded,
- selectCoordinatesToFly,
- toggleReverseGeocodeActive,
toggleShowGeosearch,
} = this.props;
return (
<GeosearchModal
+ coordinates={coordinates}
geosearchMobileModalOpen={geosearchMobileModalOpen}
isExpanded={isExpanded}
isMobile={isMobile}
- clearCoordinates={clearCoordinates}
- coordinates={coordinates}
- selectCoordinatesToFly={selectCoordinatesToFly}
- toggleReverseGeocodeActive={toggleReverseGeocodeActive}
+ handleClearCoordinatesClick={this.handleClearCoordinatesClick}
+ handleSelectCordinatesToFly={this.handleSelectCordinatesToFly}
+ handleReverseGeocodeActive={this.handleReverseGeocodeActive}
toggleShowGeosearch={toggleShowGeosearch}
/>
);
@@ -88,12 +112,14 @@ const mapStateToProps = (state) => {
const isMobile = browser.lessThan.medium;
const snapshotModalOpen = modal.isOpen && modal.id === 'TOOLBAR_SNAPSHOT';
const geosearchMobileModalOpen = modal.isOpen && modal.id === 'TOOLBAR_GEOSEARCH_MOBILE';
+ const coordinatesDialogOpen = modal.isOpen && modal.id.includes('COORDINATES_VECTOR_DIALOG');
// Collapse when Image download / GIF / is open or measure tool active
const shouldBeCollapsed = snapshotModalOpen || measure.isActive || animation.gifActive;
return {
coordinates,
isExpanded,
+ coordinatesDialogOpen,
geosearchMobileModalOpen,
isMobile,
shouldBeCollapsed,
@@ -114,16 +140,21 @@ const mapDispatchToProps = (dispatch) => ({
toggleReverseGeocodeActive: (isActive) => {
dispatch(toggleReverseGeocodeActive(isActive));
},
+ onToggle: () => {
+ dispatch(onToggle());
+ },
});
Geosearch.propTypes = {
isFeatureEnabled: PropTypes.bool,
clearCoordinates: PropTypes.func,
coordinates: PropTypes.array,
+ coordinatesDialogOpen: PropTypes.bool,
geosearchMobileModalOpen: PropTypes.bool,
isExpanded: PropTypes.bool,
isDistractionFreeModeActive: PropTypes.bool,
isMobile: PropTypes.bool,
+ onToggle: PropTypes.func,
selectCoordinatesToFly: PropTypes.func,
shouldBeCollapsed: PropTypes.bool,
toggleReverseGeocodeActive: PropTypes.func,
diff --git a/web/js/containers/map-interactions/map-interactions.js b/web/js/containers/map-interactions/map-interactions.js
index bbe54ca85..86fcbfad0 100644
--- a/web/js/containers/map-interactions/map-interactions.js
+++ b/web/js/containers/map-interactions/map-interactions.js
@@ -24,7 +24,11 @@ class MapInteractions extends React.PureComponent {
return (
<>
- <div id="wv-map" className={mapClasses} />
+ <div
+ id="wv-map"
+ className={mapClasses}
+ style={{ cursor: isCoordinateSearchActive ? 'crosshair' : 'default' }}
+ />
{!isDistractionFreeModeActive && (
<>
<OlCoordinates
diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.js
index 064a0724e..a1240b7db 100644
--- a/web/js/containers/toolbar.js
+++ b/web/js/containers/toolbar.js
@@ -74,14 +74,14 @@ const CUSTOM_MODAL_PROPS = {
clickableBehindModal: true,
},
TOOLBAR_GEOSEARCH_MOBILE: {
- headerText: 'Search for places or enter coordinates',
- type: 'toolbar',
backdrop: false,
- modalClassName: 'toolbar-geosearch-modal toolbar-modal toolbar-medium-modal',
+ bodyComponent: Geosearch,
clickableBehindModal: true,
- wrapClassName: 'toolbar_modal_outer',
+ headerText: 'Search for places or enter coordinates',
mobileOnly: true,
- bodyComponent: Geosearch,
+ modalClassName: 'toolbar-geosearch-modal toolbar-modal toolbar-medium-modal',
+ type: 'toolbar',
+ wrapClassName: 'toolbar_modal_outer',
},
};
diff --git a/web/js/location.js b/web/js/location.js
index c49f1e785..1c62bd77e 100644
--- a/web/js/location.js
+++ b/web/js/location.js
@@ -25,7 +25,7 @@ import { resetLayers, hasSubDaily } from './modules/layers/selectors';
import { eventsReducerState } from './modules/natural-events/reducers';
import { mapLocationToPaletteState } from './modules/palettes/util';
import { mapLocationToAnimationState } from './modules/animation/util';
-import mapLocationToGeosearchState from './modules/geosearch/util';
+import { mapLocationToGeosearchState } from './modules/geosearch/util';
import { areCoordinatesWithinExtent } from './modules/geosearch/selectors';
import mapLocationToSidebarState from './modules/sidebar/util';
import util from './util/util';
diff --git a/web/js/modules/geosearch/actions.js b/web/js/modules/geosearch/actions.js
index c22d4a876..b8727c2c7 100644
--- a/web/js/modules/geosearch/actions.js
+++ b/web/js/modules/geosearch/actions.js
@@ -11,6 +11,7 @@ import {
removeCoordinatesMarker,
} from './selectors';
import { getMaxZoomLevelLayerCollection } from '../layers/selectors';
+import { setLocalStorageCollapseState } from './util';
export function toggleShowGeosearch() {
return (dispatch, getState) => {
@@ -18,6 +19,10 @@ export function toggleShowGeosearch() {
const { geosearch } = state;
const { isExpanded } = geosearch;
+ // handle localStorage user browser preference of expanded/collapsed
+ const storageValue = isExpanded ? 'collapsed' : 'expanded';
+ setLocalStorageCollapseState(storageValue);
+
dispatch({
type: TOGGLE_SHOW_GEOSEARCH,
value: !isExpanded,
diff --git a/web/js/modules/geosearch/reducers.js b/web/js/modules/geosearch/reducers.js
index d82a03a6c..520b2678f 100644
--- a/web/js/modules/geosearch/reducers.js
+++ b/web/js/modules/geosearch/reducers.js
@@ -6,10 +6,12 @@ import {
TOGGLE_SHOW_GEOSEARCH,
UPDATE_ACTIVE_MARKER,
} from './constants';
+import { getLocalStorageCollapseState } from './util';
+const localStorageCollapseState = getLocalStorageCollapseState();
const geosearchState = {
isCoordinateSearchActive: false,
- isExpanded: true,
+ isExpanded: !localStorageCollapseState,
coordinates: [],
activeMarker: null,
};
diff --git a/web/js/modules/geosearch/selectors.js b/web/js/modules/geosearch/selectors.js
index 7fabd98db..ea6400303 100644
--- a/web/js/modules/geosearch/selectors.js
+++ b/web/js/modules/geosearch/selectors.js
@@ -123,12 +123,27 @@ const GEOCODE_OPTIONS = {
},
};
+// https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm
+// necessary to filter to remove fast food type suggestions, but still include relavant Places of Interest
+const GEOCODE_SUGGEST_CATEGORIES = [
+ 'Address',
+ 'Populated Place',
+ 'Education,Land Features',
+ 'Water Features',
+ 'Museum',
+ 'Tourist Attraction',
+ 'Scientific Research',
+ 'Government Office',
+ 'Business Facility',
+];
+
export async function suggest(val) {
const { requestOptions, urlBase } = GEOCODE_OPTIONS;
const encodedValue = encodeURIComponent(val);
+ const encodedCategories = encodeURIComponent(GEOCODE_SUGGEST_CATEGORIES.join(','));
try {
- const response = await fetch(`${urlBase}suggest?text=${encodedValue}&f=json`, requestOptions);
+ const response = await fetch(`${urlBase}suggest?text=${encodedValue}&f=json&category=${encodedCategories}`, requestOptions);
const result = await response.text();
return JSON.parse(result);
} catch (error) {
diff --git a/web/js/modules/geosearch/util.js b/web/js/modules/geosearch/util.js
index 8a8340c1d..29d36dca2 100644
--- a/web/js/modules/geosearch/util.js
+++ b/web/js/modules/geosearch/util.js
@@ -1,11 +1,13 @@
import update from 'immutability-helper';
+import safeLocalStorage from '../../util/local-storage';
+const { GEOSEARCH_COLLAPSED } = safeLocalStorage.keys;
/**
*
* @param {*} parameters
* @param {*} stateFromLocation
*/
-export default function mapLocationToGeosearchState(
+export function mapLocationToGeosearchState(
parameters,
stateFromLocation,
state,
@@ -14,12 +16,32 @@ export default function mapLocationToGeosearchState(
const coordinates = marker
? marker.split(',')
: [];
+
+ const isMobile = state.browser.lessThan.medium;
+ const localStorageCollapseState = getLocalStorageCollapseState();
+ const isExpanded = !isMobile && !localStorageCollapseState;
+
stateFromLocation = update(stateFromLocation, {
geosearch: {
coordinates: { $set: coordinates },
- isExpanded: { $set: !state.browser.lessThan.medium },
+ isExpanded: { $set: isExpanded },
},
});
return stateFromLocation;
}
+
+/**
+ * @return {Boolean} is geosearch local storage set to 'collapsed'
+ */
+export function getLocalStorageCollapseState() {
+ return safeLocalStorage.getItem(GEOSEARCH_COLLAPSED) === 'collapsed';
+}
+
+/**
+ * @param {String} storageValue
+ * @return {Void}
+ */
+export function setLocalStorageCollapseState(storageValue) {
+ safeLocalStorage.setItem(GEOSEARCH_COLLAPSED, storageValue);
+}
diff --git a/web/js/util/local-storage.js b/web/js/util/local-storage.js
index e9f8a6b9b..cbdca5511 100644
--- a/web/js/util/local-storage.js
+++ b/web/js/util/local-storage.js
@@ -19,7 +19,7 @@ export default {
enabled,
keys: {
RECENT_LAYERS: 'recentLayers',
- SEARCH_TOKEN: 'searchToken',
+ GEOSEARCH_COLLAPSED: 'geosearchState',
DISMISSED_EVENT_VIS_ALERT: 'dismissedEventVisibilityAlert',
DISMISSED_COMPARE_ALERT: 'dismissedCompareAlert',
HIDE_TOUR: 'hideTour',