geosolutions-it / MapStore2

The solution to create and share maps, dashboards, geostories with 3D support on the web. And it is open-source too!
https://mapstore.geosolutionsgroup.com/
Other
504 stars 391 forks source link

Wrong GFI behavior using the Share tool #6722

Closed tdipisa closed 3 years ago

tdipisa commented 3 years ago

Description

If a layer in ToC is selected and not visible in the map, activating the share function will trigger a GFI request and therefore the warning: No active queryable layer. Therefore all GFI requests should be disabled while using the share function.

How to reproduce

Tested on https://qa.mapstore2.geo-solutions.it/mapstore/#/viewer/openlayers/10358

gfi_search_issue.gif

Expected Result

All GFI requests should be disabled while using the share function.

Current Result

The share function triggers a GFI request and therefore the message "No active queryable layer" is visualized.

Browser info (use this site: https://www.whatsmybrowser.org/ for non expert users) | Browser Affected | Version | |---|---| |Internet Explorer| | |Edge| | |Chrome| | |Firefox| | |Safari| |

Other useful information

offtherailz commented 3 years ago

The problem happens because the tool uses the state of the featureinfo to show the marker. Instead it should use it's own state (or the same state used by queryparams.js epic.

so this changes avoid to trigger any featureinfo action, and instead use the same of queryparams.

diff --git a/web/client/epics/queryparams.js b/web/client/epics/queryparams.js
index 44354ba6f..b1f5a60b4 100644
--- a/web/client/epics/queryparams.js
+++ b/web/client/epics/queryparams.js
@@ -19,7 +19,7 @@ import { warning } from '../actions/notifications';

 import { isValidExtent } from '../utils/CoordinatesUtils';
 import { getConfigProp, getCenter } from '../utils/ConfigUtils';
-import {featureInfoClick, hideMapinfoMarker, purgeMapInfoResults, toggleMapInfoState } from "../actions/mapInfo";
+import {  hideMapinfoMarker, purgeMapInfoResults, toggleMapInfoState } from "../actions/mapInfo";
 import {getBbox} from "../utils/MapUtils";
 import {mapSelector} from '../selectors/map';

@@ -146,10 +146,10 @@ export const readQueryParamsOnMapEpic = (action$, store) =>
  */
 export const onMapClickForShareEpic = (action$, { getState = () => { } }) =>
     action$.ofType(CLICK_ON_MAP).
-        switchMap(({point, layer}) =>{
+        switchMap(({point}) =>{
             const allowClick = get(getState(), 'controls.share.settings.centerAndZoomEnabled');
             return allowClick
-                ? Rx.Observable.of(resetSearch(), featureInfoClick(point, layer))
+                ? Rx.Observable.of(resetSearch(), addMarker(point?.latlng))
                 : Rx.Observable.empty();
         });

In components/share/SharePanel.jsx (or it's container) both onSubmitClickPoint and the point props should be bind to the a different part of the state. I suggest to use the same actions of queryparams (i think the action comes from search.js, and the part of the state is state.search.marker. At least is more consistent.