You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varff=require('feature-filter');// will match a feature with class of street_limited,// AND an admin_level less than or equal to 3,// that's NOT a polygon.varfilter=["all",["==","class","street_limited"],["<=","admin_level",3],["!=","$type","Polygon"]]// will match a feature that has a class of// wetland OR wetland_noveg.// ["in", "class", "wetland", "wetland_noveg"]// testFilter will be a function that returns a booleanvartestFilter=ff(filter);// Layer feature that you're testing. Must have type// and properties keys.varfeature={type: 2,properties: {class: "street_limited"admin_level: 1}};// will return a boolean based on whether the feature matched the filterreturntestFilter(feature);
to
var ff = require('feature-filter');
// will match a feature with class of street_limited,
// AND an admin_level less than or equal to 3,
// that's NOT a polygon.
var filter = [
"all",
["==", "class", "street_limited"],
["<=", "admin_level", 3],
["!=", "$type", "Polygon"]
]
// will match a feature that has a class of
// wetland OR wetland_noveg.
// ["in", "class", "wetland", "wetland_noveg"]
// testFilter will be a function that returns a boolean
var testFilter = ff(filter);
// Layer feature that you're testing. Must have type
// and properties keys.
var feature = {
type: 2,
properties: {
- class: "street_limited"+ class: "street_limited", //WARNING: MISSING COMMA
admin_level: 1
}
};
// will return a boolean based on whether the feature matched the filter
-return testFilter(feature);+return testFilter(null, feature); // <-- MAIN CHANGE HERE
The reason why last line is now wrong and would always return false is that a second, unused argument ('g') has been added to the generated filter at this line .
I'm sure there has to be a good reason for this 😄 but I'd like some explanation.
The text was updated successfully, but these errors were encountered:
The code from the readme of style-spec should now change from
to
The reason why last line is now wrong and would always return false is that a second, unused argument (
'g'
) has been added to the generated filter at this line .I'm sure there has to be a good reason for this 😄 but I'd like some explanation.
The text was updated successfully, but these errors were encountered: