-
Notifications
You must be signed in to change notification settings - Fork 32
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
[Datahub] Added dynamic legend generation based on map context #1069
Conversation
Affected libs:
|
📷 Screenshots are here! |
What happens if you click on a feature, it use to display the attribute in a popup at the same place. |
@fgravin The legend moves to the side if the attribute table is active. |
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.
Thank you! I did a first review without testing, let me know if you need any more information!
libs/ui/map/src/lib/components/map-legend/map-legend.component.ts
Outdated
Show resolved
Hide resolved
libs/ui/map/src/lib/components/map-legend/map-legend.component.ts
Outdated
Show resolved
Hide resolved
libs/ui/map/src/lib/components/map-legend/map-legend.component.ts
Outdated
Show resolved
Hide resolved
<gn-ui-button | ||
type="primary" | ||
(buttonClick)="toggleLegend()" | ||
extraClass="rounded p-2 text-xs" |
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.
You probably don't need the rounded p-2
classes here; take a look at this component for a way to have a nice and square close button:
geonetwork-ui/libs/ui/layout/src/lib/sortable-list/sortable-list.component.html
Lines 23 to 34 in da5f436
<gn-ui-button | |
type="light" | |
style=" | |
--gn-ui-button-padding: 0px; | |
--gn-ui-button-width: 24px; | |
--gn-ui-button-height: 24px; | |
" | |
class="ml-[8px] mr-[10px]" | |
(buttonClick)="removeItem(index)" | |
data-test="remove-item" | |
><span class="material-symbols-outlined gn-ui-icon-medium">close</span> | |
</gn-ui-button> |
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.
@jahow Does the close button look better now?
libs/ui/map/src/lib/components/map-legend/map-legend.component.spec.ts
Outdated
Show resolved
Hide resolved
libs/ui/map/src/lib/components/map-legend/map-legend.component.ts
Outdated
Show resolved
Hide resolved
</gn-ui-button> | ||
</div> | ||
<gn-ui-map-legend | ||
[context]="mapContext$ | async" |
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.
The test is failing because this adds another subscription to mapContext$
, which triggers the extent computation one more time; in the tests we only resolve the extent computation promise once, so the other does not complete and as such one of the subscriptions doesn't receive the full computed context.
Long story short, I think a good fix is to add this:
withLatestFrom(this.mdViewFacade.metadata$),
map(([context, metadata]) => {
if (context.view) return context
const extent = this.mapUtils.getRecordExtent(metadata)
const view = extent ? { extent } : null
return {
...context,
view,
}
}),
+ shareReplay(1) // line 172
)
Then we won't do unnecessary extent computations :)
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.
Thanksa a lot :)
Description
This PR integrates the
@geospatial-sdk/legend
npm package to dynamically generate map legends based on the map context in theMapViewComponent
. The legend generation works for WMTS and WMS services.Architectural Changes
Integration of
@geospatial-sdk/legend
npm package:@geospatial-sdk/legend
package is used to dynamically generate map legends based on the map context.Creation of
MapLegendComponent
:MapLegendComponent
to handle the generation and display of map legends.Modification of
MapViewComponent
:MapLegendComponent
to theMapViewComponent
.toggleLegend
andonLegendStatusChange
to manage the display and status of the legend.Screenshots
Quality Assurance Checklist
breaking change
labelbackport <release branch>
label