LogoLogo
Sign upHelp CenterContactSocial
JS SDK API Reference
JS SDK API Reference
  • API Reference
  • @feltmaps/js-sdk
  • Elements
    • CircleElementCreate
    • CircleElementRead
    • CircleElementUpdate
    • Element
    • ElementChangeCallbackParams
    • ElementCreate
    • ElementGroup
    • ElementGroupChangeCallbackParams
    • ElementUpdate
    • ElementsController
    • GetElementGroupsConstraint
    • GetElementsConstraint
    • HighlighterElementCreate
    • HighlighterElementRead
    • HighlighterElementUpdate
    • ImageElementCreate
    • ImageElementRead
    • ImageElementUpdate
    • LinkElementRead
    • MarkerElementCreate
    • MarkerElementRead
    • MarkerElementUpdate
    • NoteElementCreate
    • NoteElementRead
    • NoteElementUpdate
    • PathElementCreate
    • PathElementRead
    • PathElementUpdate
    • PlaceElementCreate
    • PlaceElementRead
    • PlaceElementUpdate
    • PolygonElementCreate
    • PolygonElementRead
    • PolygonElementUpdate
    • TextElementCreate
    • TextElementRead
    • TextElementUpdate
  • Interactions
    • InteractionsController
    • MapInteractionEvent
  • Layers
    • AggregationConfig
    • AggregationMethod
    • CreateLayersFromGeoJsonParams
    • DataOnlyLayer
    • FeltTiledVectorSource
    • FilterExpression
    • FilterLogicGate
    • FilterTernary
    • Filters
    • GeoJsonDataVectorSource
    • GeoJsonFileVectorSource
    • GeoJsonUrlVectorSource
    • GeometryFilter
    • GetLayerCalculationParams
    • GetLayerCategoriesGroup
    • GetLayerCategoriesParams
    • GetLayerGroupsConstraint
    • GetLayerHistogramBin
    • GetLayerHistogramParams
    • GetLayersConstraint
    • GetRenderedFeaturesConstraint
    • Layer
    • LayerBoundaries
    • LayerChangeCallbackParams
    • LayerCommon
    • LayerFeature
    • LayerFilters
    • LayerGroup
    • LayerGroupChangeCallbackParams
    • LayerProcessingStatus
    • LayerSchema
    • LayerSchemaAttribute
    • LayerSchemaBooleanAttribute
    • LayerSchemaCommonAttribute
    • LayerSchemaDateAttribute
    • LayerSchemaDateTimeAttribute
    • LayerSchemaNumericAttribute
    • LayerSchemaTextAttribute
    • LayersController
    • LegendItem
    • LegendItemChangeCallbackParams
    • LegendItemIdentifier
    • LegendItemsConstraint
    • MultiAggregationConfig
    • RasterBand
    • RasterLayer
    • RasterLayerSource
    • RasterValue
    • UpdateLayerParams
    • ValueConfiguration
    • VectorLayer
  • Main
    • Felt
    • FeltController
    • FeltEmbedOptions
  • Misc
    • MapDetails
    • MiscController
  • Selection
    • ElementGroupNode
    • ElementNode
    • EntityNode
    • FeatureNode
    • FeatureSelection
    • LayerGroupNode
    • LayerNode
    • SelectionController
  • Shared
    • FeltBoundary
    • FeltZoom
    • GeoJsonFeature
    • GeoJsonGeometry
    • GeoJsonProperties
    • LatLng
    • LineStringGeometry
    • LngLatTuple
    • MultiLineStringGeometry
    • MultiPointGeometry
    • MultiPolygonGeometry
    • PointGeometry
    • PolygonGeometry
    • SetVisibilityRequest
    • SortConfig
    • SortDirection
  • Tools
    • CircleToolSettings
    • ConfigurableToolType
    • HighlighterToolSettings
    • InputToolSettings
    • LineToolSettings
    • MarkerToolSettings
    • NoteToolSettings
    • PinToolSettings
    • PlaceFrame
    • PlaceSymbol
    • PolygonToolSettings
    • RouteToolSettings
    • TextToolSettings
    • ToolSettingsChangeEvent
    • ToolSettingsMap
    • ToolType
    • ToolsController
  • UI
    • OnMapInteractionsOptions
    • UiController
    • UiControlsOptions
  • Viewport
    • SetViewportCenterZoomParams
    • ViewportCenterZoom
    • ViewportConstraints
    • ViewportController
    • ViewportFitBoundsParams
    • ViewportState
Powered by GitBook
On this page
  • Remarks
  • Example

Was this helpful?

Export as PDF
  1. Layers

Filters

PreviousFilterTernaryNextGeoJsonDataVectorSource

Last updated 27 days ago

Was this helpful?


Filters: | | null | boolean

Filters can be used to change which features in a layer are rendered. Filters can be applied to a layer by the method on the Felt controller.

Filters use a tree structure for combining expressions with logical operators, called a. When combining three or more conditions, you must use proper nesting rather than a flat list.

See the examples below for the correct structure to use when building complex filters.

Remarks

The possible operators are:

  • lt: Less than

  • gt: Greater than

  • le: Less than or equal to

  • ge: Greater than or equal to

  • eq: Equal to

  • ne: Not equal to

  • cn: Contains

  • nc: Does not contain

The allowed boolean operators are:

  • and: Logical AND

  • or: Logical OR

Example

// 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
    ]
  ]
});
FilterTernary
FilterExpression
FilterTernary
`setLayerFilters`