require(["esri/layers/support/DisplayFilterInfo"], (DisplayFilterInfo) => { /* code goes here */ });
import DisplayFilterInfo from "@arcgis/core/layers/support/DisplayFilterInfo.js";
esri/layers/support/DisplayFilterInfo
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 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 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.
- See also
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
The active filter id. | DisplayFilterInfo | ||
The name of the class. | Accessor | ||
A collection of filters that define which features should be rendered on the display. | DisplayFilterInfo | ||
The display filter mode. | DisplayFilterInfo |
Property Details
-
The active filter id. This filter is currently applied to the layer. The active filter is set when the display filter mode is
manual
.
-
filters
filters Collection<DisplayFilter>autocast
-
A collection of filters that define which features should be rendered on the display.
-
mode
mode String
-
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.
Possible Values:"manual" |"scale"
- Default Value:"manual"
Example// loop through the layer's display filters and create a dropdown to select the active filter layer.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 dropdown filterSelect.addEventListener("calciteSelectChange", () => { layer.displayFilterInfo.activeFilterId = filterSelect.value; });
-
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
this | Creates a deep clone of this object. | DisplayFilterInfo | |
Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. | DisplayFilterInfo | ||
Returns true if a named group of handles exist. | Accessor | ||
Removes a group of handles owned by the object. | Accessor | ||
Converts an instance of this class to its ArcGIS portal JSON representation. | DisplayFilterInfo |
Method Details
-
Inherited from Accessor
-
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
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.
ReturnsType Description this A deep clone of the class instance that invoked this method.
-
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.Parameterjson ObjectA 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
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from Accessor -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
Inherited from Accessor
-
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
toJSON
toJSON(){Object}
-
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
ReturnsType Description Object The ArcGIS portal JSON representation of an instance of this class.