-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
query*Features and MapMouseEvent.features returns a null
feature property as "null"
#8497
Comments
Same issue with version |
Find with null becomes "null" (see mapbox/mapbox-gl-js#8497)
Can somebody with knowledge of the codebase comment where source / solution of this bug could be found? I may be able to create a PR if given a hint. |
Wanted to flag that this is still an issue that I just hit. |
I hope this is an acceptable change, although I don't know the complete requirements of this package, but this fix will solve mapbox/mapbox-gl-js#8497. I also have a hard time thinking of a reason it would make sense to have null as a string `"null"` because of the ambiguity it brings.
Thought I would add that this PR fixes this issue if it's merged: mapbox/vt-pbf#39 |
can please someone check this pr? |
I hope this is an acceptable change, although I don't know the complete requirements of this package, but this fix will solve mapbox/mapbox-gl-js#8497. I also have a hard time thinking of a reason it would make sense to have null as a string `"null"` because of the ambiguity it brings. Co-authored-by: Vladimir Agafonkin <agafonkin@gmail.com>
Just flagging that I'm still running into this issue. |
copypaste workaround if you know your data has not actual string values called "null" const features = map.queryRenderedFeatures(...)
for (let i = 0; i < features.length; i++) {
for (const key of Object.keys(features[i].properties)) {
if (features[i].properties[key] === 'null') {
features[i].properties[key] = null
}
}
} |
mapbox-gl-js version: v1.1.1 (true for previous versions too)
browser: Chrome ...
Link to Demonstration
https://codepen.io/anon/pen/rXBGBb?editors=1001#anon-login
Expected Behavior
I would expect a returned value of property on a geojson feature to remain
null
and not become"null"
.Actual Behavior
A null property geojson feature e.g
{ my_property: null }
is converted to a string{ my_property: 'null' }
when queried (i.equerySourceFeatures
) or inMapMouseEvent
's features.By inspecting the
_data
of the source I can see that null values of feature properties are stored as expected.The text was updated successfully, but these errors were encountered: