Skip to content

Commit

Permalink
#10545: remove marker in case no results + hover identify mode active…
Browse files Browse the repository at this point in the history
… and hideEmptyPopupOption with true (#10619)
  • Loading branch information
mahmoudadel54 authored Oct 17, 2024
1 parent 1a9a01e commit 0101c6b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
48 changes: 48 additions & 0 deletions web/client/epics/__tests__/identify-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion web/client/epics/identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0101c6b

Please sign in to comment.