From 91b3c954bba0dc4da3a6f663c037e138a375ae78 Mon Sep 17 00:00:00 2001 From: mahmoud adel <58145645+mahmoudadel54@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:24:45 +0300 Subject: [PATCH] #10545: remove marker in case no results + hover identify mode active and hideEmptyPopupOption with true (#10619) --- web/client/epics/__tests__/identify-test.js | 48 +++++++++++++++++++++ web/client/epics/identify.js | 10 ++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/web/client/epics/__tests__/identify-test.js b/web/client/epics/__tests__/identify-test.js index 613bb39779..7850e04d0f 100644 --- a/web/client/epics/__tests__/identify-test.js +++ b/web/client/epics/__tests__/identify-test.js @@ -965,6 +965,54 @@ describe('identify Epics', () => { testEpic(zoomToVisibleAreaEpic, 3, sentActions, expectedAction, state); }); + it('test zoomToVisibleAreaEpic remove shown marker of identify if no results + existing hideEmptyPopupOption flag = true', (done) => { + // remove previous hook + registerHook('RESOLUTION_HOOK', undefined); + + const state = { + mapInfo: { + centerToMarker: true + }, + mapPopups: { + hideEmptyPopupOption: true + }, + map: {present: {...TEST_MAP_STATE.present, eventListeners: {mousemove: ["identifyFloatingTool"]}}}, + maplayout: { + boundingMapRect: { + left: 500, + bottom: 250 + } + } + }; + + const sentActions = [ + featureInfoClick({ latlng: { lat: 36.95, lng: -79.84 } }), + loadFeatureInfo(1, "no features were found") + ]; + + const expectedAction = actions => { + try { + expect(actions.length).toBe(2); + actions.map((action) => { + switch (action.type) { + case HIDE_MAPINFO_MARKER: + done(); + break; + case UPDATE_CENTER_TO_MARKER: + expect(action.status).toBe('disabled'); + break; + default: + expect(true).toBe(false); + } + }); + } catch (ex) { + done(ex); + } + done(); + }; + + testEpic(zoomToVisibleAreaEpic, 2, sentActions, expectedAction, state); + }); it('onMapClick triggers featureinfo when selected', done => { registerHook(GET_COORDINATES_FROM_PIXEL_HOOK, undefined); diff --git a/web/client/epics/identify.js b/web/client/epics/identify.js index e375336595..2ce441c643 100644 --- a/web/client/epics/identify.js +++ b/web/client/epics/identify.js @@ -51,6 +51,7 @@ import { floatingIdentifyDelaySelector } from '../selectors/localConfig'; import { createControlEnabledSelector, measureSelector } from '../selectors/controls'; import { localizedLayerStylesEnvSelector } from '../selectors/localizedLayerStyles'; import { mouseOutSelector } from '../selectors/mousePosition'; +import { hideEmptyPopupSelector } from '../selectors/mapPopups'; import {getBbox, getCurrentResolution, parseLayoutValue} from '../utils/MapUtils'; import {buildIdentifyRequest, defaultQueryableFilter, filterRequestParams} from '../utils/MapInfoUtils'; import { IDENTIFY_POPUP } from '../components/map/popups'; @@ -250,8 +251,15 @@ export const zoomToVisibleAreaEpic = (action$, store) => .filter(() => centerToMarkerSelector(store.getState())) .switchMap((action) => action$.ofType(LOAD_FEATURE_INFO, ERROR_FEATURE_INFO) - .mergeMap(() => { + .mergeMap((loadFeatInfoAction) => { const state = store.getState(); + const hideIdentifyPopupIfNoResults = hideEmptyPopupSelector(state); + const hoverIdentifyActive = isMouseMoveIdentifyActiveSelector(state); + const noResultFeatures = loadFeatInfoAction.type === LOAD_FEATURE_INFO && loadFeatInfoAction?.data?.includes("no features were found"); + // remove marker in case activated identify hover mode and no fetched results plus existing hideIdentifyPopupIfNoResults = true + if (noResultFeatures && hideIdentifyPopupIfNoResults && hoverIdentifyActive) { + return Rx.Observable.from([updateCenterToMarker('disabled'), hideMapinfoMarker()]); + } const map = mapSelector(state); const mapProjection = projectionSelector(state); const projectionDefs = projectionDefsSelector(state);