Skip to content

feat: propagate QGIS selection color to map highlight layer#6599

Open
meyerlor wants to merge 12 commits into3liz:masterfrom
meyerlor:feature/respect-qgis-selection-color
Open

feat: propagate QGIS selection color to map highlight layer#6599
meyerlor wants to merge 12 commits into3liz:masterfrom
meyerlor:feature/respect-qgis-selection-color

Conversation

@meyerlor
Copy link
Copy Markdown
Collaborator

@meyerlor meyerlor commented Feb 25, 2026

Read SelectionColor from the QGIS project Gui properties and expose it through the PHP→JSON→JS pipeline so the OpenLayers highlight/ selection overlay respects the user-configured color instead of the hardcoded yellow rgba(255,255,0,0.8).

  • ProjectGuiProperties: add getSelectionColor() with 0-255→0-1 alpha
  • QgisProject: cache and expose selectionColor property
  • Project: add getSelectionColor() wrapper; inject into getUpdatedConfig()
  • Options.js: add selectionColor optional property with default fallback
  • map.js: use initialConfig.options.selectionColor for highlight style

Superseeds #748
Fixes: #4520

ToDo: Respect "per layer" custom selection color as configured in the layer properties of QGIS

Selection Color

@github-actions github-actions Bot added this to the 3.11.0 milestone Feb 25, 2026
@meyerlor meyerlor force-pushed the feature/respect-qgis-selection-color branch from f01cadf to 6ea6ab2 Compare February 25, 2026 15:45
Read SelectionColor from the QGIS project Gui properties and expose
it through the PHP→JSON→JS pipeline so the OpenLayers highlight/
selection overlay respects the user-configured color instead of
the hardcoded yellow rgba(255,255,0,0.8).

- ProjectGuiProperties: add getSelectionColor() with 0-255→0-1 alpha
- QgisProject: cache and expose selectionColor property
- Project: add getSelectionColor() wrapper; inject into getUpdatedConfig()
- Options.js: add selectionColor optional property with default fallback
- map.js: use initialConfig.options.selectionColor for highlight style
@meyerlor meyerlor force-pushed the feature/respect-qgis-selection-color branch from 6ea6ab2 to 4643738 Compare February 25, 2026 15:47
- Remove fill-color from highlight layer style so startup snapshot matches
  the stroke-only reference (polygon interiors are transparent as before)
- Populate OL highlight layer via WFS when selection is made from the
  attribute table, so screenshots differ between selected/deselected states
- Clear highlight layer in emptyLayerSelection to remove it when
  selection is cleared (filter applied, deselect)
- Update attribute-table test to wait for WFS GetFeature request before
  taking the selectHash screenshot
With 3 polygon features rendered via OL highlight layer (instead of
QGIS Server SELECTION yellow), the screenshot PNG grows beyond the
previous 10000-byte upper bound. Raise the limit to 15000.
@meyerlor meyerlor marked this pull request as draft February 25, 2026 21:19
…highlight

- Restore fill-color in _highlightLayer style (was removed to fix snapshot
  but broke the selection visual feedback for all polygon layers)
- Use WFS FEATUREID instead of SELECTIONTOKEN to fetch selected features
  for OL highlight (SELECTIONTOKEN is not reliably supported on WFS endpoint)
- Add olHighlightUpdated flag to layerSelectionChanged events fired by
  SelectionTool so updateMapLayerSelection skips duplicate WFS fetch
  (SelectionTool already calls addHighlightFeatures directly)
- Add hasHighlightFeatures getter to map for external checks
- Set startup.qgs SelectionColorAlpha to 204 (0.800 opacity) to match
  the existing reference snapshot taken with rgba(255,255,0,0.8)
The OL highlight layer covers polygon interiors with semi-opaque yellow,
reducing PNG entropy vs the complex map background. With 3 features
highlighted, the byte size is consistently ~7222 (below the old 8000
threshold). Lower to 5000 and wait for WFS response before screenshot.
The fill-color added in a previous commit caused startup.spec.js to fail
because the reference snapshot expects stroke-only yellow outlines.
Polygon outlines are still clearly visible as selection indicators.
Also revert startup.qgs SelectionColorAlpha to 255 (no longer needed).
Two distinct use cases shared the same _highlightLayer:
- Popup/locate/search: shows feature location, stroke-only yellow is correct
- SelectionTool/attribute table: user-chosen features, should use fill+stroke
  with the project's configured selection color

Add _selectionLayer (fill + stroke) alongside _highlightLayer (stroke only).
SelectionTool and attributeTable now use addSelectionFeatures /
setSelectionFeatures / clearSelectionFeatures which operate on the new layer.
Popup, locate, search, startup, atlas, etc. continue using _highlightLayer
unchanged.
_highlightLayer (popup, locate, search, startup) uses fixed rgba(255,255,0,0.8)
and is stroke-only — unaffected by project selection color setting.
Only _selectionLayer (SelectionTool, attribute table) uses the
project-configured selectionColor with fill+stroke.
@meyerlor
Copy link
Copy Markdown
Collaborator Author

meyerlor commented Feb 26, 2026

it should be good now.

  • Selecting via Attribute Table highlights the feature now in the projects customized color
  • deselecting works now as well.
  • The yellow outline for "popUp Features" remains yellow (or should that follow for consistency also the customized color?)

Copy link
Copy Markdown
Collaborator

@rldhont rldhont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @meyerlor,

Sorry for the delay, I am not in favor to display selection client-side. It is possible in QGIS project to defined for each layer a selection symbol, not only the color. With this changes, Lizmap will not be able to display the selection as configured in the QGIS Project.

I am more in favor to apply the selection color defined in the project to popup, locate, search and startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is it possible to change highlighting color ?

2 participants