[8.19] [Maps] Show labels after saving edits while staying on Vector tiles (… (#240728)#241285
Merged
nreese merged 1 commit intoelastic:8.19from Oct 30, 2025
Merged
Conversation
elastic#240728) Closes elastic#240727 --- ## Summary When using **Maps → Create index (Draw shapes)**, the new layer defaults to **Scaling → Use vector tiles**. Adding label styling (Fixed or By value) previously did **not** display labels until the user manually changed Scaling to **Limit results** and back. This PR makes labels appear immediately (after styling or save) on vector-tiles layers by: - Requesting MVT tiles with **`with_labels=true`** when label styling is active - **Refreshing** tile sources when label styling changes and after saving edits - Properly routing **GEOJSON_VECTOR** layers with `scalingType: MVT` through the MVT pipeline Elastic’s `_mvt` API returns suggested label points when `with_labels=true`; this wires Kibana to use that path and refresh tiles accordingly. Kibana’s **Vector layer** docs describe the scaling modes this aligns with. > 🧠 Investigation and solution developed with the help of the large language model **Claude Sonnet 4.5**, used to analyze the root cause and assist in implementation. --- ### What changed (files) 1. **`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx`** • Snapshots the current label descriptor and `hasLabels` flag into the source request meta; any change invalidates the cached tiles and re-fetches through the MVT layer. 2. **`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts`** • Respect `isForceRefresh` (was checking only `forceRefreshDueToDrawing`). • Generate a new token only when `hasLabels` or buffer change (prevents loops). • Include **`with_labels=true`** in tile requests when label styling is active (Elasticsearch `_mvt` label points). 3. **`x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx`** • When Create index uses MVT scaling, emit an **MvtVectorLayer** descriptor so the layer starts on the MVT pipeline and picks up the label-refresh logic. > **Note:** `geojson_vector_layer.tsx` is restored to match `main` (no MVT source added by GeoJSON). Vector-tile rendering remains owned by `MvtVectorLayer`. Per Elastic’s docs, the vector-tile search API can return suggested label points when `with_labels=true`; the Vector layer docs describe when to use **Use vector tiles** vs **Limit results**. This change wires Kibana’s MVT path to request tiles with labels and refresh them when styling/saving, so labels render without a scaling toggle. --- ### Why During the Create index workflow, vector-tiles scaling is the default. Tiles are built server-side from indexed data, so unsaved edits and label changes don’t show until tiles are refreshed. By requesting tiles with labels and refreshing them on style or save, labels now render as expected without a manual scaling toggle. --- ### Before / After | Before | After | |:--|:--| | Create index → Draw point → Add label → Label missing until Scaling changed | Create index → Draw point → Add label → Label appears instantly (no toggle needed) | **Before (GIF):**  **After (GIF):**  --- ### Testing This change was verified manually; **no new unit or functional tests were added** in this PR. **Manual validation steps** - Add layer → Create index - Draw a point or other shape - Add label styling (Fixed value and By value) → labels appear immediately without toggling scaling - Modify label text → label updates in real time - Toggle labels on/off → tiles refresh correctly - Save edits → labels persist after saving - No crashes, flickering, or infinite refresh loops **Test coverage note** Existing Jest tests for Maps layers and source syncing still pass. Potential follow-ups: - Label style change triggers `isForceRefresh=true` - `with_labels=true` included in MVT tile requests when labels are active - GeoJSON→MVT rendering path switching works without regression --- ## Release note **Fix:** Labels in the **Create index** flow now render with the default **Use vector tiles** scaling as soon as label styling is applied (or after save), without requiring a scaling toggle. --- ### Checklist - [x] No new UI strings (i18n N/A); follows EUI sentence case - [x] No HTTP API or security changes - [ ] Unit tests updated/added *(none in this PR; validated manually)* - [x] Include release note - [ ] Labels (`release_note:*`, `backport:*`, `review`, `community`) will be applied by maintainers during triage --- ### Identify risks - **Scope:** Limited to Create index / MVT-scaling render path - **Performance:** `with_labels` adds small label points per tile; only used when labels are enabled - **Mitigation:** Refresh is scoped to the affected layer; token generation avoids loops --- ### Validation ```bash nvm use 22.17.1 yarn kbn bootstrap yarn lint yarn test:jest x-pack/platform/plugins/shared/maps yarn es snapshot --license trial yarn start --------- Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 3b3adac) # Conflicts: # x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx
5 tasks
mbondyra
approved these changes
Oct 30, 2025
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.
Backport
This will backport the following commits from
mainto8.19:Questions ?
Please refer to the Backport tool documentation