From 12d039cbce780b7a8657075db71c5383f9c8c06f Mon Sep 17 00:00:00 2001 From: mahmoud adel <58145645+mahmoudadel54@users.noreply.github.com> Date: Fri, 17 May 2024 13:32:01 +0300 Subject: [PATCH] #10308: Disable the marker when the search for map type is changed (#10316) (#10336) Description: - handle clearing marker of coords search if switching from coord search to bookmark search --- .../components/mapcontrols/search/SearchBar.jsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/web/client/components/mapcontrols/search/SearchBar.jsx b/web/client/components/mapcontrols/search/SearchBar.jsx index d4836844ca..d9374b12a8 100644 --- a/web/client/components/mapcontrols/search/SearchBar.jsx +++ b/web/client/components/mapcontrols/search/SearchBar.jsx @@ -8,7 +8,7 @@ import React, { useEffect, useState } from 'react'; import {FormGroup, Glyphicon, MenuItem} from 'react-bootstrap'; -import { isEmpty, isEqual, isUndefined, get } from 'lodash'; +import { isEmpty, isEqual, isUndefined, get, isNumber } from 'lodash'; import Message from '../../I18N/Message'; import SearchBarMenu from './SearchBarMenu'; @@ -113,7 +113,17 @@ export default ({ setSearchServiceSelected(-1); } }, [searchOptions?.services]); - + useEffect(()=>{ + // clear coord search/ crs search marker + if (!['mapCRSCoordinatesSearch', 'coordinatesSearch'].includes(activeTool)) { + onClearCoordinatesSearch({owner: "search"}); + if (isNumber(coordinate?.lon) && isNumber(coordinate?.lat)) { + const clearedFields = ["lat", "lon", "xCoord", "yCoord", "currentMapXYCRS"]; + const resetVal = ''; + clearedFields.forEach(field => onChangeCoord(field, resetVal)); + } + } + }, [activeTool]); useEffect(() => { // Switch back to coordinate search when map CRS is EPSG:4326 and active tool is Map CRS coordinate search if (currentMapCRS === 'EPSG:4326' && activeTool === 'mapCRSCoordinatesSearch') {