Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-1931-hotfix (#3852)

Jason Hurleyac89e107ce6e
diff --git a/e2e/features/location-search/location-search-test.js b/e2e/features/location-search/location-search-test.js
index 8841bee2e..39a6d8758 100644
--- a/e2e/features/location-search/location-search-test.js
+++ b/e2e/features/location-search/location-search-test.js
@@ -2,7 +2,7 @@ const reuseables = require('../../reuseables/skip-tour.js');
const localSelectors = require('../../reuseables/selectors.js');
// encoded id; originally coordinates-map-marker_38.8904,-77.032
-const testMarkerEncodedID = '.coordinates-map-marker_38__2E__8904__2C__-77__2E__032';
+const testMarkerEncodedID = '.coordinates-map-marker_-77__2E__032__2C__38__2E__8904';
const TIME_LIMIT = 10000;
const {
diff --git a/web/js/components/location-search/location-marker.js b/web/js/components/location-search/location-marker.js
index b4e98a924..d870feaec 100644
--- a/web/js/components/location-search/location-marker.js
+++ b/web/js/components/location-search/location-marker.js
@@ -7,9 +7,9 @@ import { getCoordinatesMetadata } from './ol-coordinates-marker-util';
export default function LocationMarker ({
reverseGeocodeResults, removeMarker, coordinatesObject, isMobile, dialogVisible = true,
}) {
- const coordinates = [coordinatesObject.latitude, coordinatesObject.longitude];
+ const coordinates = [coordinatesObject.longitude, coordinatesObject.latitude];
const [latitude, longitude] = coordinates;
- const tooltipId = util.encodeId(`coordinates-map-marker_${latitude},${longitude}`);
+ const tooltipId = util.encodeId(`coordinates-map-marker_${longitude},${latitude}`);
const geocodeProperties = { latitude, longitude, reverseGeocodeResults };
const coordinatesMetadata = getCoordinatesMetadata(geocodeProperties);
const [showDialog, setShowDialog] = useState(dialogVisible);
diff --git a/web/js/components/location-search/location-search-modal.js b/web/js/components/location-search/location-search-modal.js
index 99433d4bb..b5c4cf57d 100644
--- a/web/js/components/location-search/location-search-modal.js
+++ b/web/js/components/location-search/location-search-modal.js
@@ -188,7 +188,7 @@ class LocationSearchModal extends Component {
const coordinatesInputValue = isValidCoordinates(value);
if (coordinatesInputValue) {
this.debounceGetSuggestions.cancel();
- const { latitude, longitude } = coordinatesInputValue;
+ const { longitude, latitude } = coordinatesInputValue;
this.clearAlerts();
clearSuggestions();
updatePendingCoordinates([longitude, latitude]);
diff --git a/web/js/map/ui.js b/web/js/map/ui.js
index d4bcb00e8..2e861d352 100644
--- a/web/js/map/ui.js
+++ b/web/js/map/ui.js
@@ -85,7 +85,7 @@ export default function mapui(models, config, store, ui) {
proj: {}, // One map for each projection
selected: null, // The map for the selected projection
selectedVectors: {},
- activeMarker: null,
+ markers: [],
runningdata,
layerKey,
createLayer,
@@ -106,6 +106,9 @@ export default function mapui(models, config, store, ui) {
case REMOVE_MARKER:
return removeCoordinatesMarker(action.coordinates);
case SET_MARKER: {
+ if (action.flyToExistingMarker) {
+ return flyToMarker(action.coordinates);
+ }
return addMarkerAndUpdateStore(true, action.reverseGeocodeResults, action.isCoordinatesSearchActive, action.coordinates);
}
case TOGGLE_DIALOG_VISIBLE:
@@ -235,6 +238,40 @@ export default function mapui(models, config, store, ui) {
updateProjection(true);
};
+
+
+ /*
+ * Remove coordinates marker from all projections
+ *
+ * @method removeCoordinatesMarker
+ * @static
+ *
+ * @returns {void}
+ */
+ const removeCoordinatesMarker = (coordinatesObject) => {
+ self.markers.forEach((marker) => {
+ if (marker.id === coordinatesObject.id) {
+ marker.setMap(null);
+ self.selected.removeOverlay(marker);
+ }
+ });
+ };
+
+ /*
+ * Remove all coordinates markers
+ *
+ * @method removeAllCoordinatesMarkers
+ * @static
+ *
+ * @returns {void}
+ */
+ const removeAllCoordinatesMarkers = () => {
+ self.markers.forEach((marker) => {
+ marker.setMap(null);
+ self.selected.removeOverlay(marker);
+ });
+ };
+
/*
* Handle reverse geocode and add map marker with results
*
@@ -247,6 +284,7 @@ export default function mapui(models, config, store, ui) {
const state = store.getState();
const { locationSearch, proj } = state;
const { coordinates } = locationSearch;
+ removeAllCoordinatesMarkers();
if (coordinates && coordinates.length > 0) {
coordinates.forEach((coordinatesObject) => {
const latestCoordinates = [coordinatesObject.latitude, coordinatesObject.longitude];
@@ -260,21 +298,15 @@ export default function mapui(models, config, store, ui) {
}
};
- /*
- * Remove coordinates marker
- *
- * @method removeCoordinatesMarker
- * @static
- *
- * @returns {void}
- */
- const removeCoordinatesMarker = (coordinatesObject) => {
- const map = self.selected;
- self.activeMarker = map.getOverlayById(coordinatesObject.id);
- if (self.activeMarker) {
- self.activeMarker.setMap(null);
- self.selected.removeOverlay(self.activeMarker);
- }
+ const flyToMarker = (coordinatesObject) => {
+ const state = store.getState();
+ const { proj } = state;
+ const { sources } = config;
+ const latestCoordinates = coordinatesObject && [coordinatesObject.latitude, coordinatesObject.longitude];
+ const zoom = self.selected.getView().getZoom();
+ const activeLayers = getActiveLayers(state).filter(({ projections }) => projections[proj.id]);
+ const maxZoom = getMaxZoomLevelLayerCollection(activeLayers, zoom, proj.id, sources);
+ animateCoordinates(self.selected, proj, latestCoordinates, maxZoom);
};
/*
@@ -292,9 +324,7 @@ export default function mapui(models, config, store, ui) {
const { proj, browser } = state;
const results = geocodeResults;
if (!results) return;
- const latestCoordinates = coordinatesObject && [coordinatesObject.latitude, coordinatesObject.longitude];
- const { sources } = config;
const removeMarker = () => {
store.dispatch({
type: REMOVE_MARKER,
@@ -316,16 +346,12 @@ export default function mapui(models, config, store, ui) {
return false;
}
- self.activeMarker = marker;
+ self.markers.push(marker);
self.selected.addOverlay(marker);
self.selected.renderSync();
if (shouldFlyToCoordinates) {
- // fly to coordinates and render coordinates tooltip on init SET_MARKER
- const zoom = self.selected.getView().getZoom();
- const activeLayers = getActiveLayers(state).filter(({ projections }) => projections[proj.id]);
- const maxZoom = getMaxZoomLevelLayerCollection(activeLayers, zoom, proj.id, sources);
- animateCoordinates(self.selected, proj, latestCoordinates, maxZoom);
+ flyToMarker(coordinatesObject);
}
store.dispatch({
diff --git a/web/js/modules/location-search/actions.js b/web/js/modules/location-search/actions.js
index 90554040e..9a2a7c1ad 100644
--- a/web/js/modules/location-search/actions.js
+++ b/web/js/modules/location-search/actions.js
@@ -63,6 +63,7 @@ export function setPlaceMarker(coordinates, reverseGeocodeResults, isInputSearch
const state = getState();
const {
proj,
+ locationSearch,
} = state;
if (reverseGeocodeResults) {
@@ -73,6 +74,8 @@ export function setPlaceMarker(coordinates, reverseGeocodeResults, isInputSearch
}
const coordinatesWithinExtent = areCoordinatesWithinExtent(proj, coordinates);
+ const stateCoordinates = locationSearch.coordinates;
+ const markerAlreadyExists = stateCoordinates.find((stateCoordinate) => stateCoordinate.latitude === coordinates[0] && stateCoordinate.longitude === coordinates[1]);
if (!coordinatesWithinExtent) {
return dispatch({
type: SET_MARKER,
@@ -80,6 +83,16 @@ export function setPlaceMarker(coordinates, reverseGeocodeResults, isInputSearch
});
}
+ if (markerAlreadyExists) {
+ return dispatch({
+ type: SET_MARKER,
+ coordinates: markerAlreadyExists,
+ reverseGeocodeResults,
+ isCoordinatesSearchActive: isInputSearch,
+ flyToExistingMarker: true,
+ });
+ }
+
const coordinatesObject = {
id: Math.floor(Math.random() * (coordinates[0] + coordinates[1])),
latitude: coordinates[0],
diff --git a/web/js/modules/location-search/util.js b/web/js/modules/location-search/util.js
index fc64d80c2..f5819c3be 100644
--- a/web/js/modules/location-search/util.js
+++ b/web/js/modules/location-search/util.js
@@ -154,18 +154,19 @@ export function serializeCoordinatesWrapper(coordinates, state) {
const { map, proj } = state;
const serializeCoordinates = (coordinate) => {
const coordinateValues = [coordinate.latitude, coordinate.longitude];
- if (map.ui.selected) {
- const coordinatesWithinExtent = areCoordinatesWithinExtent(proj, coordinateValues);
- if (!coordinatesWithinExtent) {
- return;
- }
- }
+ if (!map.ui.selected) return;
+ const coordinatesWithinExtent = areCoordinatesWithinExtent(proj, coordinateValues);
+ if (!coordinatesWithinExtent) return;
return coordinateValues;
};
- const serializeCoordinatesArray = (coordinatesArray) => coordinatesArray.map((coordinate) => serializeCoordinates(coordinate));
+ const serializeCoordinatesArray = (coordinatesArray) => coordinatesArray
+ .map((coordinate) => serializeCoordinates(coordinate))
+ .filter((coordinate) => coordinate);
const coordinatesURL = Array.isArray(coordinates) ? serializeCoordinatesArray(coordinates) : serializeCoordinates(coordinates);
- return coordinatesURL.join('+');
+ if (coordinatesURL.length > 0) {
+ return coordinatesURL.join('+');
+ }
}
/**