Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

move input state and related up to parent component to retain on expand and minimize

Ed Plato23a649274934
diff --git a/web/js/components/geosearch/coordinates-dialog.js b/web/js/components/geosearch/coordinates-dialog.js
index 875c3af84..66643cb74 100644
--- a/web/js/components/geosearch/coordinates-dialog.js
+++ b/web/js/components/geosearch/coordinates-dialog.js
@@ -30,12 +30,13 @@ class CoordinatesDialog extends Component {
} = this.state;
const {
- features, // parsed { latitude, longitude }
- title, // "Wairau Valley"
+ latitude,
+ longitude,
+ title,
} = coordinatesMetadata;
- const latitudeText = `Latitude: ${features.latitude} °`;
- const longitudeText = `Longitude: ${features.longitude} °`;
+ const latitudeText = `Latitude: ${latitude}`;
+ const longitudeText = `Longitude: ${longitude}`;
return (
<div className="tooltip-custom-black tooltip-static tooltip-coordinates-container">
<CopyClipboardTooltip
@@ -55,7 +56,7 @@ class CoordinatesDialog extends Component {
</span>
<CopyToClipboard
options={window.clipboardData ? {} : { format: 'text/plain' }}
- text={`${features.latitude}, ${features.longitude}`}
+ text={`${latitude}, ${longitude}`}
onCopy={this.onCopyToClipboard}
>
<FontAwesomeIcon id="copy-coordinates-to-clipboard-button" icon={faCopy} fixedWidth />
diff --git a/web/js/components/geosearch/geosearch-input.js b/web/js/components/geosearch/geosearch-input.js
index cadded013..beb44452c 100644
--- a/web/js/components/geosearch/geosearch-input.js
+++ b/web/js/components/geosearch/geosearch-input.js
@@ -8,8 +8,6 @@ import { faExclamationTriangle, faSearchLocation } from '@fortawesome/free-solid
class SearchBox extends Component {
constructor(props) {
super(props);
- this.state = {
- };
this.highlightedItem = null;
this.geosearchInput = null;
}
@@ -29,10 +27,12 @@ class SearchBox extends Component {
// handle submit button click - required to select coordinates since no suggestions menu
handleSubmitClick = (e) => {
e.preventDefault();
- const { onSelect, coordinatesPending, onCoordinateInputSelect } = this.props;
+ const {
+ onSelect, coordinatesPending, onCoordinateInputSelect, searchResults,
+ } = this.props;
if (coordinatesPending.length > 0) {
onCoordinateInputSelect();
- } else if (this.highlightedItem) {
+ } else if (searchResults.length > 0 && this.highlightedItem) {
onSelect(this.highlightedItem.text, this.highlightedItem);
}
}
@@ -86,10 +86,10 @@ class SearchBox extends Component {
} = this.props;
const hasCoordinates = coordinates.length > 0;
// eslint-disable-next-line no-nested-ternary
- const buttonContainerRight = hasCoordinates
+ const rightPositioning = hasCoordinates
? isMobile ? '67px' : '60px'
: '30px';
- const submitButtonStyle = inputValue
+ const buttonStyle = inputValue
? { color: '#0070c8', cursor: 'pointer' }
: {};
@@ -98,11 +98,11 @@ class SearchBox extends Component {
className="geosearch-submit-input-group-addon"
addonType="append"
style={{
- right: buttonContainerRight,
+ right: rightPositioning,
}}
>
<Button
- style={submitButtonStyle}
+ style={buttonStyle}
disabled={!inputValue}
onClick={this.handleSubmitClick}
className="geosearch-search-submit-button"
@@ -121,8 +121,8 @@ class SearchBox extends Component {
} = this.props;
const hasCoordinates = coordinates.length > 0;
// eslint-disable-next-line no-nested-ternary
- const buttonContainerRight = hasCoordinates
- ? isMobile ? '121px' : '121px'
+ const rightPositioning = hasCoordinates
+ ? isMobile ? '130px' : '121px'
: '92px';
return (
@@ -131,9 +131,9 @@ class SearchBox extends Component {
className="geosearch-submit-input-group-addon"
addonType="append"
style={{
- right: buttonContainerRight,
+ right: rightPositioning,
}}
- title="The entered coordinates are outside of the current map extent."
+ title="The entered location is outside of the current map extent."
>
<FontAwesomeIcon icon={faExclamationTriangle} size="1x" />
</InputGroupAddon>
@@ -141,24 +141,33 @@ class SearchBox extends Component {
);
}
- render() {
+ // condtional autocomplete wrapper styling
+ getWrapperStyle = () => {
const {
coordinates,
- inputValue,
isMobile,
- onChange,
- onSelect,
- searchResults,
showExtentAlert,
} = this.props;
const hasCoordinates = coordinates.length > 0;
const wrapperStyleWidth = hasCoordinates ? '268px' : '299px';
- const wrapperStyle = {
+ return {
width: isMobile ? '90%' : wrapperStyleWidth,
+ // eslint-disable-next-line no-nested-ternary
paddingRight: isMobile
? '0'
- : showExtentAlert ? '48px' : '26px',
+ : showExtentAlert ? '53px' : '26px',
};
+ }
+
+ render() {
+ const {
+ inputValue,
+ isMobile,
+ onChange,
+ onSelect,
+ searchResults,
+ } = this.props;
+
const placeHolderText = isMobile
? 'Enter place name or coordinates'
: 'Search for places or enter coordinates';
@@ -175,13 +184,12 @@ class SearchBox extends Component {
id: 'geosearch-autocomplete',
placeholder: placeHolderText,
}}
- wrapperStyle={wrapperStyle}
+ wrapperStyle={this.getWrapperStyle()}
value={inputValue}
items={searchResults}
getItemValue={(item) => item.text}
onSelect={onSelect}
onChange={onChange}
- onMenuVisibilityChange={this.resetHighlightedItem}
renderMenu={this.renderMenu}
renderItem={this.renderItem}
/>
diff --git a/web/js/components/geosearch/geosearch-modal.js b/web/js/components/geosearch/geosearch-modal.js
index d05defcb6..5c947a8ec 100644
--- a/web/js/components/geosearch/geosearch-modal.js
+++ b/web/js/components/geosearch/geosearch-modal.js
@@ -3,7 +3,11 @@ import React, { Component } from 'react';
import {
ButtonGroup, Button, InputGroup, InputGroupAddon,
} from 'reactstrap';
-import { get as lodashGet } from 'lodash';
+import {
+ throttle as lodashThrottle,
+ get as lodashGet,
+} from 'lodash';
+import googleTagManager from 'googleTagManager';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faMapMarkerAlt,
@@ -19,79 +23,75 @@ class SearchComponent extends Component {
constructor(props) {
super(props);
this.state = {
- inputValue: '',
isTouchDevice: false,
- searchResults: [],
- coordinatesPending: [],
- showAlert: false,
+ showReverseGeocodeAlert: false,
showExtentAlert: false,
};
- this.requestTimer = null;
+ this.throttleSuggest = lodashThrottle(suggest.bind(this), 500);
}
componentDidUpdate(prevProps) {
const { coordinates } = this.props;
- const { showAlert } = this.state;
+ const { showReverseGeocodeAlert } = this.state;
- if (showAlert && coordinates.length > 0) {
+ if (showReverseGeocodeAlert && coordinates.length > 0) {
const [prevLong, prevLat] = prevProps.coordinates;
const [long, lat] = coordinates;
if (prevLong !== long || prevLat !== lat) {
- this.dismissAlert();
+ this.dismissReverseGeocodeAlert();
}
}
}
- // update input value
- updateValue = (inputValue) => this.setState({ inputValue });
-
- // update list of suggested search results
- updateSearchResults = (searchResults) => this.setState({ searchResults });
-
- // update array of pending coordinates
- updatePendingCoordinates = (coordinatesPending) => this.setState({ coordinatesPending });
-
// dismiss message instruction alert
- dismissAlert = () => this.setState({ showAlert: false });
+ dismissReverseGeocodeAlert = () => this.setState({ showReverseGeocodeAlert: false });
- // dismiss extent message error alert
- dismissExtentAlert = () => this.setState({ showExtentAlert: false });
+ // set extent message error alert
+ setExtentAlert = (shouldShow) => this.setState({ showExtentAlert: shouldShow });
// handle submitting search after inputing coordinates
onCoordinateInputSelect = () => {
- const { isCoordinatePairWithinExtent, selectCoordinatesToFly } = this.props;
- const { coordinatesPending } = this.state;
+ const {
+ coordinatesPending,
+ isCoordinatePairWithinExtent,
+ selectCoordinatesToFly,
+ updatePendingCoordinates,
+ updateSearchResults,
+ updateValue,
+ } = this.props;
const coordinatesWithinExtent = isCoordinatePairWithinExtent(coordinatesPending);
if (coordinatesWithinExtent === false) {
- this.setState({
- showExtentAlert: true,
- });
+ this.setExtentAlert(true);
} else {
const [longitude, latitude] = coordinatesPending;
reverseGeocode([longitude, latitude]).then((results) => {
selectCoordinatesToFly([longitude, latitude], results);
});
- this.setState({
- inputValue: '',
- coordinatesPending: [],
- showExtentAlert: false,
- searchResults: [],
- });
+ this.setExtentAlert(false);
+ updateValue('');
+ updateSearchResults([]);
+ updatePendingCoordinates([]);
}
}
// handle selecting menu item in search results
onSelect=(value, item) => {
- const { isCoordinatePairWithinExtent, selectCoordinatesToFly } = this.props;
- this.setState({
- inputValue: value,
- searchResults: [item],
- });
+ const {
+ isCoordinatePairWithinExtent,
+ selectCoordinatesToFly,
+ updateSearchResults,
+ updateValue,
+ } = this.props;
+ updateValue(value);
+ updateSearchResults([item]);
const {
magicKey,
} = item;
+ googleTagManager.pushEvent({
+ event: 'geosearch_selected_suggested_menu_item',
+ });
processMagicKey(magicKey).then((result) => {
if (lodashGet(result, 'candidates[0]')) {
const firstCandidate = result.candidates[0];
@@ -104,9 +104,7 @@ class SearchComponent extends Component {
const coordinatesWithinExtent = isCoordinatePairWithinExtent([parsedX, parsedY]);
if (coordinatesWithinExtent === false) {
- this.setState({
- showExtentAlert: true,
- });
+ this.setExtentAlert(true);
} else {
selectCoordinatesToFly([parsedX, parsedY], addressAttributes);
}
@@ -117,28 +115,31 @@ class SearchComponent extends Component {
// handle input value change including text/coordinates typing, pasting, cutting
onChange=(e, value) => {
e.preventDefault();
- this.updateValue(value);
+ const {
+ updateSearchResults, updateValue, updatePendingCoordinates,
+ } = this.props;
+ updateValue(value);
// check for coordinate value
const coordinatesInputValue = isValidCoordinates(value);
if (coordinatesInputValue) {
- clearTimeout(this.requestTimer);
+ this.throttleSuggest.cancel();
const { latitude, longitude } = coordinatesInputValue;
- this.setState({
- searchResults: [],
- coordinatesPending: [longitude, latitude],
- showExtentAlert: false,
- });
+ this.setExtentAlert(false);
+ updateSearchResults([]);
+ updatePendingCoordinates([longitude, latitude]);
} else {
- clearTimeout(this.requestTimer);
+ this.throttleSuggest.cancel();
if (!value) {
- this.updateSearchResults([]);
+ updateSearchResults([]);
} else {
// provide suggestions to populate search result menu item(s)
- this.requestTimer = suggest(value).then((items) => {
+ return this.throttleSuggest(value).then((items) => {
if (lodashGet(items, 'suggestions')) {
const { suggestions } = items;
- this.updateSearchResults(suggestions);
+ updateSearchResults(suggestions);
+ } else {
+ updateSearchResults([]);
}
});
}
@@ -146,16 +147,19 @@ class SearchComponent extends Component {
}
// initiate instruction alert and activate store level toggleReverseGeocodeActive
- selectCoordinatesFromMap = (e) => {
+ initReverseGeocode = (e) => {
e.preventDefault();
const isTouchDevice = e.type === 'touchend';
- const { toggleReverseGeocodeActive } = this.props;
+ const { toggleReverseGeocodeActive, updateValue } = this.props;
toggleReverseGeocodeActive(true);
this.setState({
isTouchDevice,
- showAlert: true,
+ showReverseGeocodeAlert: true,
showExtentAlert: false,
- inputValue: '',
+ });
+ updateValue('');
+ googleTagManager.pushEvent({
+ event: 'geosearch_reverse_geocode',
});
}
@@ -167,65 +171,129 @@ class SearchComponent extends Component {
clearCoordinates();
}
+ // render alert message to instruct user map interaction
+ renderReverseGeocodeAlert = () => {
+ const {
+ isTouchDevice,
+ showReverseGeocodeAlert,
+ } = this.state;
+ const message = `${isTouchDevice ? 'Tap' : 'Click'} on map to identify a location.`;
+
+ return showReverseGeocodeAlert && (
+ <Alert
+ id="geosearch-select-coordinates-alert"
+ isOpen
+ iconClassName="faMapMarkerAlt"
+ title="Geosearch Select Coordinates"
+ timeout={6000}
+ message={message}
+ onDismiss={this.dismissReverseGeocodeAlert}
+ />
+ );
+ }
+
+ // render alert message to indicate entered location is outside of map extent
+ renderExtentAlert = () => {
+ const {
+ showExtentAlert,
+ } = this.state;
+ const message = 'Provided location is outside of the map extent. Revise or try a different projection.';
+
+ return showExtentAlert && (
+ <Alert
+ id="geosearch-select-coordinates-extent-alert"
+ isOpen
+ title="Selected Coordinates Outside Current Map Projection"
+ timeout={15000}
+ message={message}
+ onDismiss={() => this.setExtentAlert(false)}
+ />
+ );
+ }
+
+ // render geosearch component minimize button (not visible in mobile)
+ renderMinimizeButton = () => {
+ const { toggleShowGeosearch } = this.props;
+ return (
+ <InputGroupAddon addonType="prepend">
+ <Button
+ className="geosearch-search-minimize-button"
+ title="Minimize search box"
+ onClick={toggleShowGeosearch}
+ >
+ <div className="geosearch-search-minimize-button-chevron" />
+ </Button>
+ </InputGroupAddon>
+ );
+ }
+
+ // render coordinate button group with buttons 1) reverse geocode and 2) clear map marker (conditional)
+ renderCoordinateButtonGroup = () => {
+ const {
+ coordinates,
+ isMobile,
+ } = this.props;
+ const hasCoordinates = coordinates.length > 0;
+ const containerClass = `geosearch-coordinate-group-container ${hasCoordinates ? 'grouped' : ''}`;
+ const buttonRightMargin = { marginRight: hasCoordinates && isMobile ? '6px' : '1px' };
+
+ return (
+ <InputGroupAddon
+ addonType="append"
+ className={containerClass}
+ >
+ <ButtonGroup
+ className="geosearch-coordinate-button-group"
+ >
+ <Button
+ onTouchEnd={this.initReverseGeocode}
+ onMouseDown={this.initReverseGeocode}
+ className="geosearch-coordinate-button-addpoint"
+ title="Add coordinates marker onto map"
+ style={buttonRightMargin}
+ >
+ <FontAwesomeIcon icon={faMapMarkerAlt} size="1x" />
+ </Button>
+ {hasCoordinates
+ && (
+ <Button
+ onTouchEnd={this.clearCoordinatesMarker}
+ onMouseDown={this.clearCoordinatesMarker}
+ className="geosearch-coordinate-button-remove"
+ title="Clear coordinates marker from map"
+ >
+ <FontAwesomeIcon icon={faSlash} />
+ <FontAwesomeIcon icon={faMapMarkerAlt} size="1x" />
+ </Button>
+ )}
+ </ButtonGroup>
+ </InputGroupAddon>
+ );
+ }
+
render() {
const {
coordinates,
geosearchMobileModalOpen,
isExpanded,
isMobile,
- toggleShowGeosearch,
- } = this.props;
- const {
coordinatesPending,
inputValue,
- isTouchDevice,
searchResults,
- showAlert,
+ } = this.props;
+ const {
showExtentAlert,
} = this.state;
- const hasCoordinates = coordinates.length > 0;
- const alertMessage = `${isTouchDevice ? 'Tap' : 'Click'} on map to identify a point on the map.`;
- const extentAlertMessage = 'Provided location is outside of the map extent. Revise or try a different projection.';
- const coordinateButtonGroupContainerClassName = `geosearch-coordinate-group-container ${hasCoordinates ? 'grouped' : ''}`;
return (
<>
- {showAlert && (
- <Alert
- id="geosearch-select-coordinates-alert"
- isOpen
- iconClassName="faMapMarkerAlt"
- title="Geosearch Select Coordinates"
- timeout={6000}
- message={alertMessage}
- onDismiss={this.dismissAlert}
- />
- )}
- {showExtentAlert && (
- <Alert
- id="geosearch-select-coordinates-extent-alert"
- isOpen
- title="Selected Coordinates Outside Current Map Projection"
- timeout={15000}
- message={extentAlertMessage}
- onDismiss={this.dismissExtentAlert}
- />
- )}
-
+ {/* Alerts */}
+ {this.renderReverseGeocodeAlert()}
+ {this.renderExtentAlert()}
<div className="geosearch-component">
<InputGroup className="geosearch-search-input-group">
- {!isMobile
- && (
- <InputGroupAddon addonType="prepend">
- <Button
- className="geosearch-search-minimize-button"
- title="Minimize search box"
- onClick={toggleShowGeosearch}
- >
- <div className="geosearch-search-minimize-button-chevron" />
- </Button>
- </InputGroupAddon>
- )}
+ {/* Minimize button not visible in mobile */}
+ {!isMobile && this.renderMinimizeButton()}
<SearchBox
coordinates={coordinates}
coordinatesPending={coordinatesPending}
@@ -239,36 +307,8 @@ class SearchComponent extends Component {
isMobile={isMobile}
showExtentAlert={showExtentAlert}
/>
- <InputGroupAddon
- addonType="append"
- className={coordinateButtonGroupContainerClassName}
- >
- <ButtonGroup
- className="geosearch-coordinate-button-group"
- >
- <Button
- onTouchEnd={this.selectCoordinatesFromMap}
- onMouseDown={this.selectCoordinatesFromMap}
- className="geosearch-coordinate-button-addpoint"
- title="Add coordinates marker onto map"
- style={{ marginRight: hasCoordinates && isMobile ? '6px' : '0' }}
- >
- <FontAwesomeIcon icon={faMapMarkerAlt} size="1x" />
- </Button>
- {hasCoordinates
- && (
- <Button
- onTouchEnd={this.clearCoordinatesMarker}
- onMouseDown={this.clearCoordinatesMarker}
- className="geosearch-coordinate-button-remove"
- title="Clear coordinates marker from map"
- >
- <FontAwesomeIcon icon={faSlash} />
- <FontAwesomeIcon icon={faMapMarkerAlt} size="1x" />
- </Button>
- )}
- </ButtonGroup>
- </InputGroupAddon>
+ {/* Coordinate button group */}
+ {this.renderCoordinateButtonGroup()}
</InputGroup>
</div>
</>
@@ -277,15 +317,21 @@ class SearchComponent extends Component {
}
SearchComponent.propTypes = {
- isCoordinatePairWithinExtent: PropTypes.func,
clearCoordinates: PropTypes.func,
coordinates: PropTypes.array,
+ coordinatesPending: PropTypes.array,
geosearchMobileModalOpen: PropTypes.bool,
+ inputValue: PropTypes.string,
+ isCoordinatePairWithinExtent: PropTypes.func,
isExpanded: PropTypes.bool,
isMobile: PropTypes.bool,
+ searchResults: PropTypes.array,
selectCoordinatesToFly: PropTypes.func,
toggleReverseGeocodeActive: PropTypes.func,
toggleShowGeosearch: PropTypes.func,
+ updatePendingCoordinates: PropTypes.func,
+ updateSearchResults: PropTypes.func,
+ updateValue: PropTypes.func,
};
export default SearchComponent;
diff --git a/web/js/components/geosearch/geosearch.js b/web/js/components/geosearch/geosearch.js
index 42444fe60..55812a847 100644
--- a/web/js/components/geosearch/geosearch.js
+++ b/web/js/components/geosearch/geosearch.js
@@ -1,7 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
-// import googleTagManager from 'googleTagManager';
import GeosearchModal from './geosearch-modal';
import {
clearCoordinates,
@@ -17,6 +16,9 @@ class Geosearch extends React.Component {
constructor(props) {
super(props);
this.state = {
+ inputValue: '',
+ searchResults: [],
+ coordinatesPending: [],
};
}
@@ -27,29 +29,49 @@ class Geosearch extends React.Component {
}
}
+ // update input value
+ updateValue = (inputValue) => this.setState({ inputValue });
+
+ // update list of suggested search results
+ updateSearchResults = (searchResults) => this.setState({ searchResults });
+
+ // update array of pending coordinates
+ updatePendingCoordinates = (coordinatesPending) => this.setState({ coordinatesPending });
+
renderSearchComponent = (isMobile) => {
const {
- isCoordinatePairWithinExtent,
clearCoordinates,
coordinates,
geosearchMobileModalOpen,
+ isCoordinatePairWithinExtent,
isExpanded,
selectCoordinatesToFly,
toggleReverseGeocodeActive,
toggleShowGeosearch,
} = this.props;
+ const {
+ coordinatesPending,
+ inputValue,
+ searchResults,
+ } = this.state;
return (
<GeosearchModal
- isCoordinatePairWithinExtent={isCoordinatePairWithinExtent}
+ clearCoordinates={clearCoordinates}
coordinates={coordinates}
+ coordinatesPending={coordinatesPending}
geosearchMobileModalOpen={geosearchMobileModalOpen}
+ inputValue={inputValue}
+ isCoordinatePairWithinExtent={isCoordinatePairWithinExtent}
isExpanded={isExpanded}
isMobile={isMobile}
- clearCoordinates={clearCoordinates}
+ searchResults={searchResults}
selectCoordinatesToFly={selectCoordinatesToFly}
toggleReverseGeocodeActive={toggleReverseGeocodeActive}
toggleShowGeosearch={toggleShowGeosearch}
+ updatePendingCoordinates={this.updatePendingCoordinates}
+ updateSearchResults={this.updateSearchResults}
+ updateValue={this.updateValue}
/>
);
}
diff --git a/web/js/components/geosearch/ol-coordinates-marker-util.js b/web/js/components/geosearch/ol-coordinates-marker-util.js
index 782c3c11a..28d83f70b 100644
--- a/web/js/components/geosearch/ol-coordinates-marker-util.js
+++ b/web/js/components/geosearch/ol-coordinates-marker-util.js
@@ -5,6 +5,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import CoordinatesDialog from './coordinates-dialog';
import { coordinatesCRSTransform } from '../../modules/projection/util';
+import util from '../../util/util';
/**
* Get parsed precision coordinate number
@@ -108,15 +109,21 @@ export function getCoordinatesMetadata(geocodeProperties) {
title = `${Match_addr}`;
}
}
- const coordinatesMetadata = {
- features: {
- latitude: parsedLatitude,
- longitude: parsedLongitude,
- },
+
+ // format coordinates based on localStorage preference
+ const format = util.getCoordinateFormat();
+ const coordinates = util.formatCoordinate(
+ [parsedLongitude, parsedLatitude],
+ format,
+ );
+ const formattedCoordinates = coordinates.split(',');
+ const [formattedLatitude, formattedLongitude] = formattedCoordinates;
+
+ return {
+ latitude: formattedLatitude.trim(),
+ longitude: formattedLongitude.trim(),
title,
};
-
- return coordinatesMetadata;
}
/**
diff --git a/web/js/components/geosearch/util.js b/web/js/components/geosearch/util.js
index 24d6e8761..99459ad29 100644
--- a/web/js/components/geosearch/util.js
+++ b/web/js/components/geosearch/util.js
@@ -1,9 +1,10 @@
import CoordinateParser from 'coordinate-parser';
+// check for valid coordinates using https://www.npmjs.com/package/coordinate-parser
export default function isValidCoordinates(position) {
try {
- const validatedCoordinates = new CoordinateParser(position);
- return validatedCoordinates;
+ const isValid = new CoordinateParser(position);
+ return isValid;
} catch (error) {
return false;
}
diff --git a/web/js/map/ui.js b/web/js/map/ui.js
index 27168aa9a..e4bb68e8a 100644
--- a/web/js/map/ui.js
+++ b/web/js/map/ui.js
@@ -56,6 +56,7 @@ import { updateVectorSelection } from '../modules/vector-styles/util';
import { faIconPlusSVGDomEl, faIconMinusSVGDomEl } from './fa-map-icons';
import { hasVectorLayers } from '../modules/layers/util';
import { addCoordinatesMarker, reverseGeocode } from '../modules/geosearch/selectors';
+import { getCoordinatesMetadata, renderTooltip } from '../components/geosearch/ol-coordinates-marker-util';
export default function mapui(models, config, store, ui) {
const id = 'wv-map';
@@ -231,6 +232,13 @@ export default function mapui(models, config, store, ui) {
*/
const addMarkerAndUpdateStore = (activeMarker, coordinates, results) => {
const marker = addCoordinatesMarker(activeMarker, config, { ui: self }, coordinates, results);
+
+ // handle render initial tooltip
+ const [longitude, latitude] = coordinates;
+ const geocodeProperties = { latitude, longitude, reverseGeocodeResults: results };
+ const coordinatesMetadata = getCoordinatesMetadata(geocodeProperties);
+ renderTooltip(self.selected, config, [latitude, longitude], coordinatesMetadata);
+
store.dispatch({ type: UPDATE_ACTIVE_MARKER, value: marker, reverseGeocodeResults: results });
};
@@ -433,8 +441,8 @@ export default function mapui(models, config, store, ui) {
lodashEach(defs, (def) => {
map.addLayer(createLayer(def));
});
- // add active map marker back after destroying compare mode post createLayer
- if (compareMapDestroyed && activeMarker) {
+ // add active map marker back after destroying from layer/compare change
+ if (activeMarker) {
addMarkerAndUpdateStore(activeMarker, coordinates, reverseGeocodeResults);
}
} else {
diff --git a/web/js/modules/geosearch/selectors.js b/web/js/modules/geosearch/selectors.js
index 46ee6231a..1596f5827 100644
--- a/web/js/modules/geosearch/selectors.js
+++ b/web/js/modules/geosearch/selectors.js
@@ -134,14 +134,17 @@ const constantRequestParameters = '&langCode=en&f=json';
// necessary to filter to remove fast food type suggestions, but still include relavant Places of Interest
const GEOCODE_SUGGEST_CATEGORIES = [
'Address',
+ 'Street Address',
'Populated Place',
- 'Education,Land Features',
+ 'Education',
+ 'Land Features',
'Water Features',
'Museum',
'Tourist Attraction',
'Scientific Research',
'Government Office',
'Business Facility',
+ 'Primary Postal',
];
export async function suggest(val) {
diff --git a/web/js/modules/image-download/util.test.js b/web/js/modules/image-download/util.test.js
index 3e030a967..4e4a35701 100644
--- a/web/js/modules/image-download/util.test.js
+++ b/web/js/modules/image-download/util.test.js
@@ -214,7 +214,7 @@ test('Download URL', () => {
height: 300,
};
const dateTime = new Date('2019-06-24T19:04:00Z');
- const geosearchCoordinates = [37.7771, -122.4196];
+ const geosearchCoordinates = [-19.16086, 2.71169];
const dlURL = getDownloadUrl(url, proj, mockLayerDefs, lonlats, dimensions, dateTime, false, false, geosearchCoordinates);
const expectedURL = 'http://localhost:3002/api/v1/snapshot'
+ '?REQUEST=GetSnapshot'
@@ -225,6 +225,6 @@ test('Download URL', () => {
+ '&WRAP=day'
+ '&FORMAT=image/jpeg'
+ '&WIDTH=300&HEIGHT=300'
- + '&MARKER=37.7771,-122.4196';
+ + '&MARKER=-19.16086,2.71169';
expect(dlURL.includes(expectedURL)).toBe(true);
});