-
Notifications
You must be signed in to change notification settings - Fork 444
Floating Dynamic Legend Plugin for ArcGIS & WMS layers #11118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Floating Dynamic Legend Plugin for ArcGIS & WMS layers #11118
Conversation
|
@arxitpln thank you so much for your contribution. PR state updated as needed. We will review it soon. |
allyoucanmap
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arxitpln I created this branch https://github.com/allyoucanmap/MapStore2/tree/arxit-floating-dynamic-legend on my fork with the initial review changes to apply, this is the commit allyoucanmap@a11b673 you can cherry pick on your branch to apply the provided changes.
In addition and after applying the above changes we need also to improve the following:
- The default layout for this type of plugin is a side panel, we should allow to make it configurable using a boolean
cfg.floatingby default it should be false. When true it will render the floating modal when false the side panel similar to other plugins (eg: GeoProcessing) - When the legend is completely empty there is no feedback to the user. We should at least add a message explaining that the legend is empty because there are not visible layer on the current visible map
- Missing unit tests for components and utils
- Missing jsDoc for the plugin configuration
- We should have the options to visualize the legend as a flat list of layers without groups. We could include a configuration boolean
cfg.flatLegendso when a user configure it set a true only the list of layers is rendered, see in the image above TOC has group but legend only the list of layers. We could try to usegroupsprop to extract layers asconst layers = flattenArrayOfObjects(groups)?.filter(node => !node?.nodes);
I'm adding inline comment to explain changes included here allyoucanmap@a11b673
| "dependencies": [ | ||
| "Toolbar", | ||
| "BurgerMenu", | ||
| "SidebarMenu" | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In allyoucanmap@a11b673 only the SidebarMenu is included as dependency because is the current preferred container for all side plugins
web/client/configs/localConfig.json
Outdated
| ], | ||
| "desktop": [ | ||
| "Details", | ||
| "Details","DynamicLegend", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In allyoucanmap@a11b673 this has been excluded because the default localConfig.json should not contain the plugin. This plugin will be configured only via context in the default product application
web/client/configs/simple.json
Outdated
| { | ||
| "name": "DynamicLegend" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed
web/client/plugins/DynamicLegend.jsx
Outdated
| options: { | ||
| disablePluginIf: "{state('router') && (state('router').endsWith('new') || state('router').includes('newgeostory') || state('router').endsWith('dashboard'))}" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In In allyoucanmap@a11b673 removed because not needed
| const dynamicLegendIsEmpty = data.layers.every(layer => layer.legend.length === 0); | ||
| if ((node.dynamicLegendIsEmpty ?? null) !== dynamicLegendIsEmpty) { | ||
| onUpdateNode({ dynamicLegendIsEmpty }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In allyoucanmap@a11b673 the property as been renamed to legendEmpty to make it generic because it could be empty in other cases. Also the onUpdateNode has been changed to onChange to make it consistent with the parent component
| if ((this.props.layer.dynamicLegendIsEmpty ?? null) !== imgError) { | ||
| this.props.onUpdateNode({ dynamicLegendIsEmpty: imgError }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In allyoucanmap@a11b673 same as previous comment
| const dynamicLegendIsEmpty = data.length === 0 || data[0].rules.length === 0; | ||
| if ((this.props.layer.dynamicLegendIsEmpty ?? null) !== dynamicLegendIsEmpty) { | ||
| this.props.onUpdateNode({ dynamicLegendIsEmpty }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In allyoucanmap@a11b673 same as previous comment
| const customGroupNodeComponent = props => ( | ||
| <div style={getVisibilityStyle(props.node?.isVisible ?? true)}> | ||
| <DefaultGroup {...props} /> | ||
| </div> | ||
| ); | ||
| const customLayerNodeComponent = props => { | ||
| const layer = layerDict[props.node.id]; | ||
| if (!layer) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <div style={getVisibilityStyle(props.node?.isVisible ?? true)}> | ||
| <DefaultLayer {...props} node={layer} /> | ||
| </div> | ||
| ); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In allyoucanmap@a11b673 this component has been changed to avoid too many re-render inside the custom nodes, changes:
- moved customGroupNodeComponent and customLayerNodeComponent outside the render function to avoid re-render on each prop update of DynamicLegend component
- reviewed the hiding logic of node by exposing and using the getNodeStyle prop in ControlledTOC
| @@ -0,0 +1,14 @@ | |||
| const isLayer = node => node.nodeType === "layers"; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In allyoucanmap@a11b673 this file has been renamed to DynamicLegendUtils because it does not contain selectors but utils. Some of the utils has been changed to support the new hiding logic.
To better isolate the plugin all files have been moved under the plugins/DynamicLegend folder:
plugins/DynamicLegend/
|__assets/
|__components/
|__utils/
|__index.js
Note DynamicLegend is uppercase as the name file so the import resolver will look for the index.js file inside
…end' into arxit-floating-dynamic-legend
…ions-it#11701) (cherry picked from commit af6340d) Co-authored-by: RowHeat <40065760+rowheat02@users.noreply.github.com>
…tions-it#11704) (geosolutions-it#11706) (cherry picked from commit 4df89f5) Co-authored-by: stefano bovio <stefano.bovio@geosolutionsgroup.com>
geosolutions-it#11729) (cherry picked from commit 8f0a40e) Co-authored-by: Lorenzo Natali <lorenzo.natali@geosolutionsgroup.com>
|
@allyoucanmap, we asked for a review but there is still a pending issue. Please see above our comment (4 Nov) |
|
@arxitpln in this other branch https://github.com/allyoucanmap/MapStore2/commits/issue_11075_layout on my fork you can find two commits:
Please double check both commits before applying them on your branch, thanks |
allyoucanmap
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see this comment #11118 (comment)
…) (geosolutions-it#11736) (cherry picked from commit c0b9487) Co-authored-by: Lorenzo Natali <lorenzo.natali@geosolutionsgroup.com>
…chrone plugin (geosolutions-it#11737) (geosolutions-it#11741) (cherry picked from commit 7974015) Co-authored-by: Lorenzo Natali <lorenzo.natali@geosolutionsgroup.com>
…#11727) (geosolutions-it#11743) (cherry picked from commit 1fffbef) Co-authored-by: Suren <dsuren1@gmail.com>
…eosolutions-it#11756) (geosolutions-it#11757) (cherry picked from commit e6ad159) Co-authored-by: ElenaGallo <56537133+ElenaGallo@users.noreply.github.com>
…Unadvertised Contexts (geosolutions-it#11752) (geosolutions-it#11755) (cherry picked from commit 1b6d336) Co-authored-by: RowHeat <40065760+rowheat02@users.noreply.github.com>
…eosolutions-it#11759) * add_11684 * add_review_11684 (cherry picked from commit c27477c) Co-authored-by: ElenaGallo <56537133+ElenaGallo@users.noreply.github.com>
…tions-it#11761) (geosolutions-it#11763) (cherry picked from commit 23b1527) Co-authored-by: Lorenzo Natali <lorenzo.natali@geosolutionsgroup.com>
…Chart Widget (geosolutions-it#11764) (geosolutions-it#11765) (cherry picked from commit b02c773) Co-authored-by: ElenaGallo <56537133+ElenaGallo@users.noreply.github.com>
…eosolutions-it#11767) * add_11662 * Update docs/user-guide/filtering-layers.md * Update docs/user-guide/filtering-layers.md --------- (cherry picked from commit 9a8083e) Co-authored-by: ElenaGallo <56537133+ElenaGallo@users.noreply.github.com> Co-authored-by: Tobia Di Pisa <tobia.dipisa@geosolutionsgroup.com>
…t-floating-dynamic-legend

Description
Displays the legend of the ArcGIS & WMS layers visible in the current extent of the map
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x", remove the others)
Issue
What is the current behavior?
No floating legend
#11075
What is the new behavior?
Displays in a modal the legend of the ArcGIS & WMS layers visible in the current extent of the map and so automatically adapts its content on zoom in/out, pan or layers visibility toggle on/off
Displays the legends in the same hierarchy as the Layer List
Breaking change
Does this PR introduce a breaking change? (check one with "x", remove the other)
Other useful information