DisplayFilterInfo

AMD: require(["esri/layers/support/DisplayFilterInfo"], (DisplayFilterInfo) => { /* code goes here */ });
ESM: import DisplayFilterInfo from "@arcgis/core/layers/support/DisplayFilterInfo.js";
Class: esri/layers/support/DisplayFilterInfo
Inheritance: DisplayFilterInfoAccessor
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 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

DisplayFilterInfo

Constructor
new DisplayFilterInfo(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
Show inherited properties Hide inherited properties
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

activeFilterId

Property
activeFilterId String |null |undefined

The active filter id. This filter is currently applied to the layer. The active filter is set when the display filter mode is manual.

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

filters

Property
filters Collection<DisplayFilter>autocast

A collection of filters that define which features should be rendered on the display.

mode

Property
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

Show inherited methods Hide inherited methods
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

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
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();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key 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.

clone

Method
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
Type Description
this A deep clone of the class instance that invoked this method.

fromJSON

Method
fromJSON(json){* |null |undefined}static

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.

Parameter
json Object

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
Type Description
* | null | undefined Returns a new instance of this class.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type 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");
}

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

toJSON

Method
toJSON(){Object}

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
Type Description
Object The ArcGIS portal JSON representation of an instance of this class.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.