Interactive interface for browsing global, full-resolution satellite imagery
update fontawesome tooltip formats, add ismobile check to prevent hover on tooltip
Ed Plato54a6a6acb8cb
diff --git a/e2e/features/compare/compare-test.js b/e2e/features/compare/compare-test.jsindex 324c41009..7126bf645 100644--- a/e2e/features/compare/compare-test.js+++ b/e2e/features/compare/compare-test.js@@ -18,16 +18,10 @@ module.exports = {reuseables.loadAndSkipTour(c, TIME_LIMIT);},// load A|B and verify that it is active-<<<<<<< HEAD'A|B is loaded': (c) => {c.url(c.globals.url + localQuerystrings.swipeAndAIsActive);c.waitForElementVisible(localSelectors.swipeDragger, TIME_LIMIT);-=======- 'A|B is loaded': function(client) {- client.url(client.globals.url + localQuerystrings.swipeAndAIsActive);- client.waitForElementVisible(localSelectors.swipeDragger, TIME_LIMIT);- client.pause(1000);->>>>>>> 6001fb02e (add delay for compare test, add class back to measure tooltip for tests)+ c.pause(1000);},'Animation is disabled when compare mode active': (c) => {diff --git a/e2e/features/geosearch/geosearch-mobile-test.js b/e2e/features/geosearch/geosearch-mobile-test.jsindex 74e7d664b..bea897622 100644--- a/e2e/features/geosearch/geosearch-mobile-test.js+++ b/e2e/features/geosearch/geosearch-mobile-test.js@@ -9,22 +9,22 @@ const {} = localSelectors;module.exports = {- before(client) {- reuseables.loadAndSkipTour(client, TIME_LIMIT);- client.resizeWindow(375, 667); // iPhone 6/7/8 dimensions- client.pause(300);+ before(c) {+ reuseables.loadAndSkipTour(c, TIME_LIMIT);+ c.resizeWindow(375, 667); // iPhone 6/7/8 dimensions+ c.pause(300);},- 'Geosearch mobile dialog is not visible by default': (client) => {- client.waitForElementVisible(geosearchToolbarButton, TIME_LIMIT);- client.expect.element(geosearchMobileDialog).to.not.be.present;+ 'Geosearch mobile dialog is not visible by default': (c) => {+ c.waitForElementVisible(geosearchToolbarButton, TIME_LIMIT);+ c.expect.element(geosearchMobileDialog).to.not.be.present;},- 'Clicking geosearch toolbar button opens the geosearch mobile dialog': (client) => {- client.waitForElementVisible(geosearchToolbarButton, TIME_LIMIT);- client.click(geosearchToolbarButton);- client.pause(500);- client.expect.element(geosearchMobileDialog).to.be.present;+ 'Clicking geosearch toolbar button opens the geosearch mobile dialog': (c) => {+ c.waitForElementVisible(geosearchToolbarButton, TIME_LIMIT);+ c.click(geosearchToolbarButton);+ c.pause(500);+ c.expect.element(geosearchMobileDialog).to.be.present;},- after(client) {- client.end();+ after(c) {+ c.end();},};diff --git a/e2e/features/geosearch/geosearch-test.js b/e2e/features/geosearch/geosearch-test.jsindex e945f334b..e77445334 100644--- a/e2e/features/geosearch/geosearch-test.js+++ b/e2e/features/geosearch/geosearch-test.js@@ -1,35 +1,69 @@const reuseables = require('../../reuseables/skip-tour.js');const localSelectors = require('../../reuseables/selectors.js');+// encoded id; originally coordinates-map-marker_38.89037,-77.03196+const testMarkerEncodedID = '.coordinates-map-marker_38__2E__89037__2C__-77__2E__03196';+const testMarkerNoDetailsEncodedID = '.coordinates-map-marker_5__2C__-51__2E__5';const TIME_LIMIT = 10000;const {geosearchToolbarButton,geosearchComponent,geosearchMinimizeButton,+ tooltipCoordinatesContainer,+ tooltipCoordinatesTitle,+ tooltipCoordinatesLatitude,+ tooltipCoordinatesLongitude,} = localSelectors;module.exports = {- before(client) {- reuseables.loadAndSkipTour(client, TIME_LIMIT);- },- 'Geosearch component is visible by default': (client) => {- client.waitForElementVisible(geosearchComponent, TIME_LIMIT);- client.expect.element(geosearchComponent).to.be.present;- },- 'Clicking the minimize button minimizes the geosearch component': (client) => {- client.waitForElementVisible(geosearchComponent, TIME_LIMIT);- client.click(geosearchMinimizeButton);- client.pause(500);- client.expect.element(geosearchComponent).to.not.be.present;- },- 'Clicking geosearch toolbar button expands the geosearch component': (client) => {- client.waitForElementVisible(geosearchToolbarButton, TIME_LIMIT);- client.click(geosearchToolbarButton);- client.pause(500);- client.expect.element(geosearchComponent).to.be.present;- },- after(client) {- client.end();+ before(c) {+ reuseables.loadAndSkipTour(c, TIME_LIMIT);+ },+ 'Geosearch component is visible by default': (c) => {+ c.waitForElementVisible(geosearchComponent, TIME_LIMIT);+ c.expect.element(geosearchComponent).to.be.present;+ },+ 'Clicking the minimize button minimizes the geosearch component': (c) => {+ c.waitForElementVisible(geosearchComponent, TIME_LIMIT);+ c.click(geosearchMinimizeButton);+ c.pause(500);+ c.expect.element(geosearchComponent).to.not.be.present;+ },+ 'Geosearch component remains hidden on subsequent page loads per user preference': (c) => {+ reuseables.loadAndSkipTour(c, TIME_LIMIT);+ c.waitForElementVisible(geosearchToolbarButton, TIME_LIMIT);+ c.expect.element(geosearchComponent).to.not.be.present;+ },+ 'Clicking geosearch toolbar button expands the geosearch component': (c) => {+ c.click(geosearchToolbarButton);+ c.pause(500);+ c.expect.element(geosearchComponent).to.be.present;+ },+ 'Coordinates dialog for permalink marker is visible by default on page load': (c) => {+ c.url(`${c.globals.url}?v=-176.3167432493038,-16.70650759975561,-16.988618249303812,108.30938074294103&marker=-77.03196,38.89037`);+ c.waitForElementVisible(tooltipCoordinatesContainer, TIME_LIMIT);+ c.expect.element(testMarkerEncodedID).to.be.present;+ },+ 'Coordinates title and detailed coordinates are correct': (c) => {+ c.assert.containsText(tooltipCoordinatesTitle, 'Washington, District of Columbia');+ c.assert.containsText(tooltipCoordinatesLatitude, 'Latitude: 38.8904°');+ c.assert.containsText(tooltipCoordinatesLongitude, 'Longitude: -77.0320°');+ },+ 'Clicking minimize tooltip hides the coordinates dialog': (c) => {+ c.click('.minimize-coordinates-tooltip');+ c.pause(500);+ c.expect.element(tooltipCoordinatesContainer).to.not.be.present;+ },+ 'Coordinate title for no suggested place results displays correct coordinates instead': (c) => {+ c.url(`${c.globals.url}?marker=-51.5,5`);+ c.waitForElementVisible(tooltipCoordinatesContainer, TIME_LIMIT);+ c.expect.element(testMarkerNoDetailsEncodedID).to.be.present;+ c.assert.containsText(tooltipCoordinatesTitle, '5.0000°, -51.5000°');+ c.assert.containsText(tooltipCoordinatesLatitude, 'Latitude: 5.0000°');+ c.assert.containsText(tooltipCoordinatesLongitude, 'Longitude: -51.5000°');+ },+ after(c) {+ c.end();},};diff --git a/e2e/reuseables/selectors.js b/e2e/reuseables/selectors.jsindex 2f1d08fa3..9f4b3c8d0 100644--- a/e2e/reuseables/selectors.js+++ b/e2e/reuseables/selectors.js@@ -128,4 +128,8 @@ module.exports = {geosearchComponent: '.geosearch-component',geosearchMobileDialog: '#toolbar_geosearch_mobile',geosearchMinimizeButton: '.geosearch-search-minimize-button',+ tooltipCoordinatesContainer: '.tooltip-coordinates-container',+ tooltipCoordinatesTitle: '.tooltip-coordinates-title',+ tooltipCoordinatesLatitude: '.tooltip-coordinates-latitude',+ tooltipCoordinatesLongitude: '.tooltip-coordinates-longitude',};diff --git a/web/css/geosearch.css b/web/css/geosearch.cssindex f6525ccf4..aa6529e02 100644--- a/web/css/geosearch.css+++ b/web/css/geosearch.css@@ -35,7 +35,8 @@right: 62px;margin-right: 0;background: none;- & .geosearch-search-submit-button {+ & .geosearch-search-submit-button,+ & .geosearch-search-clear-button {background: none;border: none;color: #999;@@ -54,18 +55,31 @@top: 13px;}}+ & .geosearch-search-clear-button {+ cursor: pointer;+ color: #fff;+ position: absolute;+ top: 0;+ right: 0;+ height: 38px;+ }& svg.svg-inline--fa.fa-exclamation-triangle {color: #d54e21;position: absolute;left: 8px;top: 13px;}+ & svg.svg-inline--fa.fa-times {+ position: absolute;+ left: 10px;+ top: 13px;+ }}/* Geosearch Component */.geosearch-component {position: absolute;- right: 181px;+ right: 182px;top: 10px;width: 350px;margin-right: 1px;@@ -75,36 +89,19 @@}/* Geosearch Component Coordinate Buttons */-.geosearch-coordinate-group-container.grouped .geosearch-coordinate-button-addpoint {- margin-right: 1px;-}--.geosearch-coordinate-button-group {- margin-left: 0.5px;- & .btn {- width: 31px;- border: none;- background: #00457b;- &:focus,- &:hover {- box-shadow: none;- background-color: #eee;- color: #00457b;- }- }-}-.geosearch-coordinate-button-addpoint {border-radius: 0;border-top-right-radius: 5px;border-bottom-right-radius: 5px;-}--.geosearch-coordinate-button-remove svg.svg-inline--fa.fa-slash {- position: absolute;- top: 10px;- left: 6px;- font-size: 1.25em;+ width: 31px;+ border: none;+ background: #00457b;+ &:focus,+ &:hover {+ box-shadow: none;+ background-color: #eee;+ color: #00457b;+ }}/* Geosearch Component Minimize Button */@@ -149,11 +146,18 @@.dark-input,.dark-input:focus {background: none;- background-color: none;color: #fff;box-shadow: none;}+.geosearch-input-alert-icon {+ right: 120px;+}++.geosearch-input-clear-container {+ right: 62px;+}+/* Mobile Styling */@media only screen and (max-width: 768px) {.geosearch-component {@@ -163,6 +167,12 @@.geosearch-input-container {width: 100%;}+ .geosearch-input-clear-container {+ right: 70px;+ }+ .geosearch-input-alert-icon {+ right: 130px;+ }.geosearch-autocomplete {font-size: 16px;&::placeholder {@@ -179,7 +189,7 @@}.geosearch-submit-input-group-addon {margin-right: 6px;- background: #00457b;+ background: none;& .geosearch-search-submit-button {border-left: none;}diff --git a/web/css/tooltip.css b/web/css/tooltip.cssindex f19f45e8e..bbdd37835 100644--- a/web/css/tooltip.css+++ b/web/css/tooltip.css@@ -127,13 +127,20 @@right: 6px;bottom: 6px;}+ & .copy-coordinates-to-clipboard-button {+ position: absolute;+ right: 0;+ bottom: 0;+ height: 20px;+ width: 23px;+ }}.tooltip-coordinates-title {white-space: pre-wrap;word-wrap: break-word;line-height: 17px;font-size: 16px;- padding-right: 23px;+ padding-right: 50px;}.tooltip-coordinates-group {display: flex;@@ -143,15 +150,22 @@padding-right: 26px;}}- .close-tooltip {+ .close-tooltip,+ .minimize-tooltip {margin-left: 8px;border-left: 1px solid #777;- padding-left: 6px;- &.close-coordinates-tooltip {+ &.close-coordinates-tooltip,+ &.minimize-coordinates-tooltip {position: absolute;- top: 4px;+ padding: 3px 0 3px 6px;+ top: 0;+ }+ &.close-coordinates-tooltip {right: 6px;}+ &.minimize-coordinates-tooltip {+ right: 30px;+ }}.svg-inline--fa {width: 12px;diff --git a/web/js/components/geosearch/coordinates-dialog.js b/web/js/components/geosearch/coordinates-dialog.jsindex 66643cb74..d2cfbe0c9 100644--- a/web/js/components/geosearch/coordinates-dialog.js+++ b/web/js/components/geosearch/coordinates-dialog.js@@ -1,9 +1,9 @@/* eslint-disable no-restricted-syntax */import React, { Component } from 'react';import PropTypes from 'prop-types';+import { UncontrolledTooltip } from 'reactstrap';import { CopyToClipboard } from 'react-copy-to-clipboard';import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';-import { faTimes, faCopy } from '@fortawesome/free-solid-svg-icons';import CopyClipboardTooltip from './copy-tooltip';class CoordinatesDialog extends Component {@@ -11,6 +11,7 @@ class CoordinatesDialog extends Component {super(props);this.state = {tooltipToggleTime: 0,+ showTooltips: true,};}@@ -21,9 +22,102 @@ class CoordinatesDialog extends Component {});}+ // close dialog and remove map marker+ clearCoordinates = () => {+ const { clearCoordinates } = this.props;+ this.setState({+ showTooltips: false,+ });+ clearCoordinates();+ }++ // minimize dialog (destroy component)+ minimizeDialog = () => {+ const { removeCoordinatesDialog } = this.props;+ this.setState({+ showTooltips: false,+ });+ removeCoordinatesDialog();+ }++ // render minimize and remove dialog button controls+ renderDialogButtonControls = () => {+ const {+ isMobile,+ } = this.props;+ const { showTooltips } = this.state;++ const closeButtonId = 'close-coordinates-tooltip';+ const minimizeButtonId = 'minimize-coordinates-tooltip';+ const closeButtonLabelText = 'Remove map marker';+ const minimizeButtonLabelText = 'Minimize coordinates tooltip';++ const tooltipVisibilityCondition = !isMobile && showTooltips;+ return (+ <>+ <span id={closeButtonId} className="close-tooltip close-coordinates-tooltip">+ {tooltipVisibilityCondition+ && (+ <UncontrolledTooltip+ trigger="hover"+ target={closeButtonId}+ boundariesElement="window"+ placement="top"+ >+ {closeButtonLabelText}+ </UncontrolledTooltip>+ )}+ <FontAwesomeIcon onClick={this.clearCoordinates} icon="times" fixedWidth />+ </span>+ <span id={minimizeButtonId} className="minimize-tooltip minimize-coordinates-tooltip">+ {tooltipVisibilityCondition+ && (+ <UncontrolledTooltip+ trigger="hover"+ target={minimizeButtonId}+ boundariesElement="window"+ placement="top"+ >+ {minimizeButtonLabelText}+ </UncontrolledTooltip>+ )}+ <FontAwesomeIcon onClick={this.minimizeDialog} icon="minus" fixedWidth />+ </span>+ </>+ );+ }++ // render copy to clipboard button+ renderCopyToClipboardButton = () => {+ const { coordinatesMetadata, isMobile } = this.props;+ const { latitude, longitude } = coordinatesMetadata;++ const buttonId = 'copy-coordinates-to-clipboard-button';+ const labelText = 'Copy coordinates to clipboard';+ return (+ <CopyToClipboard+ options={window.clipboardData ? {} : { format: 'text/plain' }}+ text={`${latitude}, ${longitude}`}+ onCopy={this.onCopyToClipboard}+ >+ <div+ id={buttonId}+ className="copy-coordinates-to-clipboard-button"+ >+ {!isMobile && (+ <UncontrolledTooltip placement="bottom" trigger="hover" target={buttonId}>+ {labelText}+ </UncontrolledTooltip>+ )}+ <FontAwesomeIcon icon="copy" fixedWidth />+ </div>+ </CopyToClipboard>+ );+ }+render() {const {- toggleWithClose, coordinatesMetadata,+ coordinatesMetadata, tooltipId,} = this.props;const {tooltipToggleTime,@@ -37,38 +131,33 @@ class CoordinatesDialog extends Component {const latitudeText = `Latitude: ${latitude}`;const longitudeText = `Longitude: ${longitude}`;+return (- <div className="tooltip-custom-black tooltip-static tooltip-coordinates-container">+ <div className={`tooltip-custom-black tooltip-static tooltip-coordinates-container ${tooltipId}`}><CopyClipboardTooltiptooltipToggleTime={tooltipToggleTime}/><div className="tooltip-coordinates-title">{title}</div><div className="tooltip-coordinates-group">- <div>+ <div className="tooltip-coordinates-latitude">{latitudeText}</div>- <div>+ <div className="tooltip-coordinates-longitude">{longitudeText}</div></div>- <span className="close-tooltip close-coordinates-tooltip" onClick={toggleWithClose}>- <FontAwesomeIcon icon={faTimes} fixedWidth />- </span>- <CopyToClipboard- options={window.clipboardData ? {} : { format: 'text/plain' }}- text={`${latitude}, ${longitude}`}- onCopy={this.onCopyToClipboard}- >- <FontAwesomeIcon id="copy-coordinates-to-clipboard-button" icon={faCopy} fixedWidth />- </CopyToClipboard>+ {this.renderDialogButtonControls()}+ {this.renderCopyToClipboardButton()}</div>);}}-export default CoordinatesDialog;CoordinatesDialog.propTypes = {- toggleWithClose: PropTypes.func,+ clearCoordinates: PropTypes.func,+ removeCoordinatesDialog: PropTypes.func,coordinatesMetadata: PropTypes.object,+ isMobile: PropTypes.bool,+ tooltipId: PropTypes.string,};diff --git a/web/js/components/geosearch/geosearch-input.js b/web/js/components/geosearch/geosearch-input.jsindex beb44452c..eaa754fab 100644--- a/web/js/components/geosearch/geosearch-input.js+++ b/web/js/components/geosearch/geosearch-input.js@@ -1,9 +1,8 @@import React, { Component } from 'react';import PropTypes from 'prop-types';import Autocomplete from 'react-autocomplete';-import { Button, InputGroupAddon } from 'reactstrap';+import { Button, InputGroupAddon, UncontrolledTooltip } from 'reactstrap';import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';-import { faExclamationTriangle, faSearchLocation } from '@fortawesome/free-solid-svg-icons';class SearchBox extends Component {constructor(props) {@@ -82,33 +81,42 @@ class SearchBox extends Component {// render submit buttonrenderSubmitButton = () => {const {- coordinates, inputValue, isMobile,+ inputValue, isMobile,} = this.props;- const hasCoordinates = coordinates.length > 0;- // eslint-disable-next-line no-nested-ternary- const rightPositioning = hasCoordinates- ? isMobile ? '67px' : '60px'- : '30px';+ const buttonId = 'geosearch-search-submit-button';+ const labelText = 'Submit and navigate to location';+ const rightPositioning = '31px';const buttonStyle = inputValue- ? { color: '#0070c8', cursor: 'pointer' }+ ? { background: isMobile ? '#d54e21' : 'none', color: isMobile ? '#fff' : '#d54e21', cursor: 'pointer' }: {};+ const tooltipVisibilityCondition = inputValue && !isMobile;return (<InputGroupAddonclassName="geosearch-submit-input-group-addon"- addonType="append"+ addonType="prepend"style={{right: rightPositioning,}}><Button+ id={buttonId}style={buttonStyle}disabled={!inputValue}onClick={this.handleSubmitClick}className="geosearch-search-submit-button"- title="Search by place name or reverse search using coordinates">- <FontAwesomeIcon icon={faSearchLocation} size="1x" />+ {tooltipVisibilityCondition && (+ <UncontrolledTooltip+ trigger="hover"+ target={buttonId}+ boundariesElement="window"+ placement="bottom"+ >+ {labelText}+ </UncontrolledTooltip>+ )}+ <FontAwesomeIcon icon="search-location" size="1x" /></Button></InputGroupAddon>);@@ -117,25 +125,54 @@ class SearchBox extends Component {// render alert iconrenderAlertIcon = () => {const {- coordinates, isMobile, showExtentAlert,+ showExtentAlert,} = this.props;- const hasCoordinates = coordinates.length > 0;- // eslint-disable-next-line no-nested-ternary- const rightPositioning = hasCoordinates- ? isMobile ? '130px' : '121px'- : '92px';return (showExtentAlert && (<InputGroupAddon- className="geosearch-submit-input-group-addon"+ className="geosearch-submit-input-group-addon geosearch-input-alert-icon"addonType="append"- style={{- right: rightPositioning,- }}title="The entered location is outside of the current map extent.">- <FontAwesomeIcon icon={faExclamationTriangle} size="1x" />+ <FontAwesomeIcon icon="exclamation-triangle" size="1x" />+ </InputGroupAddon>+ )+ );+ }++ // render clear input X+ renderClearInput = () => {+ const {+ inputValue, isMobile, clearInput,+ } = this.props;+ const buttonId = 'geosearch-search-clear-button';+ const labelText = 'Clear search text';+ const tooltipVisibilityCondition = inputValue && !isMobile;++ return (+ inputValue && (+ <InputGroupAddon+ className="geosearch-submit-input-group-addon geosearch-input-clear-container"+ addonType="append"+ >+ <Button+ id={buttonId}+ onClick={clearInput}+ className="geosearch-search-clear-button"+ >+ {tooltipVisibilityCondition && (+ <UncontrolledTooltip+ trigger="hover"+ target={buttonId}+ boundariesElement="window"+ placement="bottom"+ >+ {labelText}+ </UncontrolledTooltip>+ )}+ <FontAwesomeIcon icon="times" size="1x" />+ </Button></InputGroupAddon>));@@ -144,18 +181,21 @@ class SearchBox extends Component {// condtional autocomplete wrapper stylinggetWrapperStyle = () => {const {- coordinates,isMobile,showExtentAlert,+ inputValue,} = this.props;- const hasCoordinates = coordinates.length > 0;- const wrapperStyleWidth = hasCoordinates ? '268px' : '299px';++ // handle mobile/desktop input padding with/without alert+ const paddingRightStyle = inputValue+ ? showExtentAlert+ ? isMobile ? '68px' : '84px'+ : isMobile ? '42px' : '60px'+ : '0';+return {- width: isMobile ? '90%' : wrapperStyleWidth,- // eslint-disable-next-line no-nested-ternary- paddingRight: isMobile- ? '0'- : showExtentAlert ? '53px' : '26px',+ width: isMobile ? '90%' : '298px',+ paddingRight: paddingRightStyle,};}@@ -193,6 +233,7 @@ class SearchBox extends Component {renderMenu={this.renderMenu}renderItem={this.renderItem}/>+ {this.renderClearInput()}{this.renderAlertIcon()}{this.renderSubmitButton()}</div>@@ -201,7 +242,7 @@ class SearchBox extends Component {}SearchBox.propTypes = {- coordinates: PropTypes.array,+ clearInput: PropTypes.func,coordinatesPending: PropTypes.array,onCoordinateInputSelect: PropTypes.func,searchResults: PropTypes.array,diff --git a/web/js/components/geosearch/geosearch-modal.js b/web/js/components/geosearch/geosearch-modal.jsindex 5c947a8ec..83edcd523 100644--- a/web/js/components/geosearch/geosearch-modal.js+++ b/web/js/components/geosearch/geosearch-modal.js@@ -1,7 +1,7 @@import PropTypes from 'prop-types';import React, { Component } from 'react';import {- ButtonGroup, Button, InputGroup, InputGroupAddon,+ Button, InputGroup, InputGroupAddon, UncontrolledTooltip,} from 'reactstrap';import {throttle as lodashThrottle,@@ -9,10 +9,6 @@ import {} from 'lodash';import googleTagManager from 'googleTagManager';import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';-import {- faMapMarkerAlt,- faSlash,-} from '@fortawesome/free-solid-svg-icons';import SearchBox from './geosearch-input';import Alert from '../util/alert';@@ -32,13 +28,14 @@ class SearchComponent extends Component {componentDidUpdate(prevProps) {const { coordinates } = this.props;- const { showReverseGeocodeAlert } = this.state;+ const { showExtentAlert, showReverseGeocodeAlert } = this.state;- if (showReverseGeocodeAlert && coordinates.length > 0) {+ if ((showReverseGeocodeAlert || showExtentAlert) && coordinates.length > 0) {const [prevLong, prevLat] = prevProps.coordinates;const [long, lat] = coordinates;if (prevLong !== long || prevLat !== lat) {this.dismissReverseGeocodeAlert();+ this.setExtentAlert(false);}}}@@ -146,6 +143,19 @@ class SearchComponent extends Component {}}+ // clear text input and search results+ clearInput = () => {+ const {+ updateSearchResults, updateValue,+ } = this.props;+ updateValue('');+ updateSearchResults([]);+ this.setState({+ showReverseGeocodeAlert: false,+ showExtentAlert: false,+ });+ }+// initiate instruction alert and activate store level toggleReverseGeocodeActiveinitReverseGeocode = (e) => {e.preventDefault();@@ -163,12 +173,19 @@ class SearchComponent extends Component {});}- // clear selected marker/coordinates from map- clearCoordinatesMarker = (e) => {- e.preventDefault();- e.stopPropagation();- const { clearCoordinates } = this.props;- clearCoordinates();+ // render hover tooltip+ renderTooltip = (buttonId, labelText) => {+ const { isMobile } = this.props;+ return !isMobile && (+ <UncontrolledTooltip+ trigger="hover"+ target={buttonId}+ boundariesElement="window"+ placement="bottom"+ >+ {labelText}+ </UncontrolledTooltip>+ );}// render alert message to instruct user map interaction@@ -214,59 +231,38 @@ class SearchComponent extends Component {// render geosearch component minimize button (not visible in mobile)renderMinimizeButton = () => {const { toggleShowGeosearch } = this.props;+ const buttonId = 'geosearch-search-minimize-button';+ const labelText = 'Hide Geosearch';return (<InputGroupAddon addonType="prepend"><Button+ id={buttonId}className="geosearch-search-minimize-button"- title="Minimize search box"onClick={toggleShowGeosearch}>+ {this.renderTooltip(buttonId, labelText)}<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' };+ // render add coordinate marker button for reverse geocode+ renderAddCoordinateButton = () => {+ const addCoordinateButtonId = 'geosearch-coordinate-button-addpoint';+ const addCoordinateLabelText = 'Add marker on map';return (- <InputGroupAddon- addonType="append"- className={containerClass}- >- <ButtonGroup- className="geosearch-coordinate-button-group"+ <InputGroupAddon addonType="append">+ <Button+ id={addCoordinateButtonId}+ onTouchEnd={this.initReverseGeocode}+ onMouseDown={this.initReverseGeocode}+ className="geosearch-coordinate-button-addpoint">- <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>+ {this.renderTooltip(addCoordinateButtonId, addCoordinateLabelText)}+ <FontAwesomeIcon icon="map-marker-alt" size="1x" />+ </Button></InputGroupAddon>);}@@ -295,6 +291,7 @@ class SearchComponent extends Component {{/* Minimize button not visible in mobile */}{!isMobile && this.renderMinimizeButton()}<SearchBox+ clearInput={this.clearInput}coordinates={coordinates}coordinatesPending={coordinatesPending}inputValue={inputValue}@@ -307,8 +304,8 @@ class SearchComponent extends Component {isMobile={isMobile}showExtentAlert={showExtentAlert}/>- {/* Coordinate button group */}- {this.renderCoordinateButtonGroup()}+ {/* Add coordinate marker button */}+ {this.renderAddCoordinateButton()}</InputGroup></div></>@@ -317,7 +314,6 @@ class SearchComponent extends Component {}SearchComponent.propTypes = {- clearCoordinates: PropTypes.func,coordinates: PropTypes.array,coordinatesPending: PropTypes.array,geosearchMobileModalOpen: PropTypes.bool,diff --git a/web/js/components/geosearch/ol-coordinates-marker-util.js b/web/js/components/geosearch/ol-coordinates-marker-util.jsindex 28d83f70b..d456fa44a 100644--- a/web/js/components/geosearch/ol-coordinates-marker-util.js+++ b/web/js/components/geosearch/ol-coordinates-marker-util.js@@ -12,7 +12,7 @@ import util from '../../util/util';* @param {String} coordinate* @returns {Number} parsed coordinate with modified precision*/-function getCoordinateDisplayPrecision(coordinate) {+const getCoordinateDisplayPrecision = (coordinate) => {const coordinateNumber = Number(coordinate);const coordinatePrecision = Math.abs(coordinateNumber) > 100? 7@@ -21,18 +21,76 @@ function getCoordinateDisplayPrecision(coordinate) {: 6;return parseFloat(coordinateNumber.toPrecision(coordinatePrecision));-}+};++/**+ * getFormattedCoordinates+ *+ * @param {String} latitude+ * @param {String} longitude+ *+ * @returns {Array} formattedCoordinates+ */+const getFormattedCoordinates = (latitude, longitude) => {+ const parsedLatitude = getCoordinateDisplayPrecision(latitude);+ const parsedLongitude = getCoordinateDisplayPrecision(longitude);++ // format coordinates based on localStorage preference+ const format = util.getCoordinateFormat();+ const coordinates = util.formatCoordinate(+ [parsedLongitude, parsedLatitude],+ format,+ );+ const formattedCoordinates = coordinates.split(',');+ return formattedCoordinates;+};++/**+ * getCoordinatesDialogTitle+ *+ * @param {Object} address+ * @param {Object} error+ * @param {String} formattedLatitude+ * @param {String} formattedLongitude+ *+ * @returns {String} title+ */+const getCoordinatesDialogTitle = (address, error, formattedLatitude, formattedLongitude) => {+ let title;+ if (error) {+ title = `${formattedLatitude.trim()}, ${formattedLongitude.trim()}`;+ } else if (address) {+ /* eslint-disable camelcase */+ const {+ Addr_type,+ Match_addr,+ ShortLabel,+ City,+ Region,+ } = address;+ if (Addr_type === 'PointAddress') {+ title = `${ShortLabel}, ${City}, ${Region}`;+ } else if (City && Region) {+ title = `${City}, ${Region}`;+ } else {+ title = `${Match_addr}`;+ }+ }+ return title;+};/*** Create tooltip React DOM element** @param {Object} map+ * @param {Object} config* @param {Array} coordinates* @param {Object} coordinatesMetadata+ * @param {Boolean} isMobile** @returns {Void}*/-export function renderTooltip(map, config, coordinates, coordinatesMetadata) {+export const renderCoordinatesTooltip = (map, config, coordinates, coordinatesMetadata, isMobile, clearCoordinates) => {const { projections } = config;const { proj } = map;const { crs } = projections[proj];@@ -40,7 +98,7 @@ export function renderTooltip(map, config, coordinates, coordinatesMetadata) {// create tooltip overlayconst tooltipElement = document.createElement('div');- const tooltipId = `coordinates-map-marker-${latitude},${longitude}`;+ const tooltipId = util.encodeId(`coordinates-map-marker_${latitude},${longitude}`);const tooltipOverlay = new Overlay({id: tooltipId,element: tooltipElement,@@ -61,18 +119,21 @@ export function renderTooltip(map, config, coordinates, coordinatesMetadata) {map.addOverlay(tooltipOverlay);tooltipOverlay.setPosition(coordinatesPosition);- // helper function to remove tooltip overlay- const removeTooltip = () => {+ // helper function to remove/hide tooltip overlay+ const removeCoordinatesDialog = () => {map.removeOverlay(tooltipOverlay);};ReactDOM.render((<CoordinatesDialogcoordinatesMetadata={coordinatesMetadata}- toggleWithClose={removeTooltip}+ removeCoordinatesDialog={removeCoordinatesDialog}+ clearCoordinates={clearCoordinates}+ isMobile={isMobile}+ tooltipId={tooltipId}/>), tooltipOverlay.getElement());-}+};/*** getCoordinatesMetadata for tooltip display@@ -81,60 +142,34 @@ export function renderTooltip(map, config, coordinates, coordinatesMetadata) {** @returns {Object} coordinatesMetadata*/-export function getCoordinatesMetadata(geocodeProperties) {+export const getCoordinatesMetadata = (geocodeProperties) => {const { latitude, longitude, reverseGeocodeResults } = geocodeProperties;const { address, error } = reverseGeocodeResults;- const parsedLatitude = getCoordinateDisplayPrecision(latitude);- const parsedLongitude = getCoordinateDisplayPrecision(longitude);-- // build title and metadata based on available parameters- let title;- if (error) {- title = `${parsedLatitude}, ${parsedLongitude}`;- } else if (address) {- /* eslint-disable camelcase */- const {- Addr_type,- Match_addr,- ShortLabel,- City,- Region,- } = address;- if (Addr_type === 'PointAddress') {- title = `${ShortLabel}, ${City}, ${Region}`;- } else if (City && Region) {- title = `${City}, ${Region}`;- } else {- title = `${Match_addr}`;- }- }+ // get formatted coordinates+ const [formattedLatitude, formattedLongitude] = getFormattedCoordinates(latitude, longitude);- // 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;+ // build title based on available parameters+ const title = getCoordinatesDialogTitle(address, error, formattedLatitude, formattedLongitude);return {latitude: formattedLatitude.trim(),longitude: formattedLongitude.trim(),title,};-}+};/*** Get coordinate dialog feature at clicked map pixel** @param {Array} pixels* @param {Object} map+ * @param {Object} config+ * @param {Boolean} isMobile** @returns {Void}*/-export function getCoordinatesDialogAtMapPixel(pixels, map, config) {+export const getCoordinatesDialogAtMapPixel = (pixels, map, config, isMobile, clearCoordinates) => {// check for existing coordinate marker tooltip overlay and prevent multiple rendersconst mapOverlays = map.getOverlays().getArray();const coordinatesTooltipOverlay = mapOverlays.filter((overlay) => {@@ -155,7 +190,7 @@ export function getCoordinatesDialogAtMapPixel(pixels, map, config) {const coordinatesMetadata = getCoordinatesMetadata(featureProperties);// create tooltip overlay React DOM element- renderTooltip(map, config, [latitude, longitude], coordinatesMetadata);+ renderCoordinatesTooltip(map, config, [latitude, longitude], coordinatesMetadata, isMobile, clearCoordinates);}});-}+};diff --git a/web/js/components/geosearch/ol-coordinates-marker.js b/web/js/components/geosearch/ol-coordinates-marker.jsindex 2f4f5c0a0..d2e61dd0c 100644--- a/web/js/components/geosearch/ol-coordinates-marker.js+++ b/web/js/components/geosearch/ol-coordinates-marker.js@@ -7,6 +7,7 @@ import PropTypes from 'prop-types';import { transform } from 'ol/proj';import { changeCursor as changeCursorActionCreator } from '../../modules/map/actions';import { getCoordinatesDialogAtMapPixel } from './ol-coordinates-marker-util';+import { clearCoordinates } from '../../modules/geosearch/actions';export class CoordinatesInteractions extends React.Component {constructor(props) {@@ -56,12 +57,21 @@ export class CoordinatesInteractions extends React.Component {singleClick(e, map) {e.stopPropagation();const {- getCoordinatesDialog, measureIsActive,+ measureIsActive,} = this.props;if (measureIsActive) return;const pixels = e.pixel;- getCoordinatesDialog(pixels, map);+ this.getCoordinatesDialog(pixels, map);+ }++ getCoordinatesDialog = (pixels, olMap) => {+ const {+ config,+ clearCoordinates,+ isMobile,+ } = this.props;+ getCoordinatesDialogAtMapPixel(pixels, olMap, config, isMobile, clearCoordinates);}render() {@@ -71,28 +81,36 @@ export class CoordinatesInteractions extends React.Component {function mapStateToProps(state) {const {+ browser,config,map,measure,geosearch,} = state;const { coordinates } = geosearch;+ const isMobile = browser.lessThan.medium;return {+ config,map,coordinates,+ isMobile,isShowingClick: map.isClickable,- getCoordinatesDialog: (pixels, olMap) => getCoordinatesDialogAtMapPixel(pixels, olMap, config),measureIsActive: measure.isActive,};} const mapDispatchToProps = (dispatch) => ({changeCursor: (bool) => {dispatch(changeCursorActionCreator(bool));},+ clearCoordinates: () => {+ dispatch(clearCoordinates());+ },});CoordinatesInteractions.propTypes = {changeCursor: PropTypes.func.isRequired,- getCoordinatesDialog: PropTypes.func.isRequired,+ config: PropTypes.object.isRequired,+ clearCoordinates: PropTypes.func.isRequired,+ isMobile: PropTypes.bool.isRequired,isShowingClick: PropTypes.bool.isRequired,measureIsActive: PropTypes.bool.isRequired,mouseEvents: PropTypes.object.isRequired,diff --git a/web/js/containers/image-download.js b/web/js/containers/image-download.jsindex ed833e439..5105a71f6 100644--- a/web/js/containers/image-download.js+++ b/web/js/containers/image-download.js@@ -16,6 +16,7 @@ import {hasSubDaily as hasSubDailySelector,getLayers,} from '../modules/layers/selectors';+import { removeCoordinatesOverlayFromAllProjections } from '../modules/geosearch/selectors';import {resolutionsGeo,resolutionsPolar,@@ -179,6 +180,11 @@ function mapStateToProps(state) {util.warn(`Redirecting image download to: ${url}`);}+ if (markerCoordinates.length > 0) {+ // clear coordinates dialog for image crop panel+ removeCoordinatesOverlayFromAllProjections(map.ui.proj);+ }+return {proj,url,diff --git a/web/js/containers/toolbar.js b/web/js/containers/toolbar.jsindex def5e8952..8a1799567 100644--- a/web/js/containers/toolbar.js+++ b/web/js/containers/toolbar.js@@ -161,7 +161,8 @@ class toolbarContainer extends Component {}renderShareButton() {- const { openModal, isDistractionFreeModeActive } = this.props;+ const { openModal, isDistractionFreeModeActive, isMobile } = this.props;+ const faSize = isMobile ? '2x' : '1x';const buttonId = 'wv-link-button';const labelText = 'Share this map';return !isDistractionFreeModeActive && (@@ -175,13 +176,16 @@ class toolbarContainer extends Component {)}>{this.renderTooltip(buttonId, labelText)}- <FontAwesomeIcon icon="share-square" size="2x" />+ <FontAwesomeIcon icon="share-square" size={faSize} /></Button>);}renderProjectionButton() {- const { config, openModal, isDistractionFreeModeActive } = this.props;+ const {+ config, openModal, isDistractionFreeModeActive, isMobile,+ } = this.props;+ const faSize = isMobile ? '2x' : '1x';const buttonId = 'wv-proj-button';const labelText = 'Switch projection';return config.ui && config.ui.projections && !isDistractionFreeModeActive && (@@ -195,7 +199,7 @@ class toolbarContainer extends Component {)}>{this.renderTooltip(buttonId, labelText)}- <FontAwesomeIcon icon="globe-asia" size="2x" />+ <FontAwesomeIcon icon="globe-asia" size={faSize} /></Button>);}@@ -212,6 +216,8 @@ class toolbarContainer extends Component {} = this.props;const { features: { geocodeSearch: isFeatureEnabled } } = config;const faSize = isMobile ? '2x' : '1x';+ const buttonId = 'wv-geosearch-button';+ const labelText = 'Search places by location';// do not render if geosearch feature isn't enabledif (!isFeatureEnabled) {@@ -231,12 +237,13 @@ class toolbarContainer extends Component {style={{display: buttonDisplayConditions ? 'inline-block' : 'none',}}- type="button"- id="wv-geosearch-button"+ id={buttonId}className="wv-toolbar-button"+ aria-label={labelText}title="Search by place name or reverse search using coordinates"onClick={handleButtonClick}>+ {this.renderTooltip(buttonId, labelText)}<FontAwesomeIcon icon="search-location" size={faSize} /></Button>);@@ -247,6 +254,7 @@ class toolbarContainer extends Component {isImageDownloadActive,isCompareActive,isDistractionFreeModeActive,+ isMobile,} = this.props;const buttonId = 'wv-image-button';const labelText = isCompareActive@@ -254,6 +262,7 @@ 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">@@ -269,7 +278,7 @@ class toolbarContainer extends Component {aria-label={labelText}onClick={this.openImageDownload}>- <FontAwesomeIcon icon="camera" size="2x" />+ <FontAwesomeIcon icon="camera" size={faSize} /></Button></div>@@ -282,10 +291,12 @@ class toolbarContainer extends Component {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';@@ -301,7 +312,7 @@ class toolbarContainer extends Component {data-content={notificationContentNumber}>{this.renderTooltip(buttonId, labelText)}- <FontAwesomeIcon icon="info-circle" size="2x" />+ <FontAwesomeIcon icon="info-circle" size={faSize} /></Button>);}@@ -313,8 +324,8 @@ class toolbarContainer extends Component {id="wv-toolbar"className="wv-toolbar">- {this.renderShareButton()}{this.renderGeosearchButtonComponent()}+ {this.renderShareButton()}{this.renderProjectionButton()}{this.renderSnapshotsButton()}{this.renderInfoButton()}diff --git a/web/js/font-awesome-library.js b/web/js/font-awesome-library.jsindex 74b2a69b1..a80220b5d 100644--- a/web/js/font-awesome-library.js+++ b/web/js/font-awesome-library.js@@ -35,6 +35,7 @@ import {faCircle,faClock,faCode,+ faCopy,faDownload,faEnvelope,faExclamationCircle,@@ -52,6 +53,7 @@ import {faInfoCircle,faLayerGroup,faMap,+ faMapMarkerAlt,faMinus,faMeteor,faPause,@@ -65,6 +67,7 @@ import {faSearchLocation,faShareSquare,faSlidersH,+ faSlash,faTimes,faTrash,faTruck,@@ -94,6 +97,7 @@ library.add(faCircle,faClock,faCode,+ faCopy,faDownload,faEnvelope,faExclamationCircle,@@ -114,6 +118,7 @@ library.add(faInfoCircle,faLayerGroup,faMap,+ faMapMarkerAlt,faMinus,faMeteor,faPause,@@ -128,6 +133,7 @@ library.add(faSearchLocation,faShareSquare,faSlidersH,+ faSlash,faTimes,faTrash,faTruck,diff --git a/web/js/map/ui.js b/web/js/map/ui.jsindex e4bb68e8a..b9ef6eeeb 100644--- a/web/js/map/ui.js+++ b/web/js/map/ui.js@@ -34,7 +34,7 @@ import { mapUtilZoomAction, getActiveLayerGroup } from './util';import mapCompare from './compare/compare';import { LOCATION_POP_ACTION } from '../redux-location-state-customs';import { CHANGE_PROJECTION } from '../modules/projection/constants';-import { UPDATE_ACTIVE_MARKER } from '../modules/geosearch/constants';+import { CLEAR_COORDINATES, UPDATE_ACTIVE_MARKER } from '../modules/geosearch/constants';import { SELECT_DATE } from '../modules/date/constants';import util from '../util/util';import * as layerConstants from '../modules/layers/constants';@@ -55,8 +55,8 @@ import { getLeadingExtent } from '../modules/map/util';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';+import { addCoordinatesMarker, reverseGeocode, removeCoordinatesMarker } from '../modules/geosearch/selectors';+import { getCoordinatesMetadata, renderCoordinatesTooltip } from '../components/geosearch/ol-coordinates-marker-util';export default function mapui(models, config, store, ui) {const id = 'wv-map';@@ -231,13 +231,27 @@ export default function mapui(models, config, store, ui) {* @returns {void}*/const addMarkerAndUpdateStore = (activeMarker, coordinates, results) => {+ const state = store.getState();+ const { browser } = state;+ const isMobile = browser.lessThan.medium;const marker = addCoordinatesMarker(activeMarker, config, { ui: self }, coordinates, results);+ // prevent marker if outside of extent+ if (!marker) {+ return false;+ }+// handle render initial tooltipconst [longitude, latitude] = coordinates;const geocodeProperties = { latitude, longitude, reverseGeocodeResults: results };const coordinatesMetadata = getCoordinatesMetadata(geocodeProperties);- renderTooltip(self.selected, config, [latitude, longitude], coordinatesMetadata);++ // handle clearing cooridnates using created marker+ const clearCoordinates = () => {+ removeCoordinatesMarker(marker, { ui: self });+ store.dispatch({ type: CLEAR_COORDINATES });+ };+ renderCoordinatesTooltip(self.selected, config, [latitude, longitude], coordinatesMetadata, isMobile, clearCoordinates);store.dispatch({ type: UPDATE_ACTIVE_MARKER, value: marker, reverseGeocodeResults: results });};diff --git a/web/js/modules/geosearch/actions.js b/web/js/modules/geosearch/actions.jsindex 4cf318fa4..185777d86 100644--- a/web/js/modules/geosearch/actions.js+++ b/web/js/modules/geosearch/actions.js@@ -12,8 +12,9 @@ import {} from './selectors';import { getMaxZoomLevelLayerCollection } from '../layers/selectors';import { setLocalStorageCollapseState } from './util';-import { getCoordinatesMetadata, renderTooltip } from '../../components/geosearch/ol-coordinates-marker-util';+import { getCoordinatesMetadata, renderCoordinatesTooltip } from '../../components/geosearch/ol-coordinates-marker-util';+// toggle show geosearch componentexport function toggleShowGeosearch() {return (dispatch, getState) => {const state = getState();@@ -31,6 +32,7 @@ export function toggleShowGeosearch() {};}+// toggle reverse geocode - if active, next click on map will add marker and get coordinatesexport function toggleReverseGeocodeActive(isCoordinateSearchActive) {return {type: TOGGLE_REVERSE_GEOCODE_ACTIVE,@@ -38,15 +40,17 @@ export function toggleReverseGeocodeActive(isCoordinateSearchActive) {};}+// use given coordinates to fly to that point, add marker, and display initial coordinates dialogexport function selectCoordinatesToFly(coordinates, reverseGeocodeResults) {return (dispatch, getState) => {const state = getState();const {- config, geosearch, map, layers, proj,+ browser, config, geosearch, map, layers, proj,} = state;const { sources } = config;const { active } = layers;const { activeMarker } = geosearch;+ const isMobile = browser.lessThan.medium;if (reverseGeocodeResults) {const { error } = reverseGeocodeResults;@@ -65,17 +69,28 @@ export function selectCoordinatesToFly(coordinates, reverseGeocodeResults) {activeMarker: null,});}++ // fly to coordinates and render coordinates tooltipconst zoom = map.ui.selected.getView().getZoom();const activeLayers = active.filter((layer) => layer.projections[proj.id] !== undefined);const maxZoom = getMaxZoomLevelLayerCollection(activeLayers, zoom, proj.id, sources);-animateCoordinates(map, config, coordinates, maxZoom);// handle render initial tooltipconst [longitude, latitude] = coordinates;- const geocodeProperties = { latitude, longitude, reverseGeocodeResults };+ const geocodeProperties = {+ latitude,+ longitude,+ reverseGeocodeResults,+ };const coordinatesMetadata = getCoordinatesMetadata(geocodeProperties);- renderTooltip(map.ui.selected, config, [latitude, longitude], coordinatesMetadata);+ const clearMarkerAndCoordinates = () => {+ removeCoordinatesMarker(marker, map);+ dispatch({+ type: CLEAR_COORDINATES,+ });+ };+ renderCoordinatesTooltip(map.ui.selected, config, [latitude, longitude], coordinatesMetadata, isMobile, clearMarkerAndCoordinates);dispatch({type: SELECT_COORDINATES_TO_FLY,@@ -87,6 +102,7 @@ export function selectCoordinatesToFly(coordinates, reverseGeocodeResults) {};}+// clear coordinates including marker and dialog (if open), adding new marker will clear any active markerexport function clearCoordinates() {return (dispatch, getState) => {const state = getState();diff --git a/web/js/modules/geosearch/selectors.js b/web/js/modules/geosearch/selectors.jsindex 1596f5827..6892bd132 100644--- a/web/js/modules/geosearch/selectors.js+++ b/web/js/modules/geosearch/selectors.js@@ -9,59 +9,81 @@ import {import { containsXY } from 'ol/extent';import { coordinatesCRSTransform } from '../projection/util';+// animate coordinates markerexport function animateCoordinates(map, config, coordinates, zoom) {const { projections } = config;const { selected } = map.ui;const { proj } = selected;const { crs } = projections[proj];- let targetCoordinates = coordinates;+ let [x, y] = coordinates;if (proj !== 'geographic') {- targetCoordinates = coordinatesCRSTransform(coordinates, 'EPSG:4326', crs);+ [x, y] = coordinatesCRSTransform(coordinates, 'EPSG:4326', crs);}- map.ui.animate.fly(targetCoordinates, zoom);+ map.ui.animate.fly([x, y], zoom);}+// check if coordinates are within selected map extentexport function areCoordinatesWithinExtent(map, config, coordinates) {const { projections } = config;const { selected } = map.ui;const { proj } = selected;const { maxExtent, crs } = projections[proj];- let coordinatesWithinExtent;+ let [x, y] = coordinates;if (proj !== 'geographic') {- const transformedCoordinates = coordinatesCRSTransform(coordinates, 'EPSG:4326', crs);- coordinatesWithinExtent = containsXY(maxExtent, transformedCoordinates[0], transformedCoordinates[1]);- } else {- coordinatesWithinExtent = containsXY(maxExtent, coordinates[0], coordinates[1]);+ const transformedXY = coordinatesCRSTransform(coordinates, 'EPSG:4326', crs);+ [x, y] = transformedXY;}+ const coordinatesWithinExtent = containsXY(maxExtent, x, y);return coordinatesWithinExtent;}+// add coordinates markerexport function addCoordinatesMarker(activeMarker, config, map, coordinates, reverseGeocodeResults) {const { projections } = config;const { selected } = map.ui;const { proj } = selected;const { crs } = projections[proj];+ // remove any markersremoveCoordinatesMarker(activeMarker, map);+ // only add marker within current map extentconst coordinatesWithinExtent = areCoordinatesWithinExtent(map, config, coordinates);if (!coordinatesWithinExtent) {return false;}+ // transform coordinates if not CRS EPSG:4326let transformedCoordinates = false;if (proj !== 'geographic') {transformedCoordinates = coordinatesCRSTransform(coordinates, 'EPSG:4326', crs);}+ // create Ol vector layer map pinconst marker = createPin(coordinates, transformedCoordinates, reverseGeocodeResults);selected.addLayer(marker);selected.renderSync();return marker;}+// remove coordinates tooltip from all projections+export function removeCoordinatesOverlayFromAllProjections(proj) {+ const mapProjections = Object.keys(proj);+ mapProjections.forEach((mapProjection) => {+ const mapOverlays = proj[mapProjection].getOverlays().getArray();+ const coordinatesTooltipOverlay = mapOverlays.filter((overlay) => {+ const { id } = overlay;+ return id && id.includes('coordinates-map-marker');+ });+ if (coordinatesTooltipOverlay.length > 0) {+ proj[mapProjection].removeOverlay(coordinatesTooltipOverlay[0]);+ }+ });+}++// remove coordinates markerexport function removeCoordinatesMarker(activeMarker, map) {const { selected, proj } = map.ui;// remove marker@@ -69,23 +91,11 @@ export function removeCoordinatesMarker(activeMarker, map) {activeMarker.setMap(null);selected.removeLayer(activeMarker);}- // remove tooltip- const removeOverlayFromAllProjections = () => {- const mapProjections = Object.keys(proj);- mapProjections.forEach((mapProjection) => {- const mapOverlays = proj[mapProjection].getOverlays().getArray();- const coordinatesTooltipOverlay = mapOverlays.filter((overlay) => {- const { id } = overlay;- return id && id.includes('coordinates-map-marker');- });- if (coordinatesTooltipOverlay.length > 0) {- proj[mapProjection].removeOverlay(coordinatesTooltipOverlay[0]);- }- });- };- removeOverlayFromAllProjections();+ // remove tooltip from all projections+ removeCoordinatesOverlayFromAllProjections(proj);}+// create Ol vector layer map pinconst createPin = function(coordinates, transformedCoordinates = false, reverseGeocodeResults = {}) {const [longitude, latitude] = coordinates;const iconFeature = new OlFeature({@@ -145,6 +155,7 @@ const GEOCODE_SUGGEST_CATEGORIES = ['Government Office','Business Facility','Primary Postal',+ 'Airport',];export async function suggest(val) {diff --git a/web/js/modules/geosearch/util.js b/web/js/modules/geosearch/util.jsindex 29d36dca2..c8e94fae5 100644--- a/web/js/modules/geosearch/util.js+++ b/web/js/modules/geosearch/util.js@@ -14,7 +14,7 @@ export function mapLocationToGeosearchState() {const { marker } = parameters;const coordinates = marker- ? marker.split(',')+ ? marker.split(',').map((coord) => Number(coord)): [];const isMobile = state.browser.lessThan.medium;diff --git a/web/js/util/util.js b/web/js/util/util.jsindex 6fe83e1b8..7469b7f11 100644--- a/web/js/util/util.js+++ b/web/js/util/util.js@@ -903,7 +903,7 @@ export default (function(self) {// Converts a string to a form that can be safely used as an identifier.//- // Currently only converts '.' and ':' to __xx__ where xx is the hex+ // Currently only converts '.' and ':' and ',' to __xx__ where xx is the hex// value of that character. Add more here as needed.//// When GIBS added the 'Particulate_Matter_Below_2.5micrometers_2001-2010'@@ -917,7 +917,7 @@ export default (function(self) {// became confusing as element attributes would need one escape character// but the selector would need two (\. vs \\.)self.encodeId = function(str) {- return str.replace(/[.:]/g, (match) => `__${match.charCodeAt(0).toString(16).toUpperCase()}__`);+ return str.replace(/[.:,]/g, (match) => `__${match.charCodeAt(0).toString(16).toUpperCase()}__`);};// Converts an encoded identifier back to its original value.