Skip to content

Commit

Permalink
#10308: Disable the marker when the search for map type is changed (#…
Browse files Browse the repository at this point in the history
…10316) (#10336)

Description:
- handle clearing marker of coords search if switching from coord search to bookmark search
  • Loading branch information
mahmoudadel54 committed May 17, 2024
1 parent 144ebdf commit 12d039c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions web/client/components/mapcontrols/search/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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') {
Expand Down

0 comments on commit 12d039c

Please sign in to comment.