Hosted Land Cover ImageryTileLayer

Explore in the sandboxView live

This sample shows how to add an instance of a hosted ImageryTileLayer to a Map in a MapView. The ImageryTileLayer in this sample shows the National Land Cover Database (NLCD) 2016 land cover types for the United States. Tiled imagery layers can be published and hosted in ArcGIS Online. These layers are image services generated from one or more image files. If an ImageryTileLayer is created using multiple images, the images are mosaicked together into a single image. Source images and raster files are converted to Cloud Raster Format (CRF) when uploaded to your ArcGIS Online organization. See the Publish hosted imagery layers document for more information on hosting your raster data.

How it works

When the application starts, The UI allows the user to specify the land cover type to display and the spatialReference of the view. The user can choose a spatial reference of the view from a drop down. The view spatialReference is changed with the specified spatialReference as shown below and layers are projected to match the spatialReference of the view:

Use dark colors for code blocks
                                                                                                                                                                                                                                           
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
      />
    <title>Hosted Land Cover ImageryTileLayer | Sample | ArcGIS API for JavaScript 4.23</title>
    <script type="module" src="https://js.arcgis.com/calcite-components/1.0.0-beta.79/calcite.esm.js"></script>
    <script nomodule="" src="https://js.arcgis.com/calcite-components/1.0.0-beta.79/calcite.js"></script>
    <link rel="stylesheet" type="text/css"
      href="https://js.arcgis.com/calcite-components/1.0.0-beta.79/calcite.css" />
    <link rel="stylesheet" href="https://js.arcgis.com/4.23/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.23/"></script>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      #infoDiv {
        position: absolute;
        top: 10px;
        right: 10px;
        padding: 10px;
        width: 200px;
        height: 320px;
    </style>
    <script>
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/layers/ImageryTileLayer",
        "esri/layers/FeatureLayer",
        "esri/layers/GroupLayer",
        "esri/renderers/UniqueValueRenderer",
        "esri/renderers/support/UniqueValueInfo",
        "esri/geometry/SpatialReference"
      ], (
        Map,
      ) =>
        (async () => {
          // Reproject the data to the projection selected by the user
          const wkidSelect = document.getElementById("projectWKID");
          wkidSelect.addEventListener("change", () => {
            view.spatialReference = {
              wkid: wkidSelect.value
            };
          });
          const viewSpatialReference = new SpatialReference({
            wkid: wkidSelect.value
          // this states layer will be used as the basemap
          const statesLayer = new FeatureLayer({
            url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2",
            renderer: {
              type: "simple",
              symbol: {
                type: "simple-fill",
                color: "#505050",
                outline: {
                  color: "#DCDCDC",
                  width: "0.5px"
            spatialReference: viewSpatialReference,
            effect: "drop-shadow(-10px, 10px, 6px gray)"
          // land cover types to set when user changes the land cover type
          const landTypes = {
            forests: {
              categories: [
                "Deciduous Forest",
                "Evergreen Forest",
                "Mixed Forest"
              color: ["#006622", "#006622", "#006622", "#006622"]
            developed: {
              categories: [
                "Developed, Open Space",
                "Developed, Low Intensity",
                "Developed, Medium Intensity",
                "Developed, High Intensity"
              color: ["#E5D0DD", "#E08B88", "#FF0000", "#A70000"]
            crops: {
              categories: ["Cultivated Crops"],
              color: ["#A56400"]
            hay: {
              categories: ["Hay/Pasture"],
              color: ["#D3F40E"]
            wetlands: {
              categories: ["Woody Wetlands", "Emergent Herbaceuous Wetlands"],
              color: ["#0073e6", "#0073e6"]
            // initialize the imagery layer with lerc format
          const layer = new ImageryTileLayer({
            url: "https://tiledimageservices.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/NLCD_2016_Land_Cover_L48_20190424/ImageServer",
            format: "lerc",
            renderer: changeLandCoverType(landTypes.forests),
            blendMode: "color-dodge",
            effect: "bloom(0.5, 0.5px, 20%) drop-shadow(1px, 1px, 1px, grey)"
          const groupLayer = new GroupLayer({
            layers: [layer],
            title: "Forested areas 2016"
          const map = new Map({
            basemap: {
              baseLayers: [statesLayer]
            layers: [groupLayer]
          const view = new MapView({
            container: "viewDiv",
            map: map,
            spatialReference: viewSpatialReference,
            center: {
              type: "point",
              x: 0,
              y: 0,
              spatialReference: viewSpatialReference
            scale: 19975114,
            background: {
              color: "#F5F5F5"
          // drop down for changing the land cover types
          const landCoverTypeSelect = document.getElementById("landCoverTypeSelect");
          landCoverTypeSelect.addEventListener("calciteRadioButtonGroupChange",(event) => {
              if (!layer.loaded) {
                return;
              let renderer = layer.renderer.clone();
              const value = event.detail;
          // this function creates a new instance of group and imagery layer whenever
          // the app is loaded or the view projection changes
          document.getElementById("forests").checked = true;
          // this function is called whenever user changes the land cover type
          // from the drop down. It creates a unique value renderer for the
          // land cover type the user selected.
          function changeLandCoverType(landType) {
            const uvr = new UniqueValueRenderer({
              field: "NLCD_Land",
              uniqueValueInfos: []
            landType.categories.forEach((value, i) => {
              const uniqueValue = new UniqueValueInfo({
                symbol: {
                  type: "simple-fill",
                  color: landType.color[i]
            return uvr;
    </script>
  </head>
  <body>
    <div id="viewDiv"></div>
    <div id="infoDiv" class="esri-widget">
      <h4 id="titleText" class="esri-widget__heading esri-editor__title">Land
        cover types - 2016</h4><br>
      <div class="esri-widget">
        <calcite-label><b>Select land type:</b>
          <calcite-radio-button-group name="Select land type" layout="vertical"
            id="landCoverTypeSelect" scale="s">
            <calcite-label layout="inline"><calcite-radio-button id="forests"
                value="forests"
                checked></calcite-radio-button>Forested Areas</calcite-label>
            <calcite-label layout="inline"><calcite-radio-button
                value="developed"></calcite-radio-button>Developed Areas</calcite-label>
            <calcite-label layout="inline"><calcite-radio-button value="crops"></calcite-radio-button>Cultivated
              Areas</calcite-label>
            <calcite-label layout="inline"><calcite-radio-button value="hay"></calcite-radio-button>Hay/Pasture
              Areas</calcite-label>
            <calcite-label layout="inline"><calcite-radio-button
                value="wetlands"></calcite-radio-button>Wetlands</calcite-label>
          </calcite-radio-button-group>
        </calcite-label>

      </div>
      <div id="projectionDiv" class="esri-widget">
        <p><b>Change view's projection:</b></p>
        <select id="projectWKID" class="esri-input esri-select">
          <option value="102003" selected>Albers Equal Area</option>
          <option value="102100">Web Mercator</option>
          <option value="4326">WGS 84</option>
        </select>
      </div>
    </div>
  </body>
</html>

When the user chooses a land cover type, we update the layer's renderer to display the selected land cover type as shown below. The land cover types are displayed in a calcite radio button group on the right side of the application.

Use dark colors for code blocks
                                                                                                                                                                                                                                           
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
      />
    <title>Hosted Land Cover ImageryTileLayer | Sample | ArcGIS API for JavaScript 4.23</title>
    <script type="module" src="https://js.arcgis.com/calcite-components/1.0.0-beta.79/calcite.esm.js"></script>
    <script nomodule="" src="https://js.arcgis.com/calcite-components/1.0.0-beta.79/calcite.js"></script>
    <link rel="stylesheet" type="text/css"
      href="https://js.arcgis.com/calcite-components/1.0.0-beta.79/calcite.css" />
    <link rel="stylesheet" href="https://js.arcgis.com/4.23/esri/themes/light/main.css" />
    <script src="https://js.arcgis.com/4.23/"></script>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      #infoDiv {
        position: absolute;
        top: 10px;
        right: 10px;
        padding: 10px;
        width: 200px;
        height: 320px;
    </style>
    <script>
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/layers/ImageryTileLayer",
        "esri/layers/FeatureLayer",
        "esri/layers/GroupLayer",
        "esri/renderers/UniqueValueRenderer",
        "esri/renderers/support/UniqueValueInfo",
        "esri/geometry/SpatialReference"
      ], (
        Map,
      ) =>
        (async () => {
          // Reproject the data to the projection selected by the user
          const wkidSelect = document.getElementById("projectWKID");
          wkidSelect.addEventListener("change", () => {
              wkid: wkidSelect.value
          const viewSpatialReference = new SpatialReference({
            wkid: wkidSelect.value
          // this states layer will be used as the basemap
          const statesLayer = new FeatureLayer({
            url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2",
            renderer: {
              type: "simple",
              symbol: {
                type: "simple-fill",
                color: "#505050",
                outline: {
                  color: "#DCDCDC",
                  width: "0.5px"
            spatialReference: viewSpatialReference,
            effect: "drop-shadow(-10px, 10px, 6px gray)"
          // land cover types to set when user changes the land cover type
          const landTypes = {
            forests: {
              categories: [
                "Deciduous Forest",
                "Evergreen Forest",
                "Mixed Forest"
              color: ["#006622", "#006622", "#006622", "#006622"]
            developed: {
              categories: [
                "Developed, Open Space",
                "Developed, Low Intensity",
                "Developed, Medium Intensity",
                "Developed, High Intensity"
              color: ["#E5D0DD", "#E08B88", "#FF0000", "#A70000"]
            crops: {
              categories: ["Cultivated Crops"],
              color: ["#A56400"]
            hay: {
              categories: ["Hay/Pasture"],
              color: ["#D3F40E"]
            wetlands: {
              categories: ["Woody Wetlands", "Emergent Herbaceuous Wetlands"],
              color: ["#0073e6", "#0073e6"]
            // initialize the imagery layer with lerc format
          const layer = new ImageryTileLayer({
            url: "https://tiledimageservices.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/NLCD_2016_Land_Cover_L48_20190424/ImageServer",
            format: "lerc",
            renderer: changeLandCoverType(landTypes.forests),
            blendMode: "color-dodge",
            effect: "bloom(0.5, 0.5px, 20%) drop-shadow(1px, 1px, 1px, grey)"
          const groupLayer = new GroupLayer({
            layers: [layer],
            title: "Forested areas 2016"
          const map = new Map({
            basemap: {
              baseLayers: [statesLayer]
            layers: [groupLayer]
          const view = new MapView({
            container: "viewDiv",
            map: map,
            spatialReference: viewSpatialReference,
            center: {
              type: "point",
              x: 0,
              y: 0,
              spatialReference: viewSpatialReference
            scale: 19975114,
            background: {
              color: "#F5F5F5"
          // drop down for changing the land cover types
          const landCoverTypeSelect = document.getElementById("landCoverTypeSelect");
          landCoverTypeSelect.addEventListener("calciteRadioButtonGroupChange",(event) => {
              if (!layer.loaded) {
                return;
              let renderer = layer.renderer.clone();
              const value = event.detail;
          // this function creates a new instance of group and imagery layer whenever
          // the app is loaded or the view projection changes
          document.getElementById("forests").checked = true;
          // this function is called whenever user changes the land cover type
          // from the drop down. It creates a unique value renderer for the
          // land cover type the user selected.
          function changeLandCoverType(landType) {
            const uvr = new UniqueValueRenderer({
              field: "NLCD_Land",
              uniqueValueInfos: []
            });
            landType.categories.forEach((value, i) => {
              const uniqueValue = new UniqueValueInfo({
                value,
                symbol: {
                  type: "simple-fill",
                  color: landType.color[i]
                }
              });
              uvr.uniqueValueInfos.push(uniqueValue);
            });
            return uvr;
          }
    </script>
  </head>
  <body>
    <div id="viewDiv"></div>
    <div id="infoDiv" class="esri-widget">
      <h4 id="titleText" class="esri-widget__heading esri-editor__title">Land
        cover types - 2016</h4><br>
      <div class="esri-widget">
        <calcite-label><b>Select land type:</b>
          <calcite-radio-button-group name="Select land type" layout="vertical"
            id="landCoverTypeSelect" scale="s">
            <calcite-label layout="inline"><calcite-radio-button id="forests"
                value="forests"
                checked></calcite-radio-button>Forested Areas</calcite-label>
            <calcite-label layout="inline"><calcite-radio-button
                value="developed"></calcite-radio-button>Developed Areas</calcite-label>
            <calcite-label layout="inline"><calcite-radio-button value="crops"></calcite-radio-button>Cultivated
              Areas</calcite-label>
            <calcite-label layout="inline"><calcite-radio-button value="hay"></calcite-radio-button>Hay/Pasture
              Areas</calcite-label>
            <calcite-label layout="inline"><calcite-radio-button
                value="wetlands"></calcite-radio-button>Wetlands</calcite-label>
          </calcite-radio-button-group>
        </calcite-label>

      </div>
      <div id="projectionDiv" class="esri-widget">
        <p><b>Change view's projection:</b></p>
        <select id="projectWKID" class="esri-input esri-select">
          <option value="102003" selected>Albers Equal Area</option>
          <option value="102100">Web Mercator</option>
          <option value="4326">WGS 84</option>
        </select>
      </div>
    </div>
  </body>
</html>

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