Skip to content

[Maps] Show labels after saving edits while staying on Vector tiles (…#240728

Merged
nreese merged 7 commits intoelastic:mainfrom
jmalmo:maps/fix-vector-tile-labels-after-save
Oct 30, 2025
Merged

[Maps] Show labels after saving edits while staying on Vector tiles (…#240728
nreese merged 7 commits intoelastic:mainfrom
jmalmo:maps/fix-vector-tile-labels-after-save

Conversation

@jmalmo
Copy link
Contributor

@jmalmo jmalmo commented Oct 26, 2025

Closes #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):
kibana_gif_not_working

After (GIF):
kibana_working_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

  • No new UI strings (i18n N/A); follows EUI sentence case
  • No HTTP API or security changes
  • Unit tests updated/added (none in this PR; validated manually)
  • 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

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


<!--ONMERGE {"backportTargets":["8.19","9.1","9.2"]} ONMERGE-->
…MVT)

When a Maps layer uses "Use vector tiles" scaling, labels now appear after
the user saves edits or modifies label styling, without requiring the user
to toggle scaling away from Vector tiles.

## Problem

Users adding label styling (Fixed value or By value) to ES Search layers
with "Use vector tiles" scaling would not see labels appear until they
manually toggled the scaling setting away from Vector tiles and back.

## Root Cause

Three interconnected issues prevented labels from appearing:

1. **Label change detection failure**: The style change handler checked for
   MVT_VECTOR layer type, but ES Search layers using "Use vector tiles" are
   GEOJSON_VECTOR type with scalingType=MVT property. This meant label
   changes were never detected for the most common use case.

2. **Missing force refresh support**: The MVT tile sync logic only checked
   forceRefreshDueToDrawing but ignored isForceRefresh flag used for style
   changes. Even when label changes were detected elsewhere, tiles wouldn't
   refresh.

3. **Wrong rendering path**: GEOJSON_VECTOR layers with scalingType=MVT were
   using GeoJSON rendering (fetching features as GeoJSON) instead of MVT
   rendering (requesting vector tiles). This meant the layer never requested
   tiles with with_labels=true, so Elasticsearch never generated label points.

## Solution

**1. Detect label changes for MVT-scaled layers (layer_actions.ts)**
   - Check sourceDescriptor.scalingType === SCALING_TYPES.MVT instead of
     layer type
   - Compare previous/next label configurations using JSON.stringify
   - Dispatch syncDataForLayerId with isForceRefresh=true when labels change
   - Works for both GEOJSON_VECTOR and MVT_VECTOR layer types

**2. Respect force refresh flag (mvt_source_data.ts)**
   - Added !syncContext.isForceRefresh to canSkip condition
   - Optimized refresh token generation: only create new token when hasLabels
     or buffer actually change (prevents infinite refresh loops)
   - Ensures tiles are re-fetched when label styling changes

**3. Make GeoJsonVectorLayer MVT-aware (geojson_vector_layer.tsx)**
   - _isTiled(): Returns true when source.isMvt() is true (enables vector
     tile rendering)
   - syncLayerWithMB(): Uses MapLibre vector tile source instead of GeoJSON
     source when using MVT scaling
   - _syncData(): Calls syncMvtSourceData() with hasLabels parameter for MVT
     scaling, ensuring tiles are requested with with_labels=true
   - getLayerIcon(), getBounds(), getFeatureById(),
     getStyleMetaDescriptorFromLocalFeatures(): Handle MVT mode gracefully to
     prevent crashes from accessing non-existent feature collection
   - _requiresPrevSourceCleanup(): Detect when MVT tile URL changes for
     proper layer re-rendering

## Testing

Tested with ES Search source using "Use vector tiles" scaling:
- ✅ Add Fixed value label styling → Labels appear immediately
- ✅ Add By value label styling → Labels appear immediately
- ✅ Toggle labels on/off → Tiles refresh correctly with/without labels
- ✅ Change label text while typing → Updates in real-time
- ✅ No crashes when creating layers
- ✅ No infinite refresh loops or flickering
- ✅ Layer icons and bounds work correctly
- ✅ Performance: tiles refresh only when hasLabels or buffer actually change

## Files Changed

- x-pack/platform/plugins/shared/maps/public/actions/layer_actions.ts
- x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/geojson_vector_layer/geojson_vector_layer.tsx
- x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts
@jmalmo jmalmo requested a review from a team as a code owner October 26, 2025 21:33
const sourceDataRequest = this.getSourceDataRequest();
if (sourceDataRequest) {
const sourceData = sourceDataRequest.getData() as any;
if (sourceData && sourceData.tileUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Vector tile layers are rendered with x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx. GeoJsonVectorLayer should not be adding vector source to the map.

Copy link
Contributor Author

@jmalmo jmalmo Oct 28, 2025

Choose a reason for hiding this comment

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

Thanks for the review! I’ve reverted GeoJsonVectorLayer back to its GeoJSON-only behavior so it no longer adds a vector source, and I've updated the description of this PR.

The fix now lives entirely in the MVT path:
layer_actions.ts detects label style changes on MVT-scaled layers and triggers a forced sync.
mvt_source_data.ts respects isForceRefresh and requests tiles with with_labels=true when labels are active (per the _mvt API).
new_vector_layer_wizard/wizard.tsx emits an MvtVectorLayer descriptor when Create index uses MVT scaling so new layers start on the MVT pipeline.

After these changes, labels appear on vector tiles after styling/save without requiring a scaling toggle. Happy to adjust further if needed/wanted.

trigger a forced sync when label styling toggles on MVT-scaled layers
include label/buffer state in MVT tile refresh tokens and request with_labels=true
instantiate MvtVectorLayer descriptors from the Create index wizard when scaling stays MVT
// syncDataForLayer may not trigger endDataLoad if no re-fetch is required
dispatch(updateStyleMeta(layerId));

// Check if label styling changed for layers using MVT scaling - this requires tile refresh
Copy link
Contributor

Choose a reason for hiding this comment

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

Redux actions are generic and should not leak layer implemenation details. This implemenation leaks MVT implemenation details. Instead, this logic should get pushed into MvtVectorLayer.syncData so that updated style change re-fetches data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I dropped the MVT-specific refresh logic from layer_actions.ts—it’s back to the generic implementation. MvtVectorLayer.syncData now snapshots the label descriptor and hasLabels flag into the request meta so any label-style change forces a tile refetch through the layer itself. Will update the description of the pR.

- track the current label descriptor/hasLabels in MvtVectorLayer.syncData so tile cache invalidates on label changes
- continue honoring hasLabels/buffer in syncMvtSourceData, requesting tiles with with_labels=true only when needed
- make the Create index wizard instantiate MvtVectorLayer descriptors when scaling is MVT, so the refresh logic always applies

Testing: manual (Create index → draw feature → toggle labels)
@jmalmo jmalmo force-pushed the maps/fix-vector-tile-labels-after-save branch from 82a5e9f to 7aab6ee Compare October 28, 2025 09:20
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

The issue is isolated to x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx. Once the wizard creates the correct layer, then issue is resolved. Please revert changes to mvt_source_data and mvt_vector_layer as they are not needed.

{ sourceDescriptor },
this.props.mapColors
);
const layerDescriptor =
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for pointing this out. This is a mistake to create a GeoJson layer when source scaling is MVT.

Can you call createDefaultLayerDescriptor to create the layer descriptor? Thanks.

Copy link
Contributor Author

@jmalmo jmalmo Oct 29, 2025

Choose a reason for hiding this comment

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

Done 👍

- reuse createDefaultLayerDescriptor so MVT scaling yields an MvtVectorLayer
- drop the earlier MVT layer/source tweaks that aren’t needed once the wizard creates the correct layer
});
const layerDescriptor = GeoJsonVectorLayer.createDescriptor(
{ sourceDescriptor },
const layerDescriptor = createDefaultLayerDescriptor(
Copy link
Contributor

Choose a reason for hiding this comment

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

createDefaultLayerDescriptor calls ESSearchSource.createDescriptor so this can just be

const layerDescriptor = createDefaultLayerDescriptor(
  {
    indexPatternId,
    geoField: 'coordinates',
    filterByMapBounds: false,
    applyGlobalQuery: false,
  },
  this.props.mapColors
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

…h the raw descriptor fields (no intermediate ESSearchSource.createDescriptor)
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

changes LGTM - thanks for contributing to kibana

@nreese
Copy link
Contributor

nreese commented Oct 29, 2025

@elasticmachine merge upstream

@nreese nreese added release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v9.1.0 v8.19.0 v9.2.0 v9.3.0 labels Oct 29, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@nreese nreese added backport:version Backport to applied version labels Feature:Maps labels Oct 29, 2025
@nreese
Copy link
Contributor

nreese commented Oct 29, 2025

/ci

@nreese nreese added the v9.2.1 label Oct 29, 2025
@nreese
Copy link
Contributor

nreese commented Oct 29, 2025

CI is failing with type failures Looks like auto update resolve the issue so no action needed.

Screenshot 2025-10-29 at 11 16 01 AM
@nreese
Copy link
Contributor

nreese commented Oct 29, 2025

/ci

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
maps 3.1MB 3.1MB +493.0B

History

@nreese nreese enabled auto-merge (squash) October 29, 2025 21:16
@nreese nreese disabled auto-merge October 29, 2025 21:16
@nreese
Copy link
Contributor

nreese commented Oct 30, 2025

@elasticmachine run docs-build

@nreese nreese merged commit 3b3adac into elastic:main Oct 30, 2025
12 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1, 9.2

https://github.com/elastic/kibana/actions/runs/18928624698

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Oct 30, 2025
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):**

![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)

**After (GIF):**

![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)

---

### 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)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.19 Backport failed because of merge conflicts
9.1 Backport failed because of merge conflicts
9.2

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 240728

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Oct 30, 2025
…iles (… (#240728) (#241219)

# Backport

This will backport the following commits from `main` to `9.2`:
- [[Maps] Show labels after saving edits while staying on Vector tiles
(… (#240728)](#240728)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Jakob
Malmo","email":"jakobmalmo@protonmail.com"},"sourceCommit":{"committedDate":"2025-10-30T03:10:46Z","message":"[Maps]
Show labels after saving edits while staying on Vector tiles (…
(#240728)\n\nCloses #240727 \n---\n\n## Summary\nWhen using **Maps →
Create index (Draw shapes)**, the new layer defaults\nto **Scaling → Use
vector tiles**.\nAdding label styling (Fixed or By value) previously did
**not** display\nlabels until the user manually changed Scaling to
**Limit results** and\nback.\nThis PR makes labels appear immediately
(after styling or save) on\nvector-tiles layers by:\n\n- Requesting MVT
tiles with **`with_labels=true`** when label styling is\nactive\n-
**Refreshing** tile sources when label styling changes and after\nsaving
edits\n- Properly routing **GEOJSON_VECTOR** layers with `scalingType:
MVT`\nthrough the MVT pipeline\n\nElastic’s `_mvt` API returns suggested
label points when\n`with_labels=true`; this wires Kibana to use that
path and refresh tiles\naccordingly.\nKibana’s **Vector layer** docs
describe the scaling modes this aligns\nwith.\n\n> 🧠 Investigation and
solution developed with the help of the large\nlanguage model **Claude
Sonnet 4.5**, used to analyze the root cause and\nassist in
implementation.\n\n---\n\n### What changed
(files)\n1.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx`**\n•
Snapshots the current label descriptor and `hasLabels` flag into
the\nsource request meta; any change invalidates the cached tiles
and\nre-fetches through the MVT
layer.\n\n2.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts`**\n•
Respect `isForceRefresh` (was checking
only\n`forceRefreshDueToDrawing`).\n• Generate a new token only when
`hasLabels` or buffer change (prevents\nloops).\n• Include
**`with_labels=true`** in tile requests when label styling is\nactive
(Elasticsearch `_mvt` label
points).\n\n3.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx`**\n•
When Create index uses MVT scaling, emit an
**MvtVectorLayer**\ndescriptor so the layer starts on the MVT pipeline
and picks up the\nlabel-refresh logic.\n\n> **Note:**
`geojson_vector_layer.tsx` is restored to match `main` (no\nMVT source
added by GeoJSON). Vector-tile rendering remains owned
by\n`MvtVectorLayer`.\n\nPer Elastic’s docs, the vector-tile search API
can return suggested\nlabel points when `with_labels=true`; the Vector
layer docs describe\nwhen to use **Use vector tiles** vs **Limit
results**. This change wires\nKibana’s MVT path to request tiles with
labels and refresh them when\nstyling/saving, so labels render without a
scaling toggle.\n\n\n\n---\n\n### Why\nDuring the Create index workflow,
vector-tiles scaling is the default. \nTiles are built server-side from
indexed data, so unsaved edits and\nlabel changes don’t show until tiles
are refreshed.\nBy requesting tiles with labels and refreshing them on
style or save,\nlabels now render as expected without a manual scaling
toggle.\n\n---\n\n### Before / After\n| Before | After |\n|:--|:--|\n|
Create index → Draw point → Add label → Label missing until
Scaling\nchanged | Create index → Draw point → Add label → Label
appears\ninstantly (no toggle needed) |\n\n**Before (GIF):**
\n\n![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)\n\n**After
(GIF):**
\n\n![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)\n\n---\n\n###
Testing\nThis change was verified manually; **no new unit or functional
tests\nwere added** in this PR.\n\n**Manual validation steps**\n- Add
layer → Create index\n- Draw a point or other shape\n- Add label styling
(Fixed value and By value) → labels appear\nimmediately without toggling
scaling\n- Modify label text → label updates in real time\n- Toggle
labels on/off → tiles refresh correctly\n- Save edits → labels persist
after saving\n- No crashes, flickering, or infinite refresh
loops\n\n**Test coverage note**\nExisting Jest tests for Maps layers and
source syncing still pass. \nPotential follow-ups:\n- Label style change
triggers `isForceRefresh=true`\n- `with_labels=true` included in MVT
tile requests when labels are\nactive\n- GeoJSON→MVT rendering path
switching works without regression\n\n---\n\n## Release note\n**Fix:**
Labels in the **Create index** flow now render with the default\n**Use
vector tiles** scaling as soon as label styling is applied (or\nafter
save), without requiring a scaling toggle.\n\n---\n\n### Checklist\n-
[x] No new UI strings (i18n N/A); follows EUI sentence case \n- [x] No
HTTP API or security changes \n- [ ] Unit tests updated/added *(none in
this PR; validated manually)* \n- [x] Include release note \n- [ ]
Labels (`release_note:*`, `backport:*`, `review`, `community`)\nwill be
applied by maintainers during triage\n\n---\n\n### Identify risks\n-
**Scope:** Limited to Create index / MVT-scaling render path \n-
**Performance:** `with_labels` adds small label points per tile;
only\nused when labels are enabled\n- **Mitigation:** Refresh is scoped
to the affected layer; token\ngeneration avoids loops\n\n---\n\n###
Validation\n```bash\nnvm use 22.17.1\nyarn kbn bootstrap\nyarn
lint\nyarn test:jest x-pack/platform/plugins/shared/maps\nyarn es
snapshot --license trial\nyarn start\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3b3adac2e24a84f216bec2d0884114013b03854a","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Presentation","💝community","Feature:Maps","backport:version","v9.3.0","v8.19.7","v9.1.7","v9.2.1"],"title":"[Maps]
Show labels after saving edits while staying on Vector tiles
(…","number":240728,"url":"https://github.com/elastic/kibana/pull/240728","mergeCommit":{"message":"[Maps]
Show labels after saving edits while staying on Vector tiles (…
(#240728)\n\nCloses #240727 \n---\n\n## Summary\nWhen using **Maps →
Create index (Draw shapes)**, the new layer defaults\nto **Scaling → Use
vector tiles**.\nAdding label styling (Fixed or By value) previously did
**not** display\nlabels until the user manually changed Scaling to
**Limit results** and\nback.\nThis PR makes labels appear immediately
(after styling or save) on\nvector-tiles layers by:\n\n- Requesting MVT
tiles with **`with_labels=true`** when label styling is\nactive\n-
**Refreshing** tile sources when label styling changes and after\nsaving
edits\n- Properly routing **GEOJSON_VECTOR** layers with `scalingType:
MVT`\nthrough the MVT pipeline\n\nElastic’s `_mvt` API returns suggested
label points when\n`with_labels=true`; this wires Kibana to use that
path and refresh tiles\naccordingly.\nKibana’s **Vector layer** docs
describe the scaling modes this aligns\nwith.\n\n> 🧠 Investigation and
solution developed with the help of the large\nlanguage model **Claude
Sonnet 4.5**, used to analyze the root cause and\nassist in
implementation.\n\n---\n\n### What changed
(files)\n1.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx`**\n•
Snapshots the current label descriptor and `hasLabels` flag into
the\nsource request meta; any change invalidates the cached tiles
and\nre-fetches through the MVT
layer.\n\n2.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts`**\n•
Respect `isForceRefresh` (was checking
only\n`forceRefreshDueToDrawing`).\n• Generate a new token only when
`hasLabels` or buffer change (prevents\nloops).\n• Include
**`with_labels=true`** in tile requests when label styling is\nactive
(Elasticsearch `_mvt` label
points).\n\n3.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx`**\n•
When Create index uses MVT scaling, emit an
**MvtVectorLayer**\ndescriptor so the layer starts on the MVT pipeline
and picks up the\nlabel-refresh logic.\n\n> **Note:**
`geojson_vector_layer.tsx` is restored to match `main` (no\nMVT source
added by GeoJSON). Vector-tile rendering remains owned
by\n`MvtVectorLayer`.\n\nPer Elastic’s docs, the vector-tile search API
can return suggested\nlabel points when `with_labels=true`; the Vector
layer docs describe\nwhen to use **Use vector tiles** vs **Limit
results**. This change wires\nKibana’s MVT path to request tiles with
labels and refresh them when\nstyling/saving, so labels render without a
scaling toggle.\n\n\n\n---\n\n### Why\nDuring the Create index workflow,
vector-tiles scaling is the default. \nTiles are built server-side from
indexed data, so unsaved edits and\nlabel changes don’t show until tiles
are refreshed.\nBy requesting tiles with labels and refreshing them on
style or save,\nlabels now render as expected without a manual scaling
toggle.\n\n---\n\n### Before / After\n| Before | After |\n|:--|:--|\n|
Create index → Draw point → Add label → Label missing until
Scaling\nchanged | Create index → Draw point → Add label → Label
appears\ninstantly (no toggle needed) |\n\n**Before (GIF):**
\n\n![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)\n\n**After
(GIF):**
\n\n![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)\n\n---\n\n###
Testing\nThis change was verified manually; **no new unit or functional
tests\nwere added** in this PR.\n\n**Manual validation steps**\n- Add
layer → Create index\n- Draw a point or other shape\n- Add label styling
(Fixed value and By value) → labels appear\nimmediately without toggling
scaling\n- Modify label text → label updates in real time\n- Toggle
labels on/off → tiles refresh correctly\n- Save edits → labels persist
after saving\n- No crashes, flickering, or infinite refresh
loops\n\n**Test coverage note**\nExisting Jest tests for Maps layers and
source syncing still pass. \nPotential follow-ups:\n- Label style change
triggers `isForceRefresh=true`\n- `with_labels=true` included in MVT
tile requests when labels are\nactive\n- GeoJSON→MVT rendering path
switching works without regression\n\n---\n\n## Release note\n**Fix:**
Labels in the **Create index** flow now render with the default\n**Use
vector tiles** scaling as soon as label styling is applied (or\nafter
save), without requiring a scaling toggle.\n\n---\n\n### Checklist\n-
[x] No new UI strings (i18n N/A); follows EUI sentence case \n- [x] No
HTTP API or security changes \n- [ ] Unit tests updated/added *(none in
this PR; validated manually)* \n- [x] Include release note \n- [ ]
Labels (`release_note:*`, `backport:*`, `review`, `community`)\nwill be
applied by maintainers during triage\n\n---\n\n### Identify risks\n-
**Scope:** Limited to Create index / MVT-scaling render path \n-
**Performance:** `with_labels` adds small label points per tile;
only\nused when labels are enabled\n- **Mitigation:** Refresh is scoped
to the affected layer; token\ngeneration avoids loops\n\n---\n\n###
Validation\n```bash\nnvm use 22.17.1\nyarn kbn bootstrap\nyarn
lint\nyarn test:jest x-pack/platform/plugins/shared/maps\nyarn es
snapshot --license trial\nyarn start\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3b3adac2e24a84f216bec2d0884114013b03854a"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.1","9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240728","number":240728,"mergeCommit":{"message":"[Maps]
Show labels after saving edits while staying on Vector tiles (…
(#240728)\n\nCloses #240727 \n---\n\n## Summary\nWhen using **Maps →
Create index (Draw shapes)**, the new layer defaults\nto **Scaling → Use
vector tiles**.\nAdding label styling (Fixed or By value) previously did
**not** display\nlabels until the user manually changed Scaling to
**Limit results** and\nback.\nThis PR makes labels appear immediately
(after styling or save) on\nvector-tiles layers by:\n\n- Requesting MVT
tiles with **`with_labels=true`** when label styling is\nactive\n-
**Refreshing** tile sources when label styling changes and after\nsaving
edits\n- Properly routing **GEOJSON_VECTOR** layers with `scalingType:
MVT`\nthrough the MVT pipeline\n\nElastic’s `_mvt` API returns suggested
label points when\n`with_labels=true`; this wires Kibana to use that
path and refresh tiles\naccordingly.\nKibana’s **Vector layer** docs
describe the scaling modes this aligns\nwith.\n\n> 🧠 Investigation and
solution developed with the help of the large\nlanguage model **Claude
Sonnet 4.5**, used to analyze the root cause and\nassist in
implementation.\n\n---\n\n### What changed
(files)\n1.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx`**\n•
Snapshots the current label descriptor and `hasLabels` flag into
the\nsource request meta; any change invalidates the cached tiles
and\nre-fetches through the MVT
layer.\n\n2.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts`**\n•
Respect `isForceRefresh` (was checking
only\n`forceRefreshDueToDrawing`).\n• Generate a new token only when
`hasLabels` or buffer change (prevents\nloops).\n• Include
**`with_labels=true`** in tile requests when label styling is\nactive
(Elasticsearch `_mvt` label
points).\n\n3.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx`**\n•
When Create index uses MVT scaling, emit an
**MvtVectorLayer**\ndescriptor so the layer starts on the MVT pipeline
and picks up the\nlabel-refresh logic.\n\n> **Note:**
`geojson_vector_layer.tsx` is restored to match `main` (no\nMVT source
added by GeoJSON). Vector-tile rendering remains owned
by\n`MvtVectorLayer`.\n\nPer Elastic’s docs, the vector-tile search API
can return suggested\nlabel points when `with_labels=true`; the Vector
layer docs describe\nwhen to use **Use vector tiles** vs **Limit
results**. This change wires\nKibana’s MVT path to request tiles with
labels and refresh them when\nstyling/saving, so labels render without a
scaling toggle.\n\n\n\n---\n\n### Why\nDuring the Create index workflow,
vector-tiles scaling is the default. \nTiles are built server-side from
indexed data, so unsaved edits and\nlabel changes don’t show until tiles
are refreshed.\nBy requesting tiles with labels and refreshing them on
style or save,\nlabels now render as expected without a manual scaling
toggle.\n\n---\n\n### Before / After\n| Before | After |\n|:--|:--|\n|
Create index → Draw point → Add label → Label missing until
Scaling\nchanged | Create index → Draw point → Add label → Label
appears\ninstantly (no toggle needed) |\n\n**Before (GIF):**
\n\n![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)\n\n**After
(GIF):**
\n\n![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)\n\n---\n\n###
Testing\nThis change was verified manually; **no new unit or functional
tests\nwere added** in this PR.\n\n**Manual validation steps**\n- Add
layer → Create index\n- Draw a point or other shape\n- Add label styling
(Fixed value and By value) → labels appear\nimmediately without toggling
scaling\n- Modify label text → label updates in real time\n- Toggle
labels on/off → tiles refresh correctly\n- Save edits → labels persist
after saving\n- No crashes, flickering, or infinite refresh
loops\n\n**Test coverage note**\nExisting Jest tests for Maps layers and
source syncing still pass. \nPotential follow-ups:\n- Label style change
triggers `isForceRefresh=true`\n- `with_labels=true` included in MVT
tile requests when labels are\nactive\n- GeoJSON→MVT rendering path
switching works without regression\n\n---\n\n## Release note\n**Fix:**
Labels in the **Create index** flow now render with the default\n**Use
vector tiles** scaling as soon as label styling is applied (or\nafter
save), without requiring a scaling toggle.\n\n---\n\n### Checklist\n-
[x] No new UI strings (i18n N/A); follows EUI sentence case \n- [x] No
HTTP API or security changes \n- [ ] Unit tests updated/added *(none in
this PR; validated manually)* \n- [x] Include release note \n- [ ]
Labels (`release_note:*`, `backport:*`, `review`, `community`)\nwill be
applied by maintainers during triage\n\n---\n\n### Identify risks\n-
**Scope:** Limited to Create index / MVT-scaling render path \n-
**Performance:** `with_labels` adds small label points per tile;
only\nused when labels are enabled\n- **Mitigation:** Refresh is scoped
to the affected layer; token\ngeneration avoids loops\n\n---\n\n###
Validation\n```bash\nnvm use 22.17.1\nyarn kbn bootstrap\nyarn
lint\nyarn test:jest x-pack/platform/plugins/shared/maps\nyarn es
snapshot --license trial\nyarn start\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3b3adac2e24a84f216bec2d0884114013b03854a"}},{"branch":"8.19","label":"v8.19.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.1","label":"v9.1.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Jakob Malmo <jakobmalmo@protonmail.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
sbelastic pushed a commit to sbelastic/kibana that referenced this pull request Oct 30, 2025
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):**  

![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)

**After (GIF):**  

![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)

---

### 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>
nreese pushed a commit to nreese/kibana that referenced this pull request Oct 30, 2025
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):**

![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)

**After (GIF):**

![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)

---

### 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
@nreese
Copy link
Contributor

nreese commented Oct 30, 2025

💚 All backports created successfully

Status Branch Result
9.1
8.19

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

nreese pushed a commit to nreese/kibana that referenced this pull request Oct 30, 2025
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):**

![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)

**After (GIF):**

![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)

---

### 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
nreese added a commit that referenced this pull request Oct 30, 2025
…iles (… (#240728) (#241283)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[Maps] Show labels after saving edits while staying on Vector tiles
(… (#240728)](#240728)

<!--- Backport version: 10.1.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Jakob
Malmo","email":"jakobmalmo@protonmail.com"},"sourceCommit":{"committedDate":"2025-10-30T03:10:46Z","message":"[Maps]
Show labels after saving edits while staying on Vector tiles (…
(#240728)\n\nCloses #240727 \n---\n\n## Summary\nWhen using **Maps →
Create index (Draw shapes)**, the new layer defaults\nto **Scaling → Use
vector tiles**.\nAdding label styling (Fixed or By value) previously did
**not** display\nlabels until the user manually changed Scaling to
**Limit results** and\nback.\nThis PR makes labels appear immediately
(after styling or save) on\nvector-tiles layers by:\n\n- Requesting MVT
tiles with **`with_labels=true`** when label styling is\nactive\n-
**Refreshing** tile sources when label styling changes and after\nsaving
edits\n- Properly routing **GEOJSON_VECTOR** layers with `scalingType:
MVT`\nthrough the MVT pipeline\n\nElastic’s `_mvt` API returns suggested
label points when\n`with_labels=true`; this wires Kibana to use that
path and refresh tiles\naccordingly.\nKibana’s **Vector layer** docs
describe the scaling modes this aligns\nwith.\n\n> 🧠 Investigation and
solution developed with the help of the large\nlanguage model **Claude
Sonnet 4.5**, used to analyze the root cause and\nassist in
implementation.\n\n---\n\n### What changed
(files)\n1.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx`**\n•
Snapshots the current label descriptor and `hasLabels` flag into
the\nsource request meta; any change invalidates the cached tiles
and\nre-fetches through the MVT
layer.\n\n2.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts`**\n•
Respect `isForceRefresh` (was checking
only\n`forceRefreshDueToDrawing`).\n• Generate a new token only when
`hasLabels` or buffer change (prevents\nloops).\n• Include
**`with_labels=true`** in tile requests when label styling is\nactive
(Elasticsearch `_mvt` label
points).\n\n3.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx`**\n•
When Create index uses MVT scaling, emit an
**MvtVectorLayer**\ndescriptor so the layer starts on the MVT pipeline
and picks up the\nlabel-refresh logic.\n\n> **Note:**
`geojson_vector_layer.tsx` is restored to match `main` (no\nMVT source
added by GeoJSON). Vector-tile rendering remains owned
by\n`MvtVectorLayer`.\n\nPer Elastic’s docs, the vector-tile search API
can return suggested\nlabel points when `with_labels=true`; the Vector
layer docs describe\nwhen to use **Use vector tiles** vs **Limit
results**. This change wires\nKibana’s MVT path to request tiles with
labels and refresh them when\nstyling/saving, so labels render without a
scaling toggle.\n\n\n\n---\n\n### Why\nDuring the Create index workflow,
vector-tiles scaling is the default. \nTiles are built server-side from
indexed data, so unsaved edits and\nlabel changes don’t show until tiles
are refreshed.\nBy requesting tiles with labels and refreshing them on
style or save,\nlabels now render as expected without a manual scaling
toggle.\n\n---\n\n### Before / After\n| Before | After |\n|:--|:--|\n|
Create index → Draw point → Add label → Label missing until
Scaling\nchanged | Create index → Draw point → Add label → Label
appears\ninstantly (no toggle needed) |\n\n**Before (GIF):**
\n\n![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)\n\n**After
(GIF):**
\n\n![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)\n\n---\n\n###
Testing\nThis change was verified manually; **no new unit or functional
tests\nwere added** in this PR.\n\n**Manual validation steps**\n- Add
layer → Create index\n- Draw a point or other shape\n- Add label styling
(Fixed value and By value) → labels appear\nimmediately without toggling
scaling\n- Modify label text → label updates in real time\n- Toggle
labels on/off → tiles refresh correctly\n- Save edits → labels persist
after saving\n- No crashes, flickering, or infinite refresh
loops\n\n**Test coverage note**\nExisting Jest tests for Maps layers and
source syncing still pass. \nPotential follow-ups:\n- Label style change
triggers `isForceRefresh=true`\n- `with_labels=true` included in MVT
tile requests when labels are\nactive\n- GeoJSON→MVT rendering path
switching works without regression\n\n---\n\n## Release note\n**Fix:**
Labels in the **Create index** flow now render with the default\n**Use
vector tiles** scaling as soon as label styling is applied (or\nafter
save), without requiring a scaling toggle.\n\n---\n\n### Checklist\n-
[x] No new UI strings (i18n N/A); follows EUI sentence case \n- [x] No
HTTP API or security changes \n- [ ] Unit tests updated/added *(none in
this PR; validated manually)* \n- [x] Include release note \n- [ ]
Labels (`release_note:*`, `backport:*`, `review`, `community`)\nwill be
applied by maintainers during triage\n\n---\n\n### Identify risks\n-
**Scope:** Limited to Create index / MVT-scaling render path \n-
**Performance:** `with_labels` adds small label points per tile;
only\nused when labels are enabled\n- **Mitigation:** Refresh is scoped
to the affected layer; token\ngeneration avoids loops\n\n---\n\n###
Validation\n```bash\nnvm use 22.17.1\nyarn kbn bootstrap\nyarn
lint\nyarn test:jest x-pack/platform/plugins/shared/maps\nyarn es
snapshot --license trial\nyarn start\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3b3adac2e24a84f216bec2d0884114013b03854a","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Presentation","💝community","Feature:Maps","backport:version","v9.3.0","v8.19.7","v9.1.7","v9.2.1"],"title":"[Maps]
Show labels after saving edits while staying on Vector tiles
(…","number":240728,"url":"https://github.com/elastic/kibana/pull/240728","mergeCommit":{"message":"[Maps]
Show labels after saving edits while staying on Vector tiles (…
(#240728)\n\nCloses #240727 \n---\n\n## Summary\nWhen using **Maps →
Create index (Draw shapes)**, the new layer defaults\nto **Scaling → Use
vector tiles**.\nAdding label styling (Fixed or By value) previously did
**not** display\nlabels until the user manually changed Scaling to
**Limit results** and\nback.\nThis PR makes labels appear immediately
(after styling or save) on\nvector-tiles layers by:\n\n- Requesting MVT
tiles with **`with_labels=true`** when label styling is\nactive\n-
**Refreshing** tile sources when label styling changes and after\nsaving
edits\n- Properly routing **GEOJSON_VECTOR** layers with `scalingType:
MVT`\nthrough the MVT pipeline\n\nElastic’s `_mvt` API returns suggested
label points when\n`with_labels=true`; this wires Kibana to use that
path and refresh tiles\naccordingly.\nKibana’s **Vector layer** docs
describe the scaling modes this aligns\nwith.\n\n> 🧠 Investigation and
solution developed with the help of the large\nlanguage model **Claude
Sonnet 4.5**, used to analyze the root cause and\nassist in
implementation.\n\n---\n\n### What changed
(files)\n1.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx`**\n•
Snapshots the current label descriptor and `hasLabels` flag into
the\nsource request meta; any change invalidates the cached tiles
and\nre-fetches through the MVT
layer.\n\n2.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts`**\n•
Respect `isForceRefresh` (was checking
only\n`forceRefreshDueToDrawing`).\n• Generate a new token only when
`hasLabels` or buffer change (prevents\nloops).\n• Include
**`with_labels=true`** in tile requests when label styling is\nactive
(Elasticsearch `_mvt` label
points).\n\n3.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx`**\n•
When Create index uses MVT scaling, emit an
**MvtVectorLayer**\ndescriptor so the layer starts on the MVT pipeline
and picks up the\nlabel-refresh logic.\n\n> **Note:**
`geojson_vector_layer.tsx` is restored to match `main` (no\nMVT source
added by GeoJSON). Vector-tile rendering remains owned
by\n`MvtVectorLayer`.\n\nPer Elastic’s docs, the vector-tile search API
can return suggested\nlabel points when `with_labels=true`; the Vector
layer docs describe\nwhen to use **Use vector tiles** vs **Limit
results**. This change wires\nKibana’s MVT path to request tiles with
labels and refresh them when\nstyling/saving, so labels render without a
scaling toggle.\n\n\n\n---\n\n### Why\nDuring the Create index workflow,
vector-tiles scaling is the default. \nTiles are built server-side from
indexed data, so unsaved edits and\nlabel changes don’t show until tiles
are refreshed.\nBy requesting tiles with labels and refreshing them on
style or save,\nlabels now render as expected without a manual scaling
toggle.\n\n---\n\n### Before / After\n| Before | After |\n|:--|:--|\n|
Create index → Draw point → Add label → Label missing until
Scaling\nchanged | Create index → Draw point → Add label → Label
appears\ninstantly (no toggle needed) |\n\n**Before (GIF):**
\n\n![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)\n\n**After
(GIF):**
\n\n![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)\n\n---\n\n###
Testing\nThis change was verified manually; **no new unit or functional
tests\nwere added** in this PR.\n\n**Manual validation steps**\n- Add
layer → Create index\n- Draw a point or other shape\n- Add label styling
(Fixed value and By value) → labels appear\nimmediately without toggling
scaling\n- Modify label text → label updates in real time\n- Toggle
labels on/off → tiles refresh correctly\n- Save edits → labels persist
after saving\n- No crashes, flickering, or infinite refresh
loops\n\n**Test coverage note**\nExisting Jest tests for Maps layers and
source syncing still pass. \nPotential follow-ups:\n- Label style change
triggers `isForceRefresh=true`\n- `with_labels=true` included in MVT
tile requests when labels are\nactive\n- GeoJSON→MVT rendering path
switching works without regression\n\n---\n\n## Release note\n**Fix:**
Labels in the **Create index** flow now render with the default\n**Use
vector tiles** scaling as soon as label styling is applied (or\nafter
save), without requiring a scaling toggle.\n\n---\n\n### Checklist\n-
[x] No new UI strings (i18n N/A); follows EUI sentence case \n- [x] No
HTTP API or security changes \n- [ ] Unit tests updated/added *(none in
this PR; validated manually)* \n- [x] Include release note \n- [ ]
Labels (`release_note:*`, `backport:*`, `review`, `community`)\nwill be
applied by maintainers during triage\n\n---\n\n### Identify risks\n-
**Scope:** Limited to Create index / MVT-scaling render path \n-
**Performance:** `with_labels` adds small label points per tile;
only\nused when labels are enabled\n- **Mitigation:** Refresh is scoped
to the affected layer; token\ngeneration avoids loops\n\n---\n\n###
Validation\n```bash\nnvm use 22.17.1\nyarn kbn bootstrap\nyarn
lint\nyarn test:jest x-pack/platform/plugins/shared/maps\nyarn es
snapshot --license trial\nyarn start\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3b3adac2e24a84f216bec2d0884114013b03854a"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.1"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240728","number":240728,"mergeCommit":{"message":"[Maps]
Show labels after saving edits while staying on Vector tiles (…
(#240728)\n\nCloses #240727 \n---\n\n## Summary\nWhen using **Maps →
Create index (Draw shapes)**, the new layer defaults\nto **Scaling → Use
vector tiles**.\nAdding label styling (Fixed or By value) previously did
**not** display\nlabels until the user manually changed Scaling to
**Limit results** and\nback.\nThis PR makes labels appear immediately
(after styling or save) on\nvector-tiles layers by:\n\n- Requesting MVT
tiles with **`with_labels=true`** when label styling is\nactive\n-
**Refreshing** tile sources when label styling changes and after\nsaving
edits\n- Properly routing **GEOJSON_VECTOR** layers with `scalingType:
MVT`\nthrough the MVT pipeline\n\nElastic’s `_mvt` API returns suggested
label points when\n`with_labels=true`; this wires Kibana to use that
path and refresh tiles\naccordingly.\nKibana’s **Vector layer** docs
describe the scaling modes this aligns\nwith.\n\n> 🧠 Investigation and
solution developed with the help of the large\nlanguage model **Claude
Sonnet 4.5**, used to analyze the root cause and\nassist in
implementation.\n\n---\n\n### What changed
(files)\n1.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx`**\n•
Snapshots the current label descriptor and `hasLabels` flag into
the\nsource request meta; any change invalidates the cached tiles
and\nre-fetches through the MVT
layer.\n\n2.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts`**\n•
Respect `isForceRefresh` (was checking
only\n`forceRefreshDueToDrawing`).\n• Generate a new token only when
`hasLabels` or buffer change (prevents\nloops).\n• Include
**`with_labels=true`** in tile requests when label styling is\nactive
(Elasticsearch `_mvt` label
points).\n\n3.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx`**\n•
When Create index uses MVT scaling, emit an
**MvtVectorLayer**\ndescriptor so the layer starts on the MVT pipeline
and picks up the\nlabel-refresh logic.\n\n> **Note:**
`geojson_vector_layer.tsx` is restored to match `main` (no\nMVT source
added by GeoJSON). Vector-tile rendering remains owned
by\n`MvtVectorLayer`.\n\nPer Elastic’s docs, the vector-tile search API
can return suggested\nlabel points when `with_labels=true`; the Vector
layer docs describe\nwhen to use **Use vector tiles** vs **Limit
results**. This change wires\nKibana’s MVT path to request tiles with
labels and refresh them when\nstyling/saving, so labels render without a
scaling toggle.\n\n\n\n---\n\n### Why\nDuring the Create index workflow,
vector-tiles scaling is the default. \nTiles are built server-side from
indexed data, so unsaved edits and\nlabel changes don’t show until tiles
are refreshed.\nBy requesting tiles with labels and refreshing them on
style or save,\nlabels now render as expected without a manual scaling
toggle.\n\n---\n\n### Before / After\n| Before | After |\n|:--|:--|\n|
Create index → Draw point → Add label → Label missing until
Scaling\nchanged | Create index → Draw point → Add label → Label
appears\ninstantly (no toggle needed) |\n\n**Before (GIF):**
\n\n![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)\n\n**After
(GIF):**
\n\n![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)\n\n---\n\n###
Testing\nThis change was verified manually; **no new unit or functional
tests\nwere added** in this PR.\n\n**Manual validation steps**\n- Add
layer → Create index\n- Draw a point or other shape\n- Add label styling
(Fixed value and By value) → labels appear\nimmediately without toggling
scaling\n- Modify label text → label updates in real time\n- Toggle
labels on/off → tiles refresh correctly\n- Save edits → labels persist
after saving\n- No crashes, flickering, or infinite refresh
loops\n\n**Test coverage note**\nExisting Jest tests for Maps layers and
source syncing still pass. \nPotential follow-ups:\n- Label style change
triggers `isForceRefresh=true`\n- `with_labels=true` included in MVT
tile requests when labels are\nactive\n- GeoJSON→MVT rendering path
switching works without regression\n\n---\n\n## Release note\n**Fix:**
Labels in the **Create index** flow now render with the default\n**Use
vector tiles** scaling as soon as label styling is applied (or\nafter
save), without requiring a scaling toggle.\n\n---\n\n### Checklist\n-
[x] No new UI strings (i18n N/A); follows EUI sentence case \n- [x] No
HTTP API or security changes \n- [ ] Unit tests updated/added *(none in
this PR; validated manually)* \n- [x] Include release note \n- [ ]
Labels (`release_note:*`, `backport:*`, `review`, `community`)\nwill be
applied by maintainers during triage\n\n---\n\n### Identify risks\n-
**Scope:** Limited to Create index / MVT-scaling render path \n-
**Performance:** `with_labels` adds small label points per tile;
only\nused when labels are enabled\n- **Mitigation:** Refresh is scoped
to the affected layer; token\ngeneration avoids loops\n\n---\n\n###
Validation\n```bash\nnvm use 22.17.1\nyarn kbn bootstrap\nyarn
lint\nyarn test:jest x-pack/platform/plugins/shared/maps\nyarn es
snapshot --license trial\nyarn start\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3b3adac2e24a84f216bec2d0884114013b03854a"}},{"branch":"8.19","label":"v8.19.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.1","label":"v9.1.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/241219","number":241219,"state":"MERGED","mergeCommit":{"sha":"7e6660eee2c149744580221d02a1a4987f5ea51c","message":"[9.2]
[Maps] Show labels after saving edits while staying on Vector tiles (…
(#240728) (#241219)\n\n# Backport\n\nThis will backport the following
commits from `main` to `9.2`:\n- [[Maps] Show labels after saving edits
while staying on Vector tiles\n(…
(#240728)](https://github.com/elastic/kibana/pull/240728)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Jakob Malmo <jakobmalmo@protonmail.com>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>"}}]}] BACKPORT-->

Co-authored-by: Jakob Malmo <jakobmalmo@protonmail.com>
nreese added a commit that referenced this pull request Oct 30, 2025
…tiles (… (#240728) (#241285)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Maps] Show labels after saving edits while staying on Vector tiles
(… (#240728)](#240728)

<!--- Backport version: 10.1.0 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Jakob
Malmo","email":"jakobmalmo@protonmail.com"},"sourceCommit":{"committedDate":"2025-10-30T03:10:46Z","message":"[Maps]
Show labels after saving edits while staying on Vector tiles (…
(#240728)\n\nCloses #240727 \n---\n\n## Summary\nWhen using **Maps →
Create index (Draw shapes)**, the new layer defaults\nto **Scaling → Use
vector tiles**.\nAdding label styling (Fixed or By value) previously did
**not** display\nlabels until the user manually changed Scaling to
**Limit results** and\nback.\nThis PR makes labels appear immediately
(after styling or save) on\nvector-tiles layers by:\n\n- Requesting MVT
tiles with **`with_labels=true`** when label styling is\nactive\n-
**Refreshing** tile sources when label styling changes and after\nsaving
edits\n- Properly routing **GEOJSON_VECTOR** layers with `scalingType:
MVT`\nthrough the MVT pipeline\n\nElastic’s `_mvt` API returns suggested
label points when\n`with_labels=true`; this wires Kibana to use that
path and refresh tiles\naccordingly.\nKibana’s **Vector layer** docs
describe the scaling modes this aligns\nwith.\n\n> 🧠 Investigation and
solution developed with the help of the large\nlanguage model **Claude
Sonnet 4.5**, used to analyze the root cause and\nassist in
implementation.\n\n---\n\n### What changed
(files)\n1.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx`**\n•
Snapshots the current label descriptor and `hasLabels` flag into
the\nsource request meta; any change invalidates the cached tiles
and\nre-fetches through the MVT
layer.\n\n2.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts`**\n•
Respect `isForceRefresh` (was checking
only\n`forceRefreshDueToDrawing`).\n• Generate a new token only when
`hasLabels` or buffer change (prevents\nloops).\n• Include
**`with_labels=true`** in tile requests when label styling is\nactive
(Elasticsearch `_mvt` label
points).\n\n3.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx`**\n•
When Create index uses MVT scaling, emit an
**MvtVectorLayer**\ndescriptor so the layer starts on the MVT pipeline
and picks up the\nlabel-refresh logic.\n\n> **Note:**
`geojson_vector_layer.tsx` is restored to match `main` (no\nMVT source
added by GeoJSON). Vector-tile rendering remains owned
by\n`MvtVectorLayer`.\n\nPer Elastic’s docs, the vector-tile search API
can return suggested\nlabel points when `with_labels=true`; the Vector
layer docs describe\nwhen to use **Use vector tiles** vs **Limit
results**. This change wires\nKibana’s MVT path to request tiles with
labels and refresh them when\nstyling/saving, so labels render without a
scaling toggle.\n\n\n\n---\n\n### Why\nDuring the Create index workflow,
vector-tiles scaling is the default. \nTiles are built server-side from
indexed data, so unsaved edits and\nlabel changes don’t show until tiles
are refreshed.\nBy requesting tiles with labels and refreshing them on
style or save,\nlabels now render as expected without a manual scaling
toggle.\n\n---\n\n### Before / After\n| Before | After |\n|:--|:--|\n|
Create index → Draw point → Add label → Label missing until
Scaling\nchanged | Create index → Draw point → Add label → Label
appears\ninstantly (no toggle needed) |\n\n**Before (GIF):**
\n\n![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)\n\n**After
(GIF):**
\n\n![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)\n\n---\n\n###
Testing\nThis change was verified manually; **no new unit or functional
tests\nwere added** in this PR.\n\n**Manual validation steps**\n- Add
layer → Create index\n- Draw a point or other shape\n- Add label styling
(Fixed value and By value) → labels appear\nimmediately without toggling
scaling\n- Modify label text → label updates in real time\n- Toggle
labels on/off → tiles refresh correctly\n- Save edits → labels persist
after saving\n- No crashes, flickering, or infinite refresh
loops\n\n**Test coverage note**\nExisting Jest tests for Maps layers and
source syncing still pass. \nPotential follow-ups:\n- Label style change
triggers `isForceRefresh=true`\n- `with_labels=true` included in MVT
tile requests when labels are\nactive\n- GeoJSON→MVT rendering path
switching works without regression\n\n---\n\n## Release note\n**Fix:**
Labels in the **Create index** flow now render with the default\n**Use
vector tiles** scaling as soon as label styling is applied (or\nafter
save), without requiring a scaling toggle.\n\n---\n\n### Checklist\n-
[x] No new UI strings (i18n N/A); follows EUI sentence case \n- [x] No
HTTP API or security changes \n- [ ] Unit tests updated/added *(none in
this PR; validated manually)* \n- [x] Include release note \n- [ ]
Labels (`release_note:*`, `backport:*`, `review`, `community`)\nwill be
applied by maintainers during triage\n\n---\n\n### Identify risks\n-
**Scope:** Limited to Create index / MVT-scaling render path \n-
**Performance:** `with_labels` adds small label points per tile;
only\nused when labels are enabled\n- **Mitigation:** Refresh is scoped
to the affected layer; token\ngeneration avoids loops\n\n---\n\n###
Validation\n```bash\nnvm use 22.17.1\nyarn kbn bootstrap\nyarn
lint\nyarn test:jest x-pack/platform/plugins/shared/maps\nyarn es
snapshot --license trial\nyarn start\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3b3adac2e24a84f216bec2d0884114013b03854a","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Presentation","💝community","Feature:Maps","backport:version","v9.3.0","v8.19.7","v9.1.7","v9.2.1"],"title":"[Maps]
Show labels after saving edits while staying on Vector tiles
(…","number":240728,"url":"https://github.com/elastic/kibana/pull/240728","mergeCommit":{"message":"[Maps]
Show labels after saving edits while staying on Vector tiles (…
(#240728)\n\nCloses #240727 \n---\n\n## Summary\nWhen using **Maps →
Create index (Draw shapes)**, the new layer defaults\nto **Scaling → Use
vector tiles**.\nAdding label styling (Fixed or By value) previously did
**not** display\nlabels until the user manually changed Scaling to
**Limit results** and\nback.\nThis PR makes labels appear immediately
(after styling or save) on\nvector-tiles layers by:\n\n- Requesting MVT
tiles with **`with_labels=true`** when label styling is\nactive\n-
**Refreshing** tile sources when label styling changes and after\nsaving
edits\n- Properly routing **GEOJSON_VECTOR** layers with `scalingType:
MVT`\nthrough the MVT pipeline\n\nElastic’s `_mvt` API returns suggested
label points when\n`with_labels=true`; this wires Kibana to use that
path and refresh tiles\naccordingly.\nKibana’s **Vector layer** docs
describe the scaling modes this aligns\nwith.\n\n> 🧠 Investigation and
solution developed with the help of the large\nlanguage model **Claude
Sonnet 4.5**, used to analyze the root cause and\nassist in
implementation.\n\n---\n\n### What changed
(files)\n1.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx`**\n•
Snapshots the current label descriptor and `hasLabels` flag into
the\nsource request meta; any change invalidates the cached tiles
and\nre-fetches through the MVT
layer.\n\n2.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts`**\n•
Respect `isForceRefresh` (was checking
only\n`forceRefreshDueToDrawing`).\n• Generate a new token only when
`hasLabels` or buffer change (prevents\nloops).\n• Include
**`with_labels=true`** in tile requests when label styling is\nactive
(Elasticsearch `_mvt` label
points).\n\n3.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx`**\n•
When Create index uses MVT scaling, emit an
**MvtVectorLayer**\ndescriptor so the layer starts on the MVT pipeline
and picks up the\nlabel-refresh logic.\n\n> **Note:**
`geojson_vector_layer.tsx` is restored to match `main` (no\nMVT source
added by GeoJSON). Vector-tile rendering remains owned
by\n`MvtVectorLayer`.\n\nPer Elastic’s docs, the vector-tile search API
can return suggested\nlabel points when `with_labels=true`; the Vector
layer docs describe\nwhen to use **Use vector tiles** vs **Limit
results**. This change wires\nKibana’s MVT path to request tiles with
labels and refresh them when\nstyling/saving, so labels render without a
scaling toggle.\n\n\n\n---\n\n### Why\nDuring the Create index workflow,
vector-tiles scaling is the default. \nTiles are built server-side from
indexed data, so unsaved edits and\nlabel changes don’t show until tiles
are refreshed.\nBy requesting tiles with labels and refreshing them on
style or save,\nlabels now render as expected without a manual scaling
toggle.\n\n---\n\n### Before / After\n| Before | After |\n|:--|:--|\n|
Create index → Draw point → Add label → Label missing until
Scaling\nchanged | Create index → Draw point → Add label → Label
appears\ninstantly (no toggle needed) |\n\n**Before (GIF):**
\n\n![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)\n\n**After
(GIF):**
\n\n![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)\n\n---\n\n###
Testing\nThis change was verified manually; **no new unit or functional
tests\nwere added** in this PR.\n\n**Manual validation steps**\n- Add
layer → Create index\n- Draw a point or other shape\n- Add label styling
(Fixed value and By value) → labels appear\nimmediately without toggling
scaling\n- Modify label text → label updates in real time\n- Toggle
labels on/off → tiles refresh correctly\n- Save edits → labels persist
after saving\n- No crashes, flickering, or infinite refresh
loops\n\n**Test coverage note**\nExisting Jest tests for Maps layers and
source syncing still pass. \nPotential follow-ups:\n- Label style change
triggers `isForceRefresh=true`\n- `with_labels=true` included in MVT
tile requests when labels are\nactive\n- GeoJSON→MVT rendering path
switching works without regression\n\n---\n\n## Release note\n**Fix:**
Labels in the **Create index** flow now render with the default\n**Use
vector tiles** scaling as soon as label styling is applied (or\nafter
save), without requiring a scaling toggle.\n\n---\n\n### Checklist\n-
[x] No new UI strings (i18n N/A); follows EUI sentence case \n- [x] No
HTTP API or security changes \n- [ ] Unit tests updated/added *(none in
this PR; validated manually)* \n- [x] Include release note \n- [ ]
Labels (`release_note:*`, `backport:*`, `review`, `community`)\nwill be
applied by maintainers during triage\n\n---\n\n### Identify risks\n-
**Scope:** Limited to Create index / MVT-scaling render path \n-
**Performance:** `with_labels` adds small label points per tile;
only\nused when labels are enabled\n- **Mitigation:** Refresh is scoped
to the affected layer; token\ngeneration avoids loops\n\n---\n\n###
Validation\n```bash\nnvm use 22.17.1\nyarn kbn bootstrap\nyarn
lint\nyarn test:jest x-pack/platform/plugins/shared/maps\nyarn es
snapshot --license trial\nyarn start\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3b3adac2e24a84f216bec2d0884114013b03854a"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.1"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240728","number":240728,"mergeCommit":{"message":"[Maps]
Show labels after saving edits while staying on Vector tiles (…
(#240728)\n\nCloses #240727 \n---\n\n## Summary\nWhen using **Maps →
Create index (Draw shapes)**, the new layer defaults\nto **Scaling → Use
vector tiles**.\nAdding label styling (Fixed or By value) previously did
**not** display\nlabels until the user manually changed Scaling to
**Limit results** and\nback.\nThis PR makes labels appear immediately
(after styling or save) on\nvector-tiles layers by:\n\n- Requesting MVT
tiles with **`with_labels=true`** when label styling is\nactive\n-
**Refreshing** tile sources when label styling changes and after\nsaving
edits\n- Properly routing **GEOJSON_VECTOR** layers with `scalingType:
MVT`\nthrough the MVT pipeline\n\nElastic’s `_mvt` API returns suggested
label points when\n`with_labels=true`; this wires Kibana to use that
path and refresh tiles\naccordingly.\nKibana’s **Vector layer** docs
describe the scaling modes this aligns\nwith.\n\n> 🧠 Investigation and
solution developed with the help of the large\nlanguage model **Claude
Sonnet 4.5**, used to analyze the root cause and\nassist in
implementation.\n\n---\n\n### What changed
(files)\n1.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx`**\n•
Snapshots the current label descriptor and `hasLabels` flag into
the\nsource request meta; any change invalidates the cached tiles
and\nre-fetches through the MVT
layer.\n\n2.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_source_data.ts`**\n•
Respect `isForceRefresh` (was checking
only\n`forceRefreshDueToDrawing`).\n• Generate a new token only when
`hasLabels` or buffer change (prevents\nloops).\n• Include
**`with_labels=true`** in tile requests when label styling is\nactive
(Elasticsearch `_mvt` label
points).\n\n3.\n**`x-pack/platform/plugins/shared/maps/public/classes/layers/wizards/new_vector_layer_wizard/wizard.tsx`**\n•
When Create index uses MVT scaling, emit an
**MvtVectorLayer**\ndescriptor so the layer starts on the MVT pipeline
and picks up the\nlabel-refresh logic.\n\n> **Note:**
`geojson_vector_layer.tsx` is restored to match `main` (no\nMVT source
added by GeoJSON). Vector-tile rendering remains owned
by\n`MvtVectorLayer`.\n\nPer Elastic’s docs, the vector-tile search API
can return suggested\nlabel points when `with_labels=true`; the Vector
layer docs describe\nwhen to use **Use vector tiles** vs **Limit
results**. This change wires\nKibana’s MVT path to request tiles with
labels and refresh them when\nstyling/saving, so labels render without a
scaling toggle.\n\n\n\n---\n\n### Why\nDuring the Create index workflow,
vector-tiles scaling is the default. \nTiles are built server-side from
indexed data, so unsaved edits and\nlabel changes don’t show until tiles
are refreshed.\nBy requesting tiles with labels and refreshing them on
style or save,\nlabels now render as expected without a manual scaling
toggle.\n\n---\n\n### Before / After\n| Before | After |\n|:--|:--|\n|
Create index → Draw point → Add label → Label missing until
Scaling\nchanged | Create index → Draw point → Add label → Label
appears\ninstantly (no toggle needed) |\n\n**Before (GIF):**
\n\n![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)\n\n**After
(GIF):**
\n\n![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)\n\n---\n\n###
Testing\nThis change was verified manually; **no new unit or functional
tests\nwere added** in this PR.\n\n**Manual validation steps**\n- Add
layer → Create index\n- Draw a point or other shape\n- Add label styling
(Fixed value and By value) → labels appear\nimmediately without toggling
scaling\n- Modify label text → label updates in real time\n- Toggle
labels on/off → tiles refresh correctly\n- Save edits → labels persist
after saving\n- No crashes, flickering, or infinite refresh
loops\n\n**Test coverage note**\nExisting Jest tests for Maps layers and
source syncing still pass. \nPotential follow-ups:\n- Label style change
triggers `isForceRefresh=true`\n- `with_labels=true` included in MVT
tile requests when labels are\nactive\n- GeoJSON→MVT rendering path
switching works without regression\n\n---\n\n## Release note\n**Fix:**
Labels in the **Create index** flow now render with the default\n**Use
vector tiles** scaling as soon as label styling is applied (or\nafter
save), without requiring a scaling toggle.\n\n---\n\n### Checklist\n-
[x] No new UI strings (i18n N/A); follows EUI sentence case \n- [x] No
HTTP API or security changes \n- [ ] Unit tests updated/added *(none in
this PR; validated manually)* \n- [x] Include release note \n- [ ]
Labels (`release_note:*`, `backport:*`, `review`, `community`)\nwill be
applied by maintainers during triage\n\n---\n\n### Identify risks\n-
**Scope:** Limited to Create index / MVT-scaling render path \n-
**Performance:** `with_labels` adds small label points per tile;
only\nused when labels are enabled\n- **Mitigation:** Refresh is scoped
to the affected layer; token\ngeneration avoids loops\n\n---\n\n###
Validation\n```bash\nnvm use 22.17.1\nyarn kbn bootstrap\nyarn
lint\nyarn test:jest x-pack/platform/plugins/shared/maps\nyarn es
snapshot --license trial\nyarn start\n\n---------\n\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"3b3adac2e24a84f216bec2d0884114013b03854a"}},{"branch":"8.19","label":"v8.19.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.1","label":"v9.1.7","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/241219","number":241219,"state":"MERGED","mergeCommit":{"sha":"7e6660eee2c149744580221d02a1a4987f5ea51c","message":"[9.2]
[Maps] Show labels after saving edits while staying on Vector tiles (…
(#240728) (#241219)\n\n# Backport\n\nThis will backport the following
commits from `main` to `9.2`:\n- [[Maps] Show labels after saving edits
while staying on Vector tiles\n(…
(#240728)](https://github.com/elastic/kibana/pull/240728)\n\n\n\n###
Questions ?\nPlease refer to the [Backport
tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by:
Jakob Malmo <jakobmalmo@protonmail.com>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>"}}]}] BACKPORT-->

Co-authored-by: Jakob Malmo <jakobmalmo@protonmail.com>
@jmalmo jmalmo deleted the maps/fix-vector-tile-labels-after-save branch October 30, 2025 15:52
ana-davydova pushed a commit to ana-davydova/kibana that referenced this pull request Nov 3, 2025
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):**  

![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)

**After (GIF):**  

![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)

---

### 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>
albertoblaz pushed a commit to albertoblaz/kibana that referenced this pull request Nov 4, 2025
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):**  

![kibana_gif_not_working](https://github.com/user-attachments/assets/6295581d-a902-47a3-aeea-4f8dfb616793)

**After (GIF):**  

![kibana_working_gif](https://github.com/user-attachments/assets/e859c649-6eb1-4139-adea-6bd7ed5f7986)

---

### 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels 💝community Feature:Maps release_note:fix Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v8.19.7 v9.1.7 v9.2.1 v9.3.0

4 participants