Filters
Last updated
Was this helpful?
Was this helpful?
// 1. Simple filter: single condition
felt.setLayerFilters({
layerId: "layer-1",
filters: ["AREA", "gt", 30_000],
});
// 2. Basic compound filter: two conditions with AND
felt.setLayerFilters({
layerId: "layer-1",
filters: [
["AREA", "gt", 30_000], // First condition
"and", // Logic operator
["COLOR", "eq", "red"] // Second condition
]
});
// 3. Complex filter: three or more conditions require nesting
// ⚠️ IMPORTANT: Filters use a tree structure, not a flat list
felt.setLayerFilters({
layerId: "layer-1",
filters: [
["AREA", "gt", 30_000], // First condition
"and", // First logic operator
[ // Nested group starts
["COLOR", "eq", "red"], // Second condition
"and", // Second logic operator
["TYPE", "eq", "residential"] // Third condition
] // Nested group ends
]
});
// 4. Even more complex: four conditions with proper nesting
// Visual structure:
// AND
// / \
// condition AND
// / \
// condition AND
// / \
// condition condition
felt.setLayerFilters({
layerId: "layer-1",
filters: [
["AREA", "gt", 30_000], // First condition
"and",
[
["COLOR", "eq", "red"], // Second condition
"and",
[
["TYPE", "eq", "residential"], // Third condition
"and",
["YEAR", "gt", 2000] // Fourth condition
]
]
]
});
// 5. Mixed operators: combining AND and OR
// Visual structure:
// AND
// / \
// condition OR
// / \
// condition condition
felt.setLayerFilters({
layerId: "layer-1",
filters: [
["AREA", "gt", 30_000], // Must have large area
"and",
[
["COLOR", "eq", "red"], // Must be either red
"or",
["TYPE", "eq", "residential"] // OR residential type
]
]
});