Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

queryRenderedFeatures filter is not giving correct result, when using promoteId. #10257

Open
dollysingh3192 opened this issue Jan 5, 2021 · 4 comments
Labels

Comments

@dollysingh3192
Copy link

dollysingh3192 commented Jan 5, 2021

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:
Jan-05-2021 22-09-22 (1)

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:
Jan-05-2021 22-12-30

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:
Jan-06-2021 13-07-08

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.

@dollysingh3192 dollysingh3192 changed the title Mapbox filter is not giving Correct result, when using promotId. Mapbox filter is not giving Correct result, when using promoteId. Jan 5, 2021
@dollysingh3192 dollysingh3192 changed the title Mapbox filter is not giving Correct result, when using promoteId. queryRenderedFeatures filter is not giving correct result, when using promoteId. Jan 6, 2021
@dollysingh3192
Copy link
Author

Mapbox Team, eagerly waiting for your response.

@ansis
Copy link
Contributor

ansis commented Jan 11, 2021

Thanks for reporting this! I think this is the same issue as #2716

Currently only number IDs work properly. The workarounds are using promoteId or switching to numeric IDs. We should try to look at fixing this soon.

@dollysingh3192
Copy link
Author

Thanks, Would be great if this gets fixed in upcoming releases.

@foundryspatial-duncan
Copy link

I think I noticed this bug today, not using promoteId but using a string as the feature id. A result from queryRenderedFeatures doesn't work when passed to setFeatureState; but the same feature does work when it's passed from a click handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants