queryRenderedFeatures filter is not giving correct result, when using promoteId.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Good Day,
I have a geojson (similar to below) and I am facing trouble with an expression that works well when used without promoteId.
GeoJson
{
'type': 'FeatureCollection',
'features': [
{
"geometry": {
"type": "Point",
"coordinates": [
8.612079620361328,
-2.932969060251523
]
},
"type": "Feature",
"properties": {
"id": "GMYTEORRGI5DQ",
"sid": "s_133",
"n": "15",
"r": "13",
"s": "312",
"sz": 5.5,
"m": "n",
"ri": 13,
"si": 7
},
"id": 11578
}
]
}
Expected Behavior
Below expression is working fine and extract one feature from Map(Without using promoteId):
mapInstance.queryRenderedFeatures({ layers: ['seat'], filter: ["any", ["==", ["id"], 21762]] });
Working GIF:

Actual Behavior
But on using promoteId in geojson source, the expression is not working at all.
mapInstance.queryRenderedFeatures({ layers: ['seat'], filter: ["any", ["==", ["id"], "GMYTEORRGI5DQ"]] });
Not Working GIF:

However, I noticed that setFilter and setFeatureState work fine with the same expression.
mapInstance.setFilter('seat', ["match", ["id"], "GMYTEORRGI5DQ", true, false]); //Works fine
GIF with setFilter:

No idea why ["id"] filter works with numeric feature id(No promoteId), but ["id"] doesn't work as soon as I apply promoteId in geojson source and try to fetch the feature with string id.
JsBin Link:
Edit: I am attaching a fiddle https://jsfiddle.net/dollysingh3192/w6bzsx84/7/ where on console log on mousemove ["id"] filter returns an empty array.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the queryRenderedFeatures filter behavior when a GeoJSON source uses promoteId, comparing it with the working numeric feature-id case. Reproduce the empty result from the linked fiddle, then compare the ["id"] handling used by queryRenderedFeatures, setFilter, and setFeatureState. Done means string IDs promoted from GeoJSON can be matched by queryRenderedFeatures as expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100