From 61b279de32b8e0fa54f6cf04b86f5ef2cff66874 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Tue, 2 Dec 2025 07:29:15 -0800 Subject: [PATCH 1/3] Fix GeoJSONSource#updateData for symbol layers --- src/source/geojson_source.test.ts | 7 ++----- src/source/geojson_source.ts | 13 +++++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/source/geojson_source.test.ts b/src/source/geojson_source.test.ts index cfc3196e90..21378ee2db 100644 --- a/src/source/geojson_source.test.ts +++ b/src/source/geojson_source.test.ts @@ -949,13 +949,10 @@ describe('GeoJSONSource.shoudReloadTile', () => { tile.latestFeatureIndex = new FeatureIndex(tile.tileID, source.promoteId); tile.latestFeatureIndex.vtLayers = { [GEOJSON_TILE_LAYER_NAME]: { - feature: (i: number) => features[i] || {} + feature: (i: number) => features[i] || {}, + length: features.length } as VectorTileLayerLike }; - - for (let i = 0; i < features.length; i++) { - tile.latestFeatureIndex.insert(features[i] as VectorTileFeatureLike, [], i, 0, 0, false); - } return tile; } diff --git a/src/source/geojson_source.ts b/src/source/geojson_source.ts index efa77338b0..f37318560d 100644 --- a/src/source/geojson_source.ts +++ b/src/source/geojson_source.ts @@ -509,12 +509,13 @@ export class GeoJSONSource extends Evented implements Source { // Update the tile if it PREVIOUSLY contained an updated feature. const layers = tile.latestFeatureIndex.loadVTLayers(); - for (let i = 0; i < tile.latestFeatureIndex.featureIndexArray.length; i++) { - const featureIndex = tile.latestFeatureIndex.featureIndexArray.get(i); - const feature = layers[GEOJSON_TILE_LAYER_NAME].feature(featureIndex.featureIndex); - const id = tile.latestFeatureIndex.getId(feature, GEOJSON_TILE_LAYER_NAME); - if (prevIds.has(id)) { - return true; + if (layers[GEOJSON_TILE_LAYER_NAME]) { + for (let i = 0; i < layers[GEOJSON_TILE_LAYER_NAME].length; i++) { + const feature = layers[GEOJSON_TILE_LAYER_NAME].feature(i); + const id = tile.latestFeatureIndex.getId(feature, GEOJSON_TILE_LAYER_NAME); + if (prevIds.has(id)) { + return true; + } } } From 512b94bdf9142caa78dc8c045f09bb8e35bfb1c5 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Tue, 2 Dec 2025 07:41:52 -0800 Subject: [PATCH 2/3] Add integration regression test --- test/integration/render/run_render_tests.ts | 7 ++- .../mapbox-gl-js#6795/expected.png | Bin 0 -> 96 bytes .../regressions/mapbox-gl-js#6795/style.json | 48 ++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 test/integration/render/tests/regressions/mapbox-gl-js#6795/expected.png create mode 100644 test/integration/render/tests/regressions/mapbox-gl-js#6795/style.json diff --git a/test/integration/render/run_render_tests.ts b/test/integration/render/run_render_tests.ts index 88172b5bbb..a6ecc9e798 100644 --- a/test/integration/render/run_render_tests.ts +++ b/test/integration/render/run_render_tests.ts @@ -12,7 +12,7 @@ import type {Page, Browser} from 'puppeteer'; import {localizeURLs} from '../lib/localize-urls'; import {launchPuppeteer} from '../lib/puppeteer_config'; -import type {default as MapLibreGL, Map as MaplibreMap, CanvasSource, PointLike, StyleSpecification} from '../../../dist/maplibre-gl'; +import type {default as MapLibreGL, Map as MaplibreMap, CanvasSource, GeoJSONSource, PointLike, StyleSpecification} from '../../../dist/maplibre-gl'; const __dirname = dirname(fileURLToPath(import.meta.url)); let maplibregl: typeof MapLibreGL; @@ -677,6 +677,11 @@ async function getImageFromStyle(styleForTest: StyleWithTestData, page: Page): P case 'pauseTiles': map.style.tileManagers[operation[1]].pause(); break; + case 'updateData': { + const source = map.getSource(operation[1]); + await source.updateData(operation[2], true); + break; + } default: if (typeof map[operation[0]] === 'function') { map[operation[0]](...operation.slice(1)); diff --git a/test/integration/render/tests/regressions/mapbox-gl-js#6795/expected.png b/test/integration/render/tests/regressions/mapbox-gl-js#6795/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..f00b82e0fda8b0a882e0e9eb0263547eb062f082 GIT binary patch literal 96 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=>Ygr+Ar*{o4>Ixsd508!FR$Y> fPXIEJ!GXOD4h{^A+xPv=1_^t*`njxgN@xNAgQgU~ literal 0 HcmV?d00001 diff --git a/test/integration/render/tests/regressions/mapbox-gl-js#6795/style.json b/test/integration/render/tests/regressions/mapbox-gl-js#6795/style.json new file mode 100644 index 0000000000..a281786666 --- /dev/null +++ b/test/integration/render/tests/regressions/mapbox-gl-js#6795/style.json @@ -0,0 +1,48 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64, + "operations": [ + ["wait"], + ["updateData", "geojson", {"remove": [0]}], + ["wait"] + ] + } + }, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "FeatureCollection", + "features": [{ + "type": "Feature", + "id": 0, + "geometry": { + "type": "Point", + "coordinates": [0, 0] + }, + "properties": { + "label": "Test" + } + }] + } + } + }, + "sprite": "local://sprites/sprite", + "layers": [ + { + "id": "symbol", + "type": "symbol", + "source": "geojson", + "layout": { + "text-field": ["get", "label"], + "text-size": 24 + }, + "paint": { + "text-color": "#ffffff" + } + } + ] +} From f007782be90bf0545a50ae6bbd4182e46be956e8 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Tue, 2 Dec 2025 07:51:41 -0800 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de9e6b50e5..e0314c4b3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Fix unwanted movement when moving a pitched terrain map at high latitudes; fix freezes when moving a pitched and rotated terrain map at low zoom ([#6775](https://github.com/maplibre/maplibre-gl-js/pull/6775)) (by [@larsmaxfield](https://github.com/larsmaxfield)) - Fix issue with `static` modifier as part of mlt package ([#6796](https://github.com/maplibre/maplibre-gl-js/pull/6796)) (by [@HarelM](https://github.com/HarelM)) - _...Add new stuff here..._ +- Fix `GeoJSONSource#updateData` for symbol layers ([#6801](https://github.com/maplibre/maplibre-gl-js/pull/6801) (by [@lucaswoj](https://github.com/lucaswoj))) ## 5.13.0