Scale-dependent DisplayFilter

This sample demonstrates how to apply a scale-dependent display filter to a feature layer containing approximately 2.7 million lines representing streams and rivers across the United States. Display filters can be applied to a feature layer and control the visibility of features on the map. It enables you to show only a subset of features while maintaining full access for querying and analysis.

In this case, a scale-dependent filter is used to display only major rivers (such as the Mississippi or Missouri) at smaller zoom levels, providing an overview of the national river network. As the user zooms in, the filter dynamically shows smaller rivers and tributaries too detailed to display at larger scales. This approach improves map performance and reduces visual clutter, ensuring a more efficient and user-friendly experience.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// set a scale dependent display filter for the rivers layer
const layer = new FeatureLayer({
  portalItem: {
    id: "5fbbf39fe52f4cf88c95cce1223a09dd"
  },
  minScale: 0,
  maxScale: 0,
  outFields: ["streamOrder"],
  displayFilterInfo: {
    mode: "scale",
    filters: [
      {
        title: "streamOrder >= 8",
        minScale: 0,
        maxScale: 36_978_595.474_472,
        where: "streamOrder >= 8"
      },
      {
        title: "streamOrder >= 7",
        minScale: 36_978_595.474_472,
        maxScale: 18_489_297.737_236,
        where: "streamOrder >= 7"
      },
      {
        title: "streamOrder >= 6",
        minScale: 18_489_297.737_236,
        maxScale: 4_622_324.434_309,
        where: "streamOrder >= 6"
      },
      {
        title: "streamOrder >= 5",
        minScale: 4_622_324.434_309,
        maxScale: 1_155_581.1_085_775,
        where: "streamOrder >= 5"
      },
      {
        title: "all",
        minScale: 1_155_581.1_085_775,
        maxScale: 0
      }
    ]
  }
});

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

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close