feat: highlight overlay for hover, multi-select, and custom colors#657
Open
BRaimbault wants to merge 4 commits into
Open
feat: highlight overlay for hover, multi-select, and custom colors#657BRaimbault wants to merge 4 commits into
BRaimbault wants to merge 4 commits into
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
What
Replaces direct feature-state styling on the base source with a cloned "highlight overlay" — a small GeoJSON source + cloned GL layers drawn above each layer's own base layers — so hover and persistent selection can each highlight one or more features, in an optional custom color, without touching the base source.
Why
The previous model (
setHoverStatetogglingfeature-state.hoverdirectly on the base source) only supported a single hovered feature per layer and had no concept of persistent multi-selection or per-highlight color. This change adds both.Key changes
Map#onMouseMovenow tracks the hovered layer/feature and firesmouseenter/mouseleaveevents instead of writing hover state directly;Layer/LayerGroupgained anonMouseEnter/onMouseLeaveoption.Layer#highlight(ids, color)/Layer#select(ids, color)(and the same onLayerGroup) accept a single id or array of ids plus an optional color, and drive the new overlay (src/utils/highlightOverlay.js). Hover and selection share one highlight color by design — see the doc comment onhighlight()/select().Layer#setVisibleIds/LayerGroup#setVisibleIds/Cluster#setVisibleIdsfilter which features render per layer, and drop any now-hidden id out of the highlight overlay too.Cluster's separate polygon source now refreshes correctly aftersetVisibleIds(), and itsclusterLayerpaint reacts to hover/selection like the other layer builders.Layer#setVisibility/removeFromcorrectly show/hide and clean up the overlay's cloned layers along with the base ones.Known issues
Highlighting a polygon-derived feature inside a
Clustersubclass currently has no visible effect — documented in-code atsrc/layers/Cluster.js(the polygon-to-point conversion used for clustering). Root-caused but not fixed here; it's a bigger architectural change (a second overlay source scoped to the polygon source) better scoped as its own follow-up.