@saschabrunnerch/arcgis-maps-sdk-js-ai-context 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +163 -203
- package/bin/cli.js +157 -173
- package/contexts/4.34/{claude → skills}/arcgis-3d-advanced/SKILL.md +586 -586
- package/contexts/4.34/{claude → skills}/arcgis-advanced-layers/SKILL.md +431 -431
- package/contexts/4.34/{claude → skills}/arcgis-analysis-services/SKILL.md +607 -607
- package/contexts/4.34/{claude → skills}/arcgis-authentication/SKILL.md +301 -301
- package/contexts/4.34/{claude → skills}/arcgis-cim-symbols/SKILL.md +486 -486
- package/contexts/4.34/{claude → skills}/arcgis-coordinates-projection/SKILL.md +406 -406
- package/contexts/4.34/{claude → skills}/arcgis-core-maps/SKILL.md +739 -739
- package/contexts/4.34/{claude → skills}/arcgis-core-utilities/SKILL.md +732 -732
- package/contexts/4.34/{claude → skills}/arcgis-custom-rendering/SKILL.md +445 -445
- package/contexts/4.34/{claude → skills}/arcgis-editing-advanced/SKILL.md +702 -702
- package/contexts/4.34/{claude → skills}/arcgis-feature-effects/SKILL.md +393 -393
- package/contexts/4.34/{claude → skills}/arcgis-geometry-operations/SKILL.md +489 -489
- package/contexts/4.34/{claude → skills}/arcgis-imagery/SKILL.md +307 -307
- package/contexts/4.34/{claude → skills}/arcgis-interaction/SKILL.md +572 -572
- package/contexts/4.34/{claude → skills}/arcgis-knowledge-graphs/SKILL.md +582 -582
- package/contexts/4.34/{claude → skills}/arcgis-layers/SKILL.md +601 -601
- package/contexts/4.34/{claude → skills}/arcgis-map-tools/SKILL.md +668 -668
- package/contexts/4.34/{claude → skills}/arcgis-media-layers/SKILL.md +290 -290
- package/contexts/4.34/{claude → skills}/arcgis-portal-content/SKILL.md +679 -679
- package/contexts/4.34/{claude → skills}/arcgis-scene-effects/SKILL.md +512 -512
- package/contexts/4.34/{claude → skills}/arcgis-smart-mapping/SKILL.md +686 -686
- package/contexts/4.34/{claude → skills}/arcgis-starter-app-extended/SKILL.md +649 -649
- package/contexts/4.34/{claude → skills}/arcgis-tables-forms/SKILL.md +877 -877
- package/contexts/4.34/{claude → skills}/arcgis-time-animation/SKILL.md +722 -722
- package/contexts/4.34/{claude → skills}/arcgis-utility-networks/SKILL.md +301 -301
- package/contexts/4.34/{claude → skills}/arcgis-visualization/SKILL.md +580 -580
- package/contexts/4.34/{claude → skills}/arcgis-widgets-ui/SKILL.md +574 -574
- package/lib/installer.js +19 -104
- package/package.json +45 -45
- package/contexts/4.34/copilot/arcgis-3d.instructions.md +0 -267
- package/contexts/4.34/copilot/arcgis-analysis.instructions.md +0 -294
- package/contexts/4.34/copilot/arcgis-arcade.instructions.md +0 -234
- package/contexts/4.34/copilot/arcgis-authentication.instructions.md +0 -187
- package/contexts/4.34/copilot/arcgis-cim-symbols.instructions.md +0 -177
- package/contexts/4.34/copilot/arcgis-core-maps.instructions.md +0 -246
- package/contexts/4.34/copilot/arcgis-core-utilities.instructions.md +0 -247
- package/contexts/4.34/copilot/arcgis-editing.instructions.md +0 -262
- package/contexts/4.34/copilot/arcgis-geometry.instructions.md +0 -225
- package/contexts/4.34/copilot/arcgis-layers.instructions.md +0 -278
- package/contexts/4.34/copilot/arcgis-popup-templates.instructions.md +0 -266
- package/contexts/4.34/copilot/arcgis-portal-advanced.instructions.md +0 -275
- package/contexts/4.34/copilot/arcgis-smart-mapping.instructions.md +0 -184
- package/contexts/4.34/copilot/arcgis-starter-app-extended.instructions.md +0 -643
- package/contexts/4.34/copilot/arcgis-starter-app.instructions.md +0 -268
- package/contexts/4.34/copilot/arcgis-time-animation.instructions.md +0 -112
- package/contexts/4.34/copilot/arcgis-visualization.instructions.md +0 -321
- package/contexts/4.34/copilot/arcgis-widgets-ui.instructions.md +0 -277
- /package/contexts/4.34/{claude → skills}/arcgis-arcade/SKILL.md +0 -0
- /package/contexts/4.34/{claude → skills}/arcgis-popup-templates/SKILL.md +0 -0
- /package/contexts/4.34/{claude → skills}/arcgis-starter-app/SKILL.md +0 -0
|
@@ -1,601 +1,601 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: arcgis-layers
|
|
3
|
-
description: Add and manage data layers in ArcGIS maps. Use for FeatureLayer, TileLayer, SceneLayer, GeoJSONLayer, and all other layer types. Covers layer configuration, queries, and management.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# ArcGIS Layers
|
|
7
|
-
|
|
8
|
-
Use this skill when adding, configuring, or querying data layers in ArcGIS maps.
|
|
9
|
-
|
|
10
|
-
## Layer Types Overview
|
|
11
|
-
|
|
12
|
-
| Layer Type | Use Case | Geometry |
|
|
13
|
-
|------------|----------|----------|
|
|
14
|
-
| FeatureLayer | Most common - feature services, editable data | Points, lines, polygons |
|
|
15
|
-
| GraphicsLayer | Client-side temporary graphics | Any |
|
|
16
|
-
| GeoJSONLayer | GeoJSON files/URLs | Points, lines, polygons |
|
|
17
|
-
| CSVLayer | CSV files with coordinates | Points |
|
|
18
|
-
| TileLayer | Cached map tiles | Raster |
|
|
19
|
-
| VectorTileLayer | Vector tiles (Mapbox style) | Vector |
|
|
20
|
-
| ImageryTileLayer | Raster imagery | Raster |
|
|
21
|
-
| SceneLayer | 3D buildings, meshes | 3D objects |
|
|
22
|
-
| IntegratedMeshLayer | Photogrammetry meshes | 3D mesh |
|
|
23
|
-
| PointCloudLayer | LiDAR point clouds | Points |
|
|
24
|
-
|
|
25
|
-
## FeatureLayer
|
|
26
|
-
|
|
27
|
-
### From URL
|
|
28
|
-
```javascript
|
|
29
|
-
import FeatureLayer from "@arcgis/core/layers/FeatureLayer.js";
|
|
30
|
-
|
|
31
|
-
const featureLayer = new FeatureLayer({
|
|
32
|
-
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0",
|
|
33
|
-
outFields: ["*"],
|
|
34
|
-
popupTemplate: {
|
|
35
|
-
title: "{Tree_ID}",
|
|
36
|
-
content: "Height: {Crown_Height} ft"
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
map.add(featureLayer);
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### From Portal Item
|
|
44
|
-
```javascript
|
|
45
|
-
const featureLayer = new FeatureLayer({
|
|
46
|
-
portalItem: {
|
|
47
|
-
id: "51c851fef66143959986b473b345b7ca"
|
|
48
|
-
},
|
|
49
|
-
outFields: ["*"]
|
|
50
|
-
});
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Client-Side (In-Memory)
|
|
54
|
-
```javascript
|
|
55
|
-
const featureLayer = new FeatureLayer({
|
|
56
|
-
source: graphics, // Array of Graphic objects
|
|
57
|
-
fields: [
|
|
58
|
-
{ name: "ObjectID", type: "oid" },
|
|
59
|
-
{ name: "name", type: "string" },
|
|
60
|
-
{ name: "value", type: "double" }
|
|
61
|
-
],
|
|
62
|
-
objectIdField: "ObjectID",
|
|
63
|
-
geometryType: "point",
|
|
64
|
-
spatialReference: { wkid: 4326 },
|
|
65
|
-
renderer: {
|
|
66
|
-
type: "simple",
|
|
67
|
-
symbol: { type: "simple-marker", color: "blue" }
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### Configuration Options
|
|
73
|
-
```javascript
|
|
74
|
-
const featureLayer = new FeatureLayer({
|
|
75
|
-
url: "...",
|
|
76
|
-
outFields: ["*"], // Fields to include (* = all)
|
|
77
|
-
definitionExpression: "population > 10000", // SQL filter
|
|
78
|
-
minScale: 500000, // Hide when zoomed out beyond this
|
|
79
|
-
maxScale: 0, // Hide when zoomed in beyond this
|
|
80
|
-
visible: true, // Initial visibility
|
|
81
|
-
opacity: 0.8, // Transparency (0-1)
|
|
82
|
-
title: "Cities", // Display name
|
|
83
|
-
orderBy: [{ field: "population" }], // Feature draw order
|
|
84
|
-
labelingInfo: [...], // Labels
|
|
85
|
-
renderer: {...}, // Symbology
|
|
86
|
-
popupTemplate: {...}, // Popup configuration
|
|
87
|
-
elevationInfo: { // 3D elevation mode
|
|
88
|
-
mode: "relative-to-ground"
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## GraphicsLayer
|
|
94
|
-
|
|
95
|
-
```javascript
|
|
96
|
-
import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer.js";
|
|
97
|
-
import Graphic from "@arcgis/core/Graphic.js";
|
|
98
|
-
|
|
99
|
-
const graphicsLayer = new GraphicsLayer();
|
|
100
|
-
map.add(graphicsLayer);
|
|
101
|
-
|
|
102
|
-
// Add a point
|
|
103
|
-
const pointGraphic = new Graphic({
|
|
104
|
-
geometry: {
|
|
105
|
-
type: "point",
|
|
106
|
-
longitude: -118.24,
|
|
107
|
-
latitude: 34.05
|
|
108
|
-
},
|
|
109
|
-
symbol: {
|
|
110
|
-
type: "simple-marker",
|
|
111
|
-
color: "red",
|
|
112
|
-
size: 12
|
|
113
|
-
},
|
|
114
|
-
attributes: { name: "Los Angeles" },
|
|
115
|
-
popupTemplate: { title: "{name}" }
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
graphicsLayer.add(pointGraphic);
|
|
119
|
-
|
|
120
|
-
// Add multiple graphics
|
|
121
|
-
graphicsLayer.addMany([graphic1, graphic2, graphic3]);
|
|
122
|
-
|
|
123
|
-
// Remove graphics
|
|
124
|
-
graphicsLayer.remove(pointGraphic);
|
|
125
|
-
graphicsLayer.removeAll();
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## GeoJSONLayer
|
|
129
|
-
|
|
130
|
-
```javascript
|
|
131
|
-
import GeoJSONLayer from "@arcgis/core/layers/GeoJSONLayer.js";
|
|
132
|
-
|
|
133
|
-
const geojsonLayer = new GeoJSONLayer({
|
|
134
|
-
url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson",
|
|
135
|
-
copyright: "USGS Earthquakes",
|
|
136
|
-
popupTemplate: {
|
|
137
|
-
title: "Earthquake Info",
|
|
138
|
-
content: "Magnitude {mag} hit {place} on {time}",
|
|
139
|
-
fieldInfos: [{
|
|
140
|
-
fieldName: "time",
|
|
141
|
-
format: { dateFormat: "short-date-short-time" }
|
|
142
|
-
}]
|
|
143
|
-
},
|
|
144
|
-
renderer: {
|
|
145
|
-
type: "simple",
|
|
146
|
-
symbol: { type: "simple-marker", color: "orange" },
|
|
147
|
-
visualVariables: [{
|
|
148
|
-
type: "size",
|
|
149
|
-
field: "mag",
|
|
150
|
-
stops: [
|
|
151
|
-
{ value: 2.5, size: "4px" },
|
|
152
|
-
{ value: 8, size: "40px" }
|
|
153
|
-
]
|
|
154
|
-
}]
|
|
155
|
-
},
|
|
156
|
-
orderBy: { field: "mag" } // Draw smaller on top
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
map.add(geojsonLayer);
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## CSVLayer
|
|
163
|
-
|
|
164
|
-
```javascript
|
|
165
|
-
import CSVLayer from "@arcgis/core/layers/CSVLayer.js";
|
|
166
|
-
|
|
167
|
-
const csvLayer = new CSVLayer({
|
|
168
|
-
url: "https://example.com/data.csv",
|
|
169
|
-
latitudeField: "latitude", // Column name for lat
|
|
170
|
-
longitudeField: "longitude", // Column name for lon
|
|
171
|
-
delimiter: ",",
|
|
172
|
-
popupTemplate: {
|
|
173
|
-
title: "{name}",
|
|
174
|
-
content: "{description}"
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
## TileLayer (Cached Tiles)
|
|
180
|
-
|
|
181
|
-
```javascript
|
|
182
|
-
import TileLayer from "@arcgis/core/layers/TileLayer.js";
|
|
183
|
-
|
|
184
|
-
const tileLayer = new TileLayer({
|
|
185
|
-
url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
map.add(tileLayer);
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## VectorTileLayer
|
|
192
|
-
|
|
193
|
-
```javascript
|
|
194
|
-
import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer.js";
|
|
195
|
-
|
|
196
|
-
// From portal item
|
|
197
|
-
const vtl = new VectorTileLayer({
|
|
198
|
-
portalItem: { id: "VECTOR_TILE_ITEM_ID" }
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
// From URL
|
|
202
|
-
const vtl = new VectorTileLayer({
|
|
203
|
-
url: "https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer"
|
|
204
|
-
});
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## ImageryTileLayer
|
|
208
|
-
|
|
209
|
-
```javascript
|
|
210
|
-
import ImageryTileLayer from "@arcgis/core/layers/ImageryTileLayer.js";
|
|
211
|
-
|
|
212
|
-
const imageryLayer = new ImageryTileLayer({
|
|
213
|
-
url: "https://tiledimageservices.arcgis.com/...",
|
|
214
|
-
// Or from COG (Cloud Optimized GeoTIFF)
|
|
215
|
-
url: "https://example.com/image.tif"
|
|
216
|
-
});
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
## 3D Layers
|
|
220
|
-
|
|
221
|
-
### SceneLayer (3D Buildings)
|
|
222
|
-
```javascript
|
|
223
|
-
import SceneLayer from "@arcgis/core/layers/SceneLayer.js";
|
|
224
|
-
|
|
225
|
-
const sceneLayer = new SceneLayer({
|
|
226
|
-
portalItem: { id: "2e0761b9a4274b8db52c4bf34356911e" },
|
|
227
|
-
popupEnabled: false
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
// Add to SceneView map
|
|
231
|
-
map.add(sceneLayer);
|
|
232
|
-
|
|
233
|
-
// Custom 3D symbology
|
|
234
|
-
sceneLayer.renderer = {
|
|
235
|
-
type: "simple",
|
|
236
|
-
symbol: {
|
|
237
|
-
type: "mesh-3d",
|
|
238
|
-
symbolLayers: [{
|
|
239
|
-
type: "fill",
|
|
240
|
-
material: { color: [244, 247, 134] }
|
|
241
|
-
}]
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### IntegratedMeshLayer
|
|
247
|
-
```javascript
|
|
248
|
-
import IntegratedMeshLayer from "@arcgis/core/layers/IntegratedMeshLayer.js";
|
|
249
|
-
|
|
250
|
-
const meshLayer = new IntegratedMeshLayer({
|
|
251
|
-
url: "https://tiles.arcgis.com/tiles/.../IntegratedMeshServer"
|
|
252
|
-
});
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### PointCloudLayer
|
|
256
|
-
```javascript
|
|
257
|
-
import PointCloudLayer from "@arcgis/core/layers/PointCloudLayer.js";
|
|
258
|
-
|
|
259
|
-
const pcLayer = new PointCloudLayer({
|
|
260
|
-
url: "https://tiles.arcgis.com/tiles/.../SceneServer"
|
|
261
|
-
});
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
## Specialized Layers
|
|
265
|
-
|
|
266
|
-
### WMSLayer
|
|
267
|
-
```javascript
|
|
268
|
-
import WMSLayer from "@arcgis/core/layers/WMSLayer.js";
|
|
269
|
-
|
|
270
|
-
const wmsLayer = new WMSLayer({
|
|
271
|
-
url: "https://example.com/wms",
|
|
272
|
-
sublayers: [{ name: "layer_name" }]
|
|
273
|
-
});
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### WFSLayer
|
|
277
|
-
```javascript
|
|
278
|
-
import WFSLayer from "@arcgis/core/layers/WFSLayer.js";
|
|
279
|
-
|
|
280
|
-
const wfsLayer = new WFSLayer({
|
|
281
|
-
url: "https://example.com/wfs",
|
|
282
|
-
name: "feature_type_name"
|
|
283
|
-
});
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
### KMLLayer
|
|
287
|
-
```javascript
|
|
288
|
-
import KMLLayer from "@arcgis/core/layers/KMLLayer.js";
|
|
289
|
-
|
|
290
|
-
const kmlLayer = new KMLLayer({
|
|
291
|
-
url: "https://example.com/file.kml"
|
|
292
|
-
});
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
### StreamLayer (Real-time)
|
|
296
|
-
```javascript
|
|
297
|
-
import StreamLayer from "@arcgis/core/layers/StreamLayer.js";
|
|
298
|
-
|
|
299
|
-
const streamLayer = new StreamLayer({
|
|
300
|
-
url: "wss://example.com/stream/service",
|
|
301
|
-
purgeOptions: {
|
|
302
|
-
displayCount: 10000
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
```
|
|
306
|
-
|
|
307
|
-
### ParquetLayer (File-based)
|
|
308
|
-
```javascript
|
|
309
|
-
import ParquetLayer from "@arcgis/core/layers/ParquetLayer.js";
|
|
310
|
-
|
|
311
|
-
const parquetLayer = new ParquetLayer({
|
|
312
|
-
urls: [
|
|
313
|
-
"https://example.com/data.parquet"
|
|
314
|
-
],
|
|
315
|
-
title: "Parquet Data",
|
|
316
|
-
renderer: {
|
|
317
|
-
type: "simple",
|
|
318
|
-
symbol: { type: "simple-marker", color: "blue" }
|
|
319
|
-
},
|
|
320
|
-
popupTemplate: {
|
|
321
|
-
title: "{name}",
|
|
322
|
-
content: [{
|
|
323
|
-
type: "fields",
|
|
324
|
-
fieldInfos: [
|
|
325
|
-
{ fieldName: "field1", label: "Field 1" }
|
|
326
|
-
]
|
|
327
|
-
}]
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
// Query feature count
|
|
332
|
-
const count = await parquetLayer.queryFeatureCount();
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### GeoRSSLayer
|
|
336
|
-
```javascript
|
|
337
|
-
import GeoRSSLayer from "@arcgis/core/layers/GeoRSSLayer.js";
|
|
338
|
-
|
|
339
|
-
const georssLayer = new GeoRSSLayer({
|
|
340
|
-
url: "https://example.com/feed.xml"
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
map.add(georssLayer);
|
|
344
|
-
|
|
345
|
-
// Zoom to layer extent
|
|
346
|
-
await view.whenLayerView(georssLayer);
|
|
347
|
-
view.goTo(georssLayer.fullExtent);
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
### WebTileLayer
|
|
351
|
-
```javascript
|
|
352
|
-
import WebTileLayer from "@arcgis/core/layers/WebTileLayer.js";
|
|
353
|
-
|
|
354
|
-
// OpenStreetMap tiles
|
|
355
|
-
const osmLayer = new WebTileLayer({
|
|
356
|
-
urlTemplate: "https://{subDomain}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
357
|
-
subDomains: ["a", "b", "c"],
|
|
358
|
-
copyright: "OpenStreetMap contributors"
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
// Custom tile service
|
|
362
|
-
const customTileLayer = new WebTileLayer({
|
|
363
|
-
urlTemplate: "https://tiles.example.com/{level}/{col}/{row}.png"
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
map.add(osmLayer);
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### MapNotesLayer
|
|
370
|
-
```javascript
|
|
371
|
-
import MapNotesLayer from "@arcgis/core/layers/MapNotesLayer.js";
|
|
372
|
-
|
|
373
|
-
// Layer for sketches and annotations
|
|
374
|
-
const notesLayer = new MapNotesLayer();
|
|
375
|
-
map.add(notesLayer);
|
|
376
|
-
|
|
377
|
-
// Access sublayers
|
|
378
|
-
const pointLayer = notesLayer.pointLayer;
|
|
379
|
-
const polylineLayer = notesLayer.polylineLayer;
|
|
380
|
-
const polygonLayer = notesLayer.polygonLayer;
|
|
381
|
-
const textLayer = notesLayer.textLayer;
|
|
382
|
-
|
|
383
|
-
// Add a text annotation
|
|
384
|
-
const textGraphic = new Graphic({
|
|
385
|
-
geometry: point,
|
|
386
|
-
symbol: {
|
|
387
|
-
type: "text",
|
|
388
|
-
text: "Note here",
|
|
389
|
-
color: [255, 255, 255],
|
|
390
|
-
haloColor: [0, 0, 0],
|
|
391
|
-
haloSize: 2,
|
|
392
|
-
font: { family: "Arial", size: 14 }
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
textLayer.add(textGraphic);
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
## Layer Management
|
|
399
|
-
|
|
400
|
-
### Adding Layers
|
|
401
|
-
```javascript
|
|
402
|
-
// Add single layer
|
|
403
|
-
map.add(layer);
|
|
404
|
-
|
|
405
|
-
// Add at specific index (0 = bottom)
|
|
406
|
-
map.add(layer, 0);
|
|
407
|
-
|
|
408
|
-
// Add multiple layers
|
|
409
|
-
map.addMany([layer1, layer2, layer3]);
|
|
410
|
-
|
|
411
|
-
// Add to Map Component
|
|
412
|
-
const viewElement = document.querySelector("arcgis-map");
|
|
413
|
-
viewElement.map.add(layer);
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
### Removing Layers
|
|
417
|
-
```javascript
|
|
418
|
-
map.remove(layer);
|
|
419
|
-
map.removeMany([layer1, layer2]);
|
|
420
|
-
map.removeAll();
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
### Layer Ordering
|
|
424
|
-
```javascript
|
|
425
|
-
// Reorder layer
|
|
426
|
-
map.reorder(layer, newIndex);
|
|
427
|
-
|
|
428
|
-
// Get layer position
|
|
429
|
-
const index = map.layers.indexOf(layer);
|
|
430
|
-
|
|
431
|
-
// Find layer by id
|
|
432
|
-
const layer = map.findLayerById("myLayerId");
|
|
433
|
-
|
|
434
|
-
// Find layer by title
|
|
435
|
-
const layer = map.layers.find(l => l.title === "Cities");
|
|
436
|
-
```
|
|
437
|
-
|
|
438
|
-
### Visibility and Opacity
|
|
439
|
-
```javascript
|
|
440
|
-
layer.visible = false;
|
|
441
|
-
layer.opacity = 0.5; // 0-1
|
|
442
|
-
|
|
443
|
-
// Watch visibility changes
|
|
444
|
-
layer.watch("visible", (newValue) => {
|
|
445
|
-
console.log("Visibility changed:", newValue);
|
|
446
|
-
});
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
## Querying Features
|
|
450
|
-
|
|
451
|
-
### Basic Query
|
|
452
|
-
```javascript
|
|
453
|
-
// Create query from layer settings
|
|
454
|
-
const query = featureLayer.createQuery();
|
|
455
|
-
query.where = "population > 100000";
|
|
456
|
-
query.outFields = ["name", "population"];
|
|
457
|
-
query.returnGeometry = true;
|
|
458
|
-
|
|
459
|
-
const result = await featureLayer.queryFeatures(query);
|
|
460
|
-
console.log(result.features); // Array of Graphic objects
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
### Query with Pagination
|
|
464
|
-
```javascript
|
|
465
|
-
const query = featureLayer.createQuery();
|
|
466
|
-
query.start = 0; // Start index
|
|
467
|
-
query.num = 20; // Number of features
|
|
468
|
-
query.orderByFields = ["population DESC"];
|
|
469
|
-
|
|
470
|
-
const result = await featureLayer.queryFeatures(query);
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
### Spatial Query
|
|
474
|
-
```javascript
|
|
475
|
-
const query = featureLayer.createQuery();
|
|
476
|
-
query.geometry = view.extent; // Or any geometry
|
|
477
|
-
query.spatialRelationship = "intersects"; // contains, crosses, etc.
|
|
478
|
-
query.returnGeometry = true;
|
|
479
|
-
|
|
480
|
-
const result = await featureLayer.queryFeatures(query);
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
### Count Query
|
|
484
|
-
```javascript
|
|
485
|
-
const count = await featureLayer.queryFeatureCount();
|
|
486
|
-
console.log("Total features:", count);
|
|
487
|
-
```
|
|
488
|
-
|
|
489
|
-
### Extent Query
|
|
490
|
-
```javascript
|
|
491
|
-
const extent = await featureLayer.queryExtent();
|
|
492
|
-
await view.goTo(extent);
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
### Statistics Query
|
|
496
|
-
```javascript
|
|
497
|
-
const query = featureLayer.createQuery();
|
|
498
|
-
query.outStatistics = [{
|
|
499
|
-
statisticType: "sum",
|
|
500
|
-
onStatisticField: "population",
|
|
501
|
-
outStatisticFieldName: "totalPop"
|
|
502
|
-
}, {
|
|
503
|
-
statisticType: "avg",
|
|
504
|
-
onStatisticField: "population",
|
|
505
|
-
outStatisticFieldName: "avgPop"
|
|
506
|
-
}];
|
|
507
|
-
|
|
508
|
-
const result = await featureLayer.queryFeatures(query);
|
|
509
|
-
console.log(result.features[0].attributes.totalPop);
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
### Query from LayerView (Client-side)
|
|
513
|
-
```javascript
|
|
514
|
-
const layerView = await view.whenLayerView(featureLayer);
|
|
515
|
-
|
|
516
|
-
// Query only currently visible features
|
|
517
|
-
const query = layerView.createQuery();
|
|
518
|
-
query.geometry = view.extent;
|
|
519
|
-
|
|
520
|
-
const result = await layerView.queryFeatures(query);
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
## Layer Loading
|
|
524
|
-
|
|
525
|
-
```javascript
|
|
526
|
-
// Wait for layer to load
|
|
527
|
-
await featureLayer.load();
|
|
528
|
-
console.log("Fields:", featureLayer.fields);
|
|
529
|
-
console.log("Extent:", featureLayer.fullExtent);
|
|
530
|
-
|
|
531
|
-
// Wait for layer view
|
|
532
|
-
const layerView = await view.whenLayerView(featureLayer);
|
|
533
|
-
|
|
534
|
-
// Check if updating
|
|
535
|
-
layerView.watch("updating", (updating) => {
|
|
536
|
-
if (!updating) {
|
|
537
|
-
console.log("Layer view finished updating");
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
```
|
|
541
|
-
|
|
542
|
-
## Definition Expressions (Filters)
|
|
543
|
-
|
|
544
|
-
```javascript
|
|
545
|
-
// SQL WHERE clause filter
|
|
546
|
-
featureLayer.definitionExpression = "state = 'California'";
|
|
547
|
-
|
|
548
|
-
// Clear filter
|
|
549
|
-
featureLayer.definitionExpression = null;
|
|
550
|
-
|
|
551
|
-
// Dynamic filter
|
|
552
|
-
function filterByYear(year) {
|
|
553
|
-
featureLayer.definitionExpression = `year = ${year}`;
|
|
554
|
-
}
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
## TypeScript Usage
|
|
558
|
-
|
|
559
|
-
Layer configurations with `type` properties support autocasting. For TypeScript safety, use `as const`:
|
|
560
|
-
|
|
561
|
-
```typescript
|
|
562
|
-
// Use 'as const' for type safety
|
|
563
|
-
const featureLayer = new FeatureLayer({
|
|
564
|
-
source: graphics,
|
|
565
|
-
fields: [
|
|
566
|
-
{ name: "ObjectID", type: "oid" },
|
|
567
|
-
{ name: "name", type: "string" }
|
|
568
|
-
],
|
|
569
|
-
geometryType: "point",
|
|
570
|
-
renderer: {
|
|
571
|
-
type: "simple",
|
|
572
|
-
symbol: { type: "simple-marker", color: "blue" }
|
|
573
|
-
} as const
|
|
574
|
-
});
|
|
575
|
-
```
|
|
576
|
-
|
|
577
|
-
For complex layer configurations, use type annotations:
|
|
578
|
-
|
|
579
|
-
```typescript
|
|
580
|
-
const renderer: __esri.SimpleRendererProperties = {
|
|
581
|
-
type: "simple",
|
|
582
|
-
symbol: { type: "simple-marker", color: "blue" }
|
|
583
|
-
};
|
|
584
|
-
|
|
585
|
-
layer.renderer = renderer;
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
> **Tip:** See [arcgis-core-maps skill](../arcgis-core-maps/SKILL.md) for detailed guidance on autocasting vs explicit classes.
|
|
589
|
-
|
|
590
|
-
## Common Pitfalls
|
|
591
|
-
|
|
592
|
-
1. **CORS errors with GeoJSON**: GeoJSON URLs must be CORS-enabled or use a proxy
|
|
593
|
-
|
|
594
|
-
2. **Missing outFields**: Specify `outFields: ["*"]` to access all attributes
|
|
595
|
-
|
|
596
|
-
3. **Not waiting for layer load**: Always `await featureLayer.load()` before accessing properties like `fields`
|
|
597
|
-
|
|
598
|
-
4. **Wrong layer for MapView vs SceneView**: Some layers only work in 3D (SceneLayer, IntegratedMeshLayer)
|
|
599
|
-
|
|
600
|
-
5. **Spatial reference mismatch**: Ensure layer data matches view's spatial reference
|
|
601
|
-
|
|
1
|
+
---
|
|
2
|
+
name: arcgis-layers
|
|
3
|
+
description: Add and manage data layers in ArcGIS maps. Use for FeatureLayer, TileLayer, SceneLayer, GeoJSONLayer, and all other layer types. Covers layer configuration, queries, and management.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ArcGIS Layers
|
|
7
|
+
|
|
8
|
+
Use this skill when adding, configuring, or querying data layers in ArcGIS maps.
|
|
9
|
+
|
|
10
|
+
## Layer Types Overview
|
|
11
|
+
|
|
12
|
+
| Layer Type | Use Case | Geometry |
|
|
13
|
+
|------------|----------|----------|
|
|
14
|
+
| FeatureLayer | Most common - feature services, editable data | Points, lines, polygons |
|
|
15
|
+
| GraphicsLayer | Client-side temporary graphics | Any |
|
|
16
|
+
| GeoJSONLayer | GeoJSON files/URLs | Points, lines, polygons |
|
|
17
|
+
| CSVLayer | CSV files with coordinates | Points |
|
|
18
|
+
| TileLayer | Cached map tiles | Raster |
|
|
19
|
+
| VectorTileLayer | Vector tiles (Mapbox style) | Vector |
|
|
20
|
+
| ImageryTileLayer | Raster imagery | Raster |
|
|
21
|
+
| SceneLayer | 3D buildings, meshes | 3D objects |
|
|
22
|
+
| IntegratedMeshLayer | Photogrammetry meshes | 3D mesh |
|
|
23
|
+
| PointCloudLayer | LiDAR point clouds | Points |
|
|
24
|
+
|
|
25
|
+
## FeatureLayer
|
|
26
|
+
|
|
27
|
+
### From URL
|
|
28
|
+
```javascript
|
|
29
|
+
import FeatureLayer from "@arcgis/core/layers/FeatureLayer.js";
|
|
30
|
+
|
|
31
|
+
const featureLayer = new FeatureLayer({
|
|
32
|
+
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0",
|
|
33
|
+
outFields: ["*"],
|
|
34
|
+
popupTemplate: {
|
|
35
|
+
title: "{Tree_ID}",
|
|
36
|
+
content: "Height: {Crown_Height} ft"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
map.add(featureLayer);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### From Portal Item
|
|
44
|
+
```javascript
|
|
45
|
+
const featureLayer = new FeatureLayer({
|
|
46
|
+
portalItem: {
|
|
47
|
+
id: "51c851fef66143959986b473b345b7ca"
|
|
48
|
+
},
|
|
49
|
+
outFields: ["*"]
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Client-Side (In-Memory)
|
|
54
|
+
```javascript
|
|
55
|
+
const featureLayer = new FeatureLayer({
|
|
56
|
+
source: graphics, // Array of Graphic objects
|
|
57
|
+
fields: [
|
|
58
|
+
{ name: "ObjectID", type: "oid" },
|
|
59
|
+
{ name: "name", type: "string" },
|
|
60
|
+
{ name: "value", type: "double" }
|
|
61
|
+
],
|
|
62
|
+
objectIdField: "ObjectID",
|
|
63
|
+
geometryType: "point",
|
|
64
|
+
spatialReference: { wkid: 4326 },
|
|
65
|
+
renderer: {
|
|
66
|
+
type: "simple",
|
|
67
|
+
symbol: { type: "simple-marker", color: "blue" }
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Configuration Options
|
|
73
|
+
```javascript
|
|
74
|
+
const featureLayer = new FeatureLayer({
|
|
75
|
+
url: "...",
|
|
76
|
+
outFields: ["*"], // Fields to include (* = all)
|
|
77
|
+
definitionExpression: "population > 10000", // SQL filter
|
|
78
|
+
minScale: 500000, // Hide when zoomed out beyond this
|
|
79
|
+
maxScale: 0, // Hide when zoomed in beyond this
|
|
80
|
+
visible: true, // Initial visibility
|
|
81
|
+
opacity: 0.8, // Transparency (0-1)
|
|
82
|
+
title: "Cities", // Display name
|
|
83
|
+
orderBy: [{ field: "population" }], // Feature draw order
|
|
84
|
+
labelingInfo: [...], // Labels
|
|
85
|
+
renderer: {...}, // Symbology
|
|
86
|
+
popupTemplate: {...}, // Popup configuration
|
|
87
|
+
elevationInfo: { // 3D elevation mode
|
|
88
|
+
mode: "relative-to-ground"
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## GraphicsLayer
|
|
94
|
+
|
|
95
|
+
```javascript
|
|
96
|
+
import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer.js";
|
|
97
|
+
import Graphic from "@arcgis/core/Graphic.js";
|
|
98
|
+
|
|
99
|
+
const graphicsLayer = new GraphicsLayer();
|
|
100
|
+
map.add(graphicsLayer);
|
|
101
|
+
|
|
102
|
+
// Add a point
|
|
103
|
+
const pointGraphic = new Graphic({
|
|
104
|
+
geometry: {
|
|
105
|
+
type: "point",
|
|
106
|
+
longitude: -118.24,
|
|
107
|
+
latitude: 34.05
|
|
108
|
+
},
|
|
109
|
+
symbol: {
|
|
110
|
+
type: "simple-marker",
|
|
111
|
+
color: "red",
|
|
112
|
+
size: 12
|
|
113
|
+
},
|
|
114
|
+
attributes: { name: "Los Angeles" },
|
|
115
|
+
popupTemplate: { title: "{name}" }
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
graphicsLayer.add(pointGraphic);
|
|
119
|
+
|
|
120
|
+
// Add multiple graphics
|
|
121
|
+
graphicsLayer.addMany([graphic1, graphic2, graphic3]);
|
|
122
|
+
|
|
123
|
+
// Remove graphics
|
|
124
|
+
graphicsLayer.remove(pointGraphic);
|
|
125
|
+
graphicsLayer.removeAll();
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## GeoJSONLayer
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
import GeoJSONLayer from "@arcgis/core/layers/GeoJSONLayer.js";
|
|
132
|
+
|
|
133
|
+
const geojsonLayer = new GeoJSONLayer({
|
|
134
|
+
url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson",
|
|
135
|
+
copyright: "USGS Earthquakes",
|
|
136
|
+
popupTemplate: {
|
|
137
|
+
title: "Earthquake Info",
|
|
138
|
+
content: "Magnitude {mag} hit {place} on {time}",
|
|
139
|
+
fieldInfos: [{
|
|
140
|
+
fieldName: "time",
|
|
141
|
+
format: { dateFormat: "short-date-short-time" }
|
|
142
|
+
}]
|
|
143
|
+
},
|
|
144
|
+
renderer: {
|
|
145
|
+
type: "simple",
|
|
146
|
+
symbol: { type: "simple-marker", color: "orange" },
|
|
147
|
+
visualVariables: [{
|
|
148
|
+
type: "size",
|
|
149
|
+
field: "mag",
|
|
150
|
+
stops: [
|
|
151
|
+
{ value: 2.5, size: "4px" },
|
|
152
|
+
{ value: 8, size: "40px" }
|
|
153
|
+
]
|
|
154
|
+
}]
|
|
155
|
+
},
|
|
156
|
+
orderBy: { field: "mag" } // Draw smaller on top
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
map.add(geojsonLayer);
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## CSVLayer
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
import CSVLayer from "@arcgis/core/layers/CSVLayer.js";
|
|
166
|
+
|
|
167
|
+
const csvLayer = new CSVLayer({
|
|
168
|
+
url: "https://example.com/data.csv",
|
|
169
|
+
latitudeField: "latitude", // Column name for lat
|
|
170
|
+
longitudeField: "longitude", // Column name for lon
|
|
171
|
+
delimiter: ",",
|
|
172
|
+
popupTemplate: {
|
|
173
|
+
title: "{name}",
|
|
174
|
+
content: "{description}"
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## TileLayer (Cached Tiles)
|
|
180
|
+
|
|
181
|
+
```javascript
|
|
182
|
+
import TileLayer from "@arcgis/core/layers/TileLayer.js";
|
|
183
|
+
|
|
184
|
+
const tileLayer = new TileLayer({
|
|
185
|
+
url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
map.add(tileLayer);
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## VectorTileLayer
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer.js";
|
|
195
|
+
|
|
196
|
+
// From portal item
|
|
197
|
+
const vtl = new VectorTileLayer({
|
|
198
|
+
portalItem: { id: "VECTOR_TILE_ITEM_ID" }
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// From URL
|
|
202
|
+
const vtl = new VectorTileLayer({
|
|
203
|
+
url: "https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer"
|
|
204
|
+
});
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## ImageryTileLayer
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
import ImageryTileLayer from "@arcgis/core/layers/ImageryTileLayer.js";
|
|
211
|
+
|
|
212
|
+
const imageryLayer = new ImageryTileLayer({
|
|
213
|
+
url: "https://tiledimageservices.arcgis.com/...",
|
|
214
|
+
// Or from COG (Cloud Optimized GeoTIFF)
|
|
215
|
+
url: "https://example.com/image.tif"
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## 3D Layers
|
|
220
|
+
|
|
221
|
+
### SceneLayer (3D Buildings)
|
|
222
|
+
```javascript
|
|
223
|
+
import SceneLayer from "@arcgis/core/layers/SceneLayer.js";
|
|
224
|
+
|
|
225
|
+
const sceneLayer = new SceneLayer({
|
|
226
|
+
portalItem: { id: "2e0761b9a4274b8db52c4bf34356911e" },
|
|
227
|
+
popupEnabled: false
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// Add to SceneView map
|
|
231
|
+
map.add(sceneLayer);
|
|
232
|
+
|
|
233
|
+
// Custom 3D symbology
|
|
234
|
+
sceneLayer.renderer = {
|
|
235
|
+
type: "simple",
|
|
236
|
+
symbol: {
|
|
237
|
+
type: "mesh-3d",
|
|
238
|
+
symbolLayers: [{
|
|
239
|
+
type: "fill",
|
|
240
|
+
material: { color: [244, 247, 134] }
|
|
241
|
+
}]
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### IntegratedMeshLayer
|
|
247
|
+
```javascript
|
|
248
|
+
import IntegratedMeshLayer from "@arcgis/core/layers/IntegratedMeshLayer.js";
|
|
249
|
+
|
|
250
|
+
const meshLayer = new IntegratedMeshLayer({
|
|
251
|
+
url: "https://tiles.arcgis.com/tiles/.../IntegratedMeshServer"
|
|
252
|
+
});
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### PointCloudLayer
|
|
256
|
+
```javascript
|
|
257
|
+
import PointCloudLayer from "@arcgis/core/layers/PointCloudLayer.js";
|
|
258
|
+
|
|
259
|
+
const pcLayer = new PointCloudLayer({
|
|
260
|
+
url: "https://tiles.arcgis.com/tiles/.../SceneServer"
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Specialized Layers
|
|
265
|
+
|
|
266
|
+
### WMSLayer
|
|
267
|
+
```javascript
|
|
268
|
+
import WMSLayer from "@arcgis/core/layers/WMSLayer.js";
|
|
269
|
+
|
|
270
|
+
const wmsLayer = new WMSLayer({
|
|
271
|
+
url: "https://example.com/wms",
|
|
272
|
+
sublayers: [{ name: "layer_name" }]
|
|
273
|
+
});
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### WFSLayer
|
|
277
|
+
```javascript
|
|
278
|
+
import WFSLayer from "@arcgis/core/layers/WFSLayer.js";
|
|
279
|
+
|
|
280
|
+
const wfsLayer = new WFSLayer({
|
|
281
|
+
url: "https://example.com/wfs",
|
|
282
|
+
name: "feature_type_name"
|
|
283
|
+
});
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### KMLLayer
|
|
287
|
+
```javascript
|
|
288
|
+
import KMLLayer from "@arcgis/core/layers/KMLLayer.js";
|
|
289
|
+
|
|
290
|
+
const kmlLayer = new KMLLayer({
|
|
291
|
+
url: "https://example.com/file.kml"
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### StreamLayer (Real-time)
|
|
296
|
+
```javascript
|
|
297
|
+
import StreamLayer from "@arcgis/core/layers/StreamLayer.js";
|
|
298
|
+
|
|
299
|
+
const streamLayer = new StreamLayer({
|
|
300
|
+
url: "wss://example.com/stream/service",
|
|
301
|
+
purgeOptions: {
|
|
302
|
+
displayCount: 10000
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### ParquetLayer (File-based)
|
|
308
|
+
```javascript
|
|
309
|
+
import ParquetLayer from "@arcgis/core/layers/ParquetLayer.js";
|
|
310
|
+
|
|
311
|
+
const parquetLayer = new ParquetLayer({
|
|
312
|
+
urls: [
|
|
313
|
+
"https://example.com/data.parquet"
|
|
314
|
+
],
|
|
315
|
+
title: "Parquet Data",
|
|
316
|
+
renderer: {
|
|
317
|
+
type: "simple",
|
|
318
|
+
symbol: { type: "simple-marker", color: "blue" }
|
|
319
|
+
},
|
|
320
|
+
popupTemplate: {
|
|
321
|
+
title: "{name}",
|
|
322
|
+
content: [{
|
|
323
|
+
type: "fields",
|
|
324
|
+
fieldInfos: [
|
|
325
|
+
{ fieldName: "field1", label: "Field 1" }
|
|
326
|
+
]
|
|
327
|
+
}]
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// Query feature count
|
|
332
|
+
const count = await parquetLayer.queryFeatureCount();
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### GeoRSSLayer
|
|
336
|
+
```javascript
|
|
337
|
+
import GeoRSSLayer from "@arcgis/core/layers/GeoRSSLayer.js";
|
|
338
|
+
|
|
339
|
+
const georssLayer = new GeoRSSLayer({
|
|
340
|
+
url: "https://example.com/feed.xml"
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
map.add(georssLayer);
|
|
344
|
+
|
|
345
|
+
// Zoom to layer extent
|
|
346
|
+
await view.whenLayerView(georssLayer);
|
|
347
|
+
view.goTo(georssLayer.fullExtent);
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### WebTileLayer
|
|
351
|
+
```javascript
|
|
352
|
+
import WebTileLayer from "@arcgis/core/layers/WebTileLayer.js";
|
|
353
|
+
|
|
354
|
+
// OpenStreetMap tiles
|
|
355
|
+
const osmLayer = new WebTileLayer({
|
|
356
|
+
urlTemplate: "https://{subDomain}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
357
|
+
subDomains: ["a", "b", "c"],
|
|
358
|
+
copyright: "OpenStreetMap contributors"
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
// Custom tile service
|
|
362
|
+
const customTileLayer = new WebTileLayer({
|
|
363
|
+
urlTemplate: "https://tiles.example.com/{level}/{col}/{row}.png"
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
map.add(osmLayer);
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### MapNotesLayer
|
|
370
|
+
```javascript
|
|
371
|
+
import MapNotesLayer from "@arcgis/core/layers/MapNotesLayer.js";
|
|
372
|
+
|
|
373
|
+
// Layer for sketches and annotations
|
|
374
|
+
const notesLayer = new MapNotesLayer();
|
|
375
|
+
map.add(notesLayer);
|
|
376
|
+
|
|
377
|
+
// Access sublayers
|
|
378
|
+
const pointLayer = notesLayer.pointLayer;
|
|
379
|
+
const polylineLayer = notesLayer.polylineLayer;
|
|
380
|
+
const polygonLayer = notesLayer.polygonLayer;
|
|
381
|
+
const textLayer = notesLayer.textLayer;
|
|
382
|
+
|
|
383
|
+
// Add a text annotation
|
|
384
|
+
const textGraphic = new Graphic({
|
|
385
|
+
geometry: point,
|
|
386
|
+
symbol: {
|
|
387
|
+
type: "text",
|
|
388
|
+
text: "Note here",
|
|
389
|
+
color: [255, 255, 255],
|
|
390
|
+
haloColor: [0, 0, 0],
|
|
391
|
+
haloSize: 2,
|
|
392
|
+
font: { family: "Arial", size: 14 }
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
textLayer.add(textGraphic);
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
## Layer Management
|
|
399
|
+
|
|
400
|
+
### Adding Layers
|
|
401
|
+
```javascript
|
|
402
|
+
// Add single layer
|
|
403
|
+
map.add(layer);
|
|
404
|
+
|
|
405
|
+
// Add at specific index (0 = bottom)
|
|
406
|
+
map.add(layer, 0);
|
|
407
|
+
|
|
408
|
+
// Add multiple layers
|
|
409
|
+
map.addMany([layer1, layer2, layer3]);
|
|
410
|
+
|
|
411
|
+
// Add to Map Component
|
|
412
|
+
const viewElement = document.querySelector("arcgis-map");
|
|
413
|
+
viewElement.map.add(layer);
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Removing Layers
|
|
417
|
+
```javascript
|
|
418
|
+
map.remove(layer);
|
|
419
|
+
map.removeMany([layer1, layer2]);
|
|
420
|
+
map.removeAll();
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Layer Ordering
|
|
424
|
+
```javascript
|
|
425
|
+
// Reorder layer
|
|
426
|
+
map.reorder(layer, newIndex);
|
|
427
|
+
|
|
428
|
+
// Get layer position
|
|
429
|
+
const index = map.layers.indexOf(layer);
|
|
430
|
+
|
|
431
|
+
// Find layer by id
|
|
432
|
+
const layer = map.findLayerById("myLayerId");
|
|
433
|
+
|
|
434
|
+
// Find layer by title
|
|
435
|
+
const layer = map.layers.find(l => l.title === "Cities");
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### Visibility and Opacity
|
|
439
|
+
```javascript
|
|
440
|
+
layer.visible = false;
|
|
441
|
+
layer.opacity = 0.5; // 0-1
|
|
442
|
+
|
|
443
|
+
// Watch visibility changes
|
|
444
|
+
layer.watch("visible", (newValue) => {
|
|
445
|
+
console.log("Visibility changed:", newValue);
|
|
446
|
+
});
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
## Querying Features
|
|
450
|
+
|
|
451
|
+
### Basic Query
|
|
452
|
+
```javascript
|
|
453
|
+
// Create query from layer settings
|
|
454
|
+
const query = featureLayer.createQuery();
|
|
455
|
+
query.where = "population > 100000";
|
|
456
|
+
query.outFields = ["name", "population"];
|
|
457
|
+
query.returnGeometry = true;
|
|
458
|
+
|
|
459
|
+
const result = await featureLayer.queryFeatures(query);
|
|
460
|
+
console.log(result.features); // Array of Graphic objects
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### Query with Pagination
|
|
464
|
+
```javascript
|
|
465
|
+
const query = featureLayer.createQuery();
|
|
466
|
+
query.start = 0; // Start index
|
|
467
|
+
query.num = 20; // Number of features
|
|
468
|
+
query.orderByFields = ["population DESC"];
|
|
469
|
+
|
|
470
|
+
const result = await featureLayer.queryFeatures(query);
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### Spatial Query
|
|
474
|
+
```javascript
|
|
475
|
+
const query = featureLayer.createQuery();
|
|
476
|
+
query.geometry = view.extent; // Or any geometry
|
|
477
|
+
query.spatialRelationship = "intersects"; // contains, crosses, etc.
|
|
478
|
+
query.returnGeometry = true;
|
|
479
|
+
|
|
480
|
+
const result = await featureLayer.queryFeatures(query);
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### Count Query
|
|
484
|
+
```javascript
|
|
485
|
+
const count = await featureLayer.queryFeatureCount();
|
|
486
|
+
console.log("Total features:", count);
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
### Extent Query
|
|
490
|
+
```javascript
|
|
491
|
+
const extent = await featureLayer.queryExtent();
|
|
492
|
+
await view.goTo(extent);
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
### Statistics Query
|
|
496
|
+
```javascript
|
|
497
|
+
const query = featureLayer.createQuery();
|
|
498
|
+
query.outStatistics = [{
|
|
499
|
+
statisticType: "sum",
|
|
500
|
+
onStatisticField: "population",
|
|
501
|
+
outStatisticFieldName: "totalPop"
|
|
502
|
+
}, {
|
|
503
|
+
statisticType: "avg",
|
|
504
|
+
onStatisticField: "population",
|
|
505
|
+
outStatisticFieldName: "avgPop"
|
|
506
|
+
}];
|
|
507
|
+
|
|
508
|
+
const result = await featureLayer.queryFeatures(query);
|
|
509
|
+
console.log(result.features[0].attributes.totalPop);
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
### Query from LayerView (Client-side)
|
|
513
|
+
```javascript
|
|
514
|
+
const layerView = await view.whenLayerView(featureLayer);
|
|
515
|
+
|
|
516
|
+
// Query only currently visible features
|
|
517
|
+
const query = layerView.createQuery();
|
|
518
|
+
query.geometry = view.extent;
|
|
519
|
+
|
|
520
|
+
const result = await layerView.queryFeatures(query);
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
## Layer Loading
|
|
524
|
+
|
|
525
|
+
```javascript
|
|
526
|
+
// Wait for layer to load
|
|
527
|
+
await featureLayer.load();
|
|
528
|
+
console.log("Fields:", featureLayer.fields);
|
|
529
|
+
console.log("Extent:", featureLayer.fullExtent);
|
|
530
|
+
|
|
531
|
+
// Wait for layer view
|
|
532
|
+
const layerView = await view.whenLayerView(featureLayer);
|
|
533
|
+
|
|
534
|
+
// Check if updating
|
|
535
|
+
layerView.watch("updating", (updating) => {
|
|
536
|
+
if (!updating) {
|
|
537
|
+
console.log("Layer view finished updating");
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
## Definition Expressions (Filters)
|
|
543
|
+
|
|
544
|
+
```javascript
|
|
545
|
+
// SQL WHERE clause filter
|
|
546
|
+
featureLayer.definitionExpression = "state = 'California'";
|
|
547
|
+
|
|
548
|
+
// Clear filter
|
|
549
|
+
featureLayer.definitionExpression = null;
|
|
550
|
+
|
|
551
|
+
// Dynamic filter
|
|
552
|
+
function filterByYear(year) {
|
|
553
|
+
featureLayer.definitionExpression = `year = ${year}`;
|
|
554
|
+
}
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
## TypeScript Usage
|
|
558
|
+
|
|
559
|
+
Layer configurations with `type` properties support autocasting. For TypeScript safety, use `as const`:
|
|
560
|
+
|
|
561
|
+
```typescript
|
|
562
|
+
// Use 'as const' for type safety
|
|
563
|
+
const featureLayer = new FeatureLayer({
|
|
564
|
+
source: graphics,
|
|
565
|
+
fields: [
|
|
566
|
+
{ name: "ObjectID", type: "oid" },
|
|
567
|
+
{ name: "name", type: "string" }
|
|
568
|
+
],
|
|
569
|
+
geometryType: "point",
|
|
570
|
+
renderer: {
|
|
571
|
+
type: "simple",
|
|
572
|
+
symbol: { type: "simple-marker", color: "blue" }
|
|
573
|
+
} as const
|
|
574
|
+
});
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
For complex layer configurations, use type annotations:
|
|
578
|
+
|
|
579
|
+
```typescript
|
|
580
|
+
const renderer: __esri.SimpleRendererProperties = {
|
|
581
|
+
type: "simple",
|
|
582
|
+
symbol: { type: "simple-marker", color: "blue" }
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
layer.renderer = renderer;
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
> **Tip:** See [arcgis-core-maps skill](../arcgis-core-maps/SKILL.md) for detailed guidance on autocasting vs explicit classes.
|
|
589
|
+
|
|
590
|
+
## Common Pitfalls
|
|
591
|
+
|
|
592
|
+
1. **CORS errors with GeoJSON**: GeoJSON URLs must be CORS-enabled or use a proxy
|
|
593
|
+
|
|
594
|
+
2. **Missing outFields**: Specify `outFields: ["*"]` to access all attributes
|
|
595
|
+
|
|
596
|
+
3. **Not waiting for layer load**: Always `await featureLayer.load()` before accessing properties like `fields`
|
|
597
|
+
|
|
598
|
+
4. **Wrong layer for MapView vs SceneView**: Some layers only work in 3D (SceneLayer, IntegratedMeshLayer)
|
|
599
|
+
|
|
600
|
+
5. **Spatial reference mismatch**: Ensure layer data matches view's spatial reference
|
|
601
|
+
|