-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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: default params to empty object instead of throwing error #2979
Conversation
|
||
map.queryRenderedFeatures(map.project(new LngLat(0, 0)), {foo: 'bar'}); | ||
}); | ||
|
||
t.end(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shared map
across these test cases make me a little nervous but I don't see any immediate harm coming of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally understood! I appreciate you sticking to convention. 😄 Let's leave these tests-as is for now.
@@ -644,7 +644,7 @@ Style.prototype = util.inherit(Evented, { | |||
} | |||
|
|||
var includedSources = {}; | |||
if (params.layers) { | |||
if (params && params.layers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What changed
Added a default empty object
{}
tomap.queryRenderedFeatures()
if nothing is passed through. Currently gl-js throws an error if the query is missing a second parameter. In order to pass linting tests, I had to renameparams
toparameters
within the logic ofqueryRenderedFeatures
.fixes #2969
Tests
Added two new tests that confirm the object is generated if it isn't passed through, and a test that confirms all parameters are preserved in the output (happy to remove this if it's unnecessary).
Refs
#2647
cc @lucaswoj @bhousel @mollymerp