import DisplayFilterInfo from "@arcgis/core/layers/support/DisplayFilterInfo.js";const DisplayFilterInfo = await $arcgis.import("@arcgis/core/layers/support/DisplayFilterInfo.js");- Inheritance
- DisplayFilterInfo→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.32
Display filters are associated with a given layer and control which features are visible on the map. They allow you to display a subset of features while retaining access to all features for querying and analysis. Unlike FeatureLayer.definitionExpression, which filters data at the source level, display filters only affect visibility on the map. Therefore display filters should be ignored when querying data to present to users.
Display filters are useful, for example, in a map of rivers across the United States, where you might want to show different types of rivers based on the zoom level. A scale-dependent display filter could be applied to show only major rivers (like the Mississippi or Missouri) when zoomed out, giving a broad overview of the river network in the country. As the user zooms in, the filter could automatically start displaying smaller rivers or tributaries that are otherwise too detailed to show at smaller scales. In agricultural field mapping, a manual display filter could be applied to display the fields based on specific parameters, such as pest control, crop health, or irrigation, regardless of zoom level. The user can toggle between these display filters, allowing them to focus on the most relevant information for their needs.
A layer can contain multiple display filters, but only one filter can be applied at a time. The mode defines the type of display filters that are associated with a layer.
To optimize memory usage for rendering, display filters may be appended to the layer's definitionExpression when querying the service.
As a result, the filtered features may not be available on the client for executing layer view queries.
To determine if all features are available in the view, check the layer view's hasAllFeaturesInView
property when layer view's dataUpdating is false. If false, the layer view does not have all features in the view
and you should query the layer instead.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| readonly inherited | ||
| | ||
| "manual" | "scale" | |
filters
- Type
- Collection<DisplayFilter>
A collection of filters that define which features should be rendered on the display.
mode
- Type
- "manual" | "scale"
The display filter mode. There are two modes to specify the active display filter:
-
Scale-dependent filter: Each display filter on a layer is associated with a visible scale range. The active display filter is determined by the current scale of the view. This approach is useful for layers with dense features at small scales where rendering can become difficult to interpret or slow. When setting scale ranges, note that scale boundaries are treated as follows:
- The minScale is inclusive, meaning the filter is applied at this scale and all larger scales (i.e., when zoomed in). The maxScale is exclusive, meaning the filter is applied up to (but not including) this scale.
- Scale range filters can overlap or have gaps:
- If filters overlap, the first filter in the filters is applied.
- If there are scale gaps between filters, no filter is applied.
-
Manual filter: Each display filter is defined by a where clause and does not rely on scale. Only one filter can be active at a time, and it must be manually selected by setting the activeFilterId property to the id property of the filter. This filter mode is useful for making visual comparisons between different subsets of data.
- Default value
- "manual"
- Example
- // loop through the layer's display filters and create a dropdown to select the active filterlayer.displayFilterInfo.filters.forEach((filter) => {const option = document.createElement("calcite-option");option.value = filter.id;option.innerText = filter.title;filterSelect.appendChild(option);});// set the active filter when the user selects a filter from the dropdownfilterSelect.addEventListener("calciteSelectChange", () => {layer.displayFilterInfo.activeFilterId = filterSelect.value;});
Methods
| Method | Signature | Class |
|---|---|---|
| inherited static | fromJSON(json: any): any | |
| inherited | clone(): this | |
| inherited | toJSON(): any |
fromJSON
- Signature
-
fromJSON (json: any): any
Creates a new instance of this class and initializes it with values from a JSON object
generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a
toJSON()
method from another ArcGIS product. See the Using fromJSON()
topic in the Guide for details and examples of when and how to use this function.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects. | |
- Returns
- any
Returns a new instance of this class.
clone
- Signature
-
clone (): this
Creates a deep clone of this object. Any properties that store values by reference will be assigned copies of the referenced values on the cloned instance.
- Returns
- this
A deep clone of the class instance that invoked this method.
toJSON
- Signature
-
toJSON (): any
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
- Returns
- any
The ArcGIS portal JSON representation of an instance of this class.