A layer filter using ["id"] never matches string ids promoted with promoteId

Author: lemunCreated Sep 23, 2026Updated Sep 28, 2026
LabelsbugenhancementPR is more than welcomed

maplibre-gl-js version: 6.11.1 (also 3.x–6.10)

browser: Chromium

Steps to Trigger Behavior

  1. Add a GeoJSON source with promoteId: 'id' whose id properties are strings (e.g. "ak1").
  2. Add a layer with filter: ['in', ['id'], ['literal', ['ak1', 'ak2']]].
  3. queryRenderedFeatures reports feature.id === 'ak1', but the filtered layer draws nothing.

Link to Demonstration

test/examples/select-features-with-boxzoomend-callback.html: shift-drag selects earthquakes (the counter updates), but the highlight layer never draws.

Expected Behavior

['id'] in a filter sees the promoted id, the same one queryRenderedFeatures returns.

Actual Behavior

It matches nothing. ['get', 'id'] works.

Details: full repro and versions tested

Summary

For a GeoJSON source with promoteId, queryRenderedFeatures() reports the promoted value as feature.id — also when it is a string. A layer filter that uses the ["id"] expression on the same source does not see that id: with string ids it matches nothing, on every version tested. (With numeric promoted ids it matches on 5.x and 6.x and matches nothing on 3.x and 4.x.) ["get", "<the promoted property>"] works everywhere.

So feature.id from a query cannot be fed back into an ["id"] filter — which is exactly what the official example "Select features with boxZoomEnd callback" does.

Minimal reproduction

javascript
const ids = ['ak1', 'ak2', 'ak3'];            // try [101, 102, 103] for the numeric case
map.addSource('q', { type: 'geojson', promoteId: 'id', data: { type: 'FeatureCollection', features: ids.map((id, i) => (
  { type: 'Feature', properties: { id }, geometry: { type: 'Point', coordinates: [i * 0.01, 0] } })) } });
map.addLayer({ id: 'base',   type: 'circle', source: 'q' });
map.addLayer({ id: 'byid',   type: 'circle', source: 'q', filter: ['in', ['id'], ['literal', ids.slice(0, 2)]] });
map.addLayer({ id: 'byprop', type: 'circle', source: 'q', filter: ['in', ['get', 'id'], ['literal', ids.slice(0, 2)]] });
map.once('idle', () => console.log(
  map.queryRenderedFeatures({ layers: ['base'] }).map((f) => f.id),   // ['ak3','ak2','ak1']  <- promoted, strings
  map.queryRenderedFeatures({ layers: ['byid'] }).length,             // 0   <- expected 2
  map.queryRenderedFeatures({ layers: ['byprop'] }).length));         // 2
3.6.2 4.7.1 5.24.0 6.10.0 6.11.1
string promoted ids, filter ["id"] 0 of 2 0 of 2 0 of 2 0 of 2 0 of 2
numeric promoted ids, filter ["id"] 0 of 2 0 of 2 2 of 2 2 of 2 2 of 2
either, filter ["get","id"] 2 of 2 2 of 2 2 of 2 2 of 2 2 of 2

Effect on the official example

test/examples/select-features-with-boxzoomend-callback.html (on main and in 6.11.1): the source is earthquakes.geojson with promoteId: 'id', whose ids are strings ("ak16994521"). After a shift-drag the counter shows the number of selected earthquakes, but the orange highlight layer (filter: ['in', ['id'], ['literal', ids]]) never draws anything. Changing the filter to ['in', ['get', 'id'], ['literal', ids]] makes the example work.

Expected

Either ["id"] evaluates to the promoted id (consistent with queryRenderedFeatures and setFeatureState), or the promoteId documentation says that filters do not see promoted ids and the example uses ["get", …].

Not claimed

No claim about vector-tile sources with promoteId, and none about why (the guess — string ids cannot be stored as vector-tile feature ids, and the filter runs on the tile feature — was not checked against the source).

AI disclosure: found and written up with Claude Code (Claude Opus 5.5); I checked the reproduction.