@saschabrunnerch/arcgis-maps-sdk-js-ai-context 0.0.1 → 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 -201
- 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/skills/arcgis-starter-app/SKILL.md +273 -0
- package/contexts/4.34/skills/arcgis-starter-app-extended/SKILL.md +649 -0
- 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 +294 -379
- 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-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
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
applyTo: "**/*.{js,ts,jsx,tsx,html}"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# ArcGIS Maps SDK - Layers
|
|
6
|
-
|
|
7
|
-
## Layer Types Overview
|
|
8
|
-
|
|
9
|
-
| Layer Type | Use Case |
|
|
10
|
-
|------------|----------|
|
|
11
|
-
| FeatureLayer | Feature services, editable data |
|
|
12
|
-
| GraphicsLayer | Client-side temporary graphics |
|
|
13
|
-
| GeoJSONLayer | GeoJSON files/URLs |
|
|
14
|
-
| CSVLayer | CSV files with coordinates |
|
|
15
|
-
| TileLayer | Cached map tiles |
|
|
16
|
-
| VectorTileLayer | Vector tiles |
|
|
17
|
-
| ImageryTileLayer | Raster imagery |
|
|
18
|
-
| SceneLayer | 3D buildings (SceneView only) |
|
|
19
|
-
| IntegratedMeshLayer | Photogrammetry meshes |
|
|
20
|
-
| PointCloudLayer | LiDAR point clouds |
|
|
21
|
-
|
|
22
|
-
## FeatureLayer
|
|
23
|
-
|
|
24
|
-
### From URL
|
|
25
|
-
```javascript
|
|
26
|
-
import FeatureLayer from "@arcgis/core/layers/FeatureLayer.js";
|
|
27
|
-
|
|
28
|
-
const layer = new FeatureLayer({
|
|
29
|
-
url: "https://services.arcgis.com/.../FeatureServer/0",
|
|
30
|
-
outFields: ["*"],
|
|
31
|
-
popupTemplate: {
|
|
32
|
-
title: "{NAME}",
|
|
33
|
-
content: "{DESCRIPTION}"
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
map.add(layer);
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### From Portal Item
|
|
41
|
-
```javascript
|
|
42
|
-
const layer = new FeatureLayer({
|
|
43
|
-
portalItem: { id: "51c851fef66143959986b473b345b7ca" },
|
|
44
|
-
outFields: ["*"]
|
|
45
|
-
});
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Client-Side (In-Memory)
|
|
49
|
-
```javascript
|
|
50
|
-
const layer = new FeatureLayer({
|
|
51
|
-
source: graphics,
|
|
52
|
-
fields: [
|
|
53
|
-
{ name: "ObjectID", type: "oid" },
|
|
54
|
-
{ name: "name", type: "string" },
|
|
55
|
-
{ name: "value", type: "double" }
|
|
56
|
-
],
|
|
57
|
-
objectIdField: "ObjectID",
|
|
58
|
-
geometryType: "point",
|
|
59
|
-
spatialReference: { wkid: 4326 }
|
|
60
|
-
});
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Configuration Options
|
|
64
|
-
```javascript
|
|
65
|
-
const layer = new FeatureLayer({
|
|
66
|
-
url: "...",
|
|
67
|
-
outFields: ["*"],
|
|
68
|
-
definitionExpression: "population > 10000",
|
|
69
|
-
minScale: 500000,
|
|
70
|
-
maxScale: 0,
|
|
71
|
-
visible: true,
|
|
72
|
-
opacity: 0.8,
|
|
73
|
-
title: "Cities",
|
|
74
|
-
elevationInfo: { mode: "relative-to-ground" }
|
|
75
|
-
});
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## GraphicsLayer
|
|
79
|
-
|
|
80
|
-
```javascript
|
|
81
|
-
import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer.js";
|
|
82
|
-
import Graphic from "@arcgis/core/Graphic.js";
|
|
83
|
-
|
|
84
|
-
const graphicsLayer = new GraphicsLayer();
|
|
85
|
-
map.add(graphicsLayer);
|
|
86
|
-
|
|
87
|
-
const graphic = new Graphic({
|
|
88
|
-
geometry: {
|
|
89
|
-
type: "point",
|
|
90
|
-
longitude: -118.24,
|
|
91
|
-
latitude: 34.05
|
|
92
|
-
},
|
|
93
|
-
symbol: {
|
|
94
|
-
type: "simple-marker",
|
|
95
|
-
color: "red",
|
|
96
|
-
size: 12
|
|
97
|
-
},
|
|
98
|
-
attributes: { name: "Los Angeles" },
|
|
99
|
-
popupTemplate: { title: "{name}" }
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
graphicsLayer.add(graphic);
|
|
103
|
-
graphicsLayer.addMany([graphic1, graphic2]);
|
|
104
|
-
graphicsLayer.removeAll();
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## GeoJSONLayer
|
|
108
|
-
|
|
109
|
-
```javascript
|
|
110
|
-
import GeoJSONLayer from "@arcgis/core/layers/GeoJSONLayer.js";
|
|
111
|
-
|
|
112
|
-
const layer = new GeoJSONLayer({
|
|
113
|
-
url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson",
|
|
114
|
-
popupTemplate: {
|
|
115
|
-
title: "Magnitude {mag}",
|
|
116
|
-
content: "Location: {place}"
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## CSVLayer
|
|
122
|
-
|
|
123
|
-
```javascript
|
|
124
|
-
import CSVLayer from "@arcgis/core/layers/CSVLayer.js";
|
|
125
|
-
|
|
126
|
-
const layer = new CSVLayer({
|
|
127
|
-
url: "https://example.com/data.csv",
|
|
128
|
-
latitudeField: "latitude",
|
|
129
|
-
longitudeField: "longitude",
|
|
130
|
-
delimiter: ","
|
|
131
|
-
});
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## TileLayer
|
|
135
|
-
|
|
136
|
-
```javascript
|
|
137
|
-
import TileLayer from "@arcgis/core/layers/TileLayer.js";
|
|
138
|
-
|
|
139
|
-
const layer = new TileLayer({
|
|
140
|
-
url: "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
|
|
141
|
-
});
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## VectorTileLayer
|
|
145
|
-
|
|
146
|
-
```javascript
|
|
147
|
-
import VectorTileLayer from "@arcgis/core/layers/VectorTileLayer.js";
|
|
148
|
-
|
|
149
|
-
const layer = new VectorTileLayer({
|
|
150
|
-
portalItem: { id: "VECTOR_TILE_ITEM_ID" }
|
|
151
|
-
});
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## WebTileLayer (OpenStreetMap, etc.)
|
|
155
|
-
|
|
156
|
-
```javascript
|
|
157
|
-
import WebTileLayer from "@arcgis/core/layers/WebTileLayer.js";
|
|
158
|
-
|
|
159
|
-
const osmLayer = new WebTileLayer({
|
|
160
|
-
urlTemplate: "https://{subDomain}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
161
|
-
subDomains: ["a", "b", "c"],
|
|
162
|
-
copyright: "OpenStreetMap contributors"
|
|
163
|
-
});
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
## 3D Layers
|
|
167
|
-
|
|
168
|
-
### SceneLayer
|
|
169
|
-
```javascript
|
|
170
|
-
import SceneLayer from "@arcgis/core/layers/SceneLayer.js";
|
|
171
|
-
|
|
172
|
-
const layer = new SceneLayer({
|
|
173
|
-
portalItem: { id: "2e0761b9a4274b8db52c4bf34356911e" }
|
|
174
|
-
});
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### IntegratedMeshLayer
|
|
178
|
-
```javascript
|
|
179
|
-
import IntegratedMeshLayer from "@arcgis/core/layers/IntegratedMeshLayer.js";
|
|
180
|
-
|
|
181
|
-
const layer = new IntegratedMeshLayer({
|
|
182
|
-
url: "https://tiles.arcgis.com/tiles/.../IntegratedMeshServer"
|
|
183
|
-
});
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
### PointCloudLayer
|
|
187
|
-
```javascript
|
|
188
|
-
import PointCloudLayer from "@arcgis/core/layers/PointCloudLayer.js";
|
|
189
|
-
|
|
190
|
-
const layer = new PointCloudLayer({
|
|
191
|
-
url: "https://tiles.arcgis.com/tiles/.../SceneServer"
|
|
192
|
-
});
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
## Layer Management
|
|
196
|
-
|
|
197
|
-
```javascript
|
|
198
|
-
// Add layers
|
|
199
|
-
map.add(layer);
|
|
200
|
-
map.add(layer, 0); // At index
|
|
201
|
-
map.addMany([layer1, layer2]);
|
|
202
|
-
|
|
203
|
-
// Remove layers
|
|
204
|
-
map.remove(layer);
|
|
205
|
-
map.removeAll();
|
|
206
|
-
|
|
207
|
-
// Reorder
|
|
208
|
-
map.reorder(layer, newIndex);
|
|
209
|
-
|
|
210
|
-
// Find layer
|
|
211
|
-
const layer = map.findLayerById("myLayerId");
|
|
212
|
-
const layer = map.layers.find(l => l.title === "Cities");
|
|
213
|
-
|
|
214
|
-
// Visibility and opacity
|
|
215
|
-
layer.visible = false;
|
|
216
|
-
layer.opacity = 0.5;
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
## Querying Features
|
|
220
|
-
|
|
221
|
-
### Basic Query
|
|
222
|
-
```javascript
|
|
223
|
-
const query = layer.createQuery();
|
|
224
|
-
query.where = "population > 100000";
|
|
225
|
-
query.outFields = ["name", "population"];
|
|
226
|
-
query.returnGeometry = true;
|
|
227
|
-
|
|
228
|
-
const result = await layer.queryFeatures(query);
|
|
229
|
-
console.log(result.features);
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Spatial Query
|
|
233
|
-
```javascript
|
|
234
|
-
query.geometry = view.extent;
|
|
235
|
-
query.spatialRelationship = "intersects";
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Statistics Query
|
|
239
|
-
```javascript
|
|
240
|
-
query.outStatistics = [{
|
|
241
|
-
statisticType: "sum",
|
|
242
|
-
onStatisticField: "population",
|
|
243
|
-
outStatisticFieldName: "totalPop"
|
|
244
|
-
}];
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
### Query from LayerView (Client-side)
|
|
248
|
-
```javascript
|
|
249
|
-
const layerView = await view.whenLayerView(layer);
|
|
250
|
-
const result = await layerView.queryFeatures(layerView.createQuery());
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
## Definition Expressions (Filters)
|
|
254
|
-
|
|
255
|
-
```javascript
|
|
256
|
-
layer.definitionExpression = "state = 'California'";
|
|
257
|
-
layer.definitionExpression = null; // Clear filter
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
## Layer Loading
|
|
261
|
-
|
|
262
|
-
```javascript
|
|
263
|
-
await layer.load();
|
|
264
|
-
console.log("Fields:", layer.fields);
|
|
265
|
-
console.log("Extent:", layer.fullExtent);
|
|
266
|
-
|
|
267
|
-
const layerView = await view.whenLayerView(layer);
|
|
268
|
-
layerView.watch("updating", (updating) => {
|
|
269
|
-
if (!updating) console.log("Layer view ready");
|
|
270
|
-
});
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
## Common Pitfalls
|
|
274
|
-
|
|
275
|
-
1. **CORS errors with GeoJSON** - URL must be CORS-enabled
|
|
276
|
-
2. **Missing outFields** - Specify `outFields: ["*"]` for all attributes
|
|
277
|
-
3. **Not waiting for layer load** - Use `await layer.load()` before accessing properties
|
|
278
|
-
4. **Spatial reference mismatch** - Ensure layer matches view's spatial reference
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
applyTo: "**/*.{js,ts,jsx,tsx,html}"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# ArcGIS Maps SDK - Popup Templates
|
|
6
|
-
|
|
7
|
-
## Content Types
|
|
8
|
-
|
|
9
|
-
| Type | Purpose |
|
|
10
|
-
|------|---------|
|
|
11
|
-
| TextContent | HTML or plain text |
|
|
12
|
-
| FieldsContent | Attribute table |
|
|
13
|
-
| MediaContent | Charts and images |
|
|
14
|
-
| AttachmentsContent | File attachments |
|
|
15
|
-
| ExpressionContent | Arcade expression results |
|
|
16
|
-
| RelationshipContent | Related records |
|
|
17
|
-
|
|
18
|
-
## Basic PopupTemplate
|
|
19
|
-
|
|
20
|
-
```javascript
|
|
21
|
-
layer.popupTemplate = {
|
|
22
|
-
title: "{name}",
|
|
23
|
-
content: "Population: {population}<br>Area: {area} sq mi"
|
|
24
|
-
};
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### With Formatting
|
|
28
|
-
|
|
29
|
-
```javascript
|
|
30
|
-
layer.popupTemplate = {
|
|
31
|
-
title: "{city_name}, {state}",
|
|
32
|
-
content: `
|
|
33
|
-
<p>Population: {population:NumberFormat(places: 0)}</p>
|
|
34
|
-
<p>Founded: {founded_date:DateFormat(selector: 'date')}</p>
|
|
35
|
-
`
|
|
36
|
-
};
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Content Array (Multiple Types)
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
layer.popupTemplate = {
|
|
43
|
-
title: "{name}",
|
|
44
|
-
content: [
|
|
45
|
-
{
|
|
46
|
-
type: "text",
|
|
47
|
-
text: "<b>Overview</b><br>{description}"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
type: "fields",
|
|
51
|
-
fieldInfos: [
|
|
52
|
-
{ fieldName: "population", label: "Population" },
|
|
53
|
-
{ fieldName: "area", label: "Area" }
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
type: "media",
|
|
58
|
-
mediaInfos: [{
|
|
59
|
-
type: "pie-chart",
|
|
60
|
-
title: "Demographics",
|
|
61
|
-
value: { fields: ["white", "black", "asian", "other"] }
|
|
62
|
-
}]
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
};
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## FieldsContent
|
|
69
|
-
|
|
70
|
-
```javascript
|
|
71
|
-
{
|
|
72
|
-
type: "fields",
|
|
73
|
-
fieldInfos: [
|
|
74
|
-
{ fieldName: "name", label: "Name" },
|
|
75
|
-
{
|
|
76
|
-
fieldName: "population",
|
|
77
|
-
label: "Population",
|
|
78
|
-
format: { digitSeparator: true, places: 0 }
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
fieldName: "date_created",
|
|
82
|
-
label: "Created",
|
|
83
|
-
format: { dateFormat: "short-date" }
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Date Formats
|
|
90
|
-
- `short-date` - 12/30/2024
|
|
91
|
-
- `short-date-short-time` - 12/30/2024, 3:30 PM
|
|
92
|
-
- `long-month-day-year` - December 30, 2024
|
|
93
|
-
- `year` - 2024
|
|
94
|
-
|
|
95
|
-
## MediaContent (Charts)
|
|
96
|
-
|
|
97
|
-
```javascript
|
|
98
|
-
{
|
|
99
|
-
type: "media",
|
|
100
|
-
mediaInfos: [
|
|
101
|
-
{
|
|
102
|
-
type: "bar-chart",
|
|
103
|
-
title: "Sales by Quarter",
|
|
104
|
-
value: { fields: ["q1", "q2", "q3", "q4"] }
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
type: "pie-chart",
|
|
108
|
-
title: "Distribution",
|
|
109
|
-
value: { fields: ["typeA", "typeB", "typeC"] }
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
type: "image",
|
|
113
|
-
value: { sourceURL: "{image_url}" }
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Chart types: `bar-chart`, `pie-chart`, `line-chart`, `column-chart`, `image`
|
|
120
|
-
|
|
121
|
-
## AttachmentsContent
|
|
122
|
-
|
|
123
|
-
```javascript
|
|
124
|
-
{
|
|
125
|
-
type: "attachments",
|
|
126
|
-
displayType: "preview", // preview, list, auto
|
|
127
|
-
title: "Photos"
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Arcade Expressions
|
|
132
|
-
|
|
133
|
-
```javascript
|
|
134
|
-
layer.popupTemplate = {
|
|
135
|
-
expressionInfos: [
|
|
136
|
-
{
|
|
137
|
-
name: "density",
|
|
138
|
-
title: "Density",
|
|
139
|
-
expression: "Round($feature.population / $feature.area, 2)"
|
|
140
|
-
}
|
|
141
|
-
],
|
|
142
|
-
content: [
|
|
143
|
-
{
|
|
144
|
-
type: "fields",
|
|
145
|
-
fieldInfos: [
|
|
146
|
-
{ fieldName: "expression/density", label: "Population Density" }
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
};
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Actions (Custom Buttons)
|
|
154
|
-
|
|
155
|
-
```javascript
|
|
156
|
-
layer.popupTemplate = {
|
|
157
|
-
title: "{name}",
|
|
158
|
-
content: "...",
|
|
159
|
-
actions: [
|
|
160
|
-
{ id: "zoom-to", title: "Zoom To", className: "esri-icon-zoom-in-magnifying-glass" },
|
|
161
|
-
{ id: "edit", title: "Edit", className: "esri-icon-edit" }
|
|
162
|
-
]
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
view.popup.on("trigger-action", (event) => {
|
|
166
|
-
if (event.action.id === "zoom-to") {
|
|
167
|
-
view.goTo(view.popup.selectedFeature);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## Dynamic Content Function
|
|
173
|
-
|
|
174
|
-
```javascript
|
|
175
|
-
layer.popupTemplate = {
|
|
176
|
-
title: "{name}",
|
|
177
|
-
content: (feature) => {
|
|
178
|
-
const attrs = feature.graphic.attributes;
|
|
179
|
-
if (attrs.type === "residential") {
|
|
180
|
-
return `<p>Bedrooms: ${attrs.bedrooms}</p>`;
|
|
181
|
-
}
|
|
182
|
-
return `<p>Zoning: ${attrs.zoning}</p>`;
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### Async Content
|
|
188
|
-
|
|
189
|
-
```javascript
|
|
190
|
-
layer.popupTemplate = {
|
|
191
|
-
title: "{name}",
|
|
192
|
-
content: async (feature) => {
|
|
193
|
-
const response = await fetch(`/api/details/${feature.graphic.attributes.id}`);
|
|
194
|
-
const data = await response.json();
|
|
195
|
-
return `<h3>${data.title}</h3><p>${data.description}</p>`;
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
## Related Records
|
|
201
|
-
|
|
202
|
-
```javascript
|
|
203
|
-
{
|
|
204
|
-
type: "relationship",
|
|
205
|
-
relationshipId: 0,
|
|
206
|
-
title: "Related Inspections",
|
|
207
|
-
displayCount: 5,
|
|
208
|
-
orderByFields: [{ field: "date", order: "desc" }]
|
|
209
|
-
}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
## OutFields
|
|
213
|
-
|
|
214
|
-
```javascript
|
|
215
|
-
layer.popupTemplate = {
|
|
216
|
-
title: "{name}",
|
|
217
|
-
content: "{description}",
|
|
218
|
-
outFields: ["name", "description"] // or ["*"] for all
|
|
219
|
-
};
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## Last Edit Info
|
|
223
|
-
|
|
224
|
-
```javascript
|
|
225
|
-
layer.popupTemplate = {
|
|
226
|
-
title: "{name}",
|
|
227
|
-
content: "...",
|
|
228
|
-
lastEditInfoEnabled: true
|
|
229
|
-
};
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## Clustering Popups
|
|
233
|
-
|
|
234
|
-
```javascript
|
|
235
|
-
layer.featureReduction = {
|
|
236
|
-
type: "cluster",
|
|
237
|
-
popupTemplate: {
|
|
238
|
-
title: "Cluster of {cluster_count} features",
|
|
239
|
-
content: [{
|
|
240
|
-
type: "fields",
|
|
241
|
-
fieldInfos: [
|
|
242
|
-
{ fieldName: "cluster_count", label: "Count" },
|
|
243
|
-
{ fieldName: "cluster_avg_value", label: "Average" }
|
|
244
|
-
]
|
|
245
|
-
}]
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
## GeoJSON Field Path
|
|
251
|
-
|
|
252
|
-
```javascript
|
|
253
|
-
// GeoJSON uses properties/ prefix
|
|
254
|
-
layer.popupTemplate = {
|
|
255
|
-
title: "{properties/name}",
|
|
256
|
-
content: "{properties/description}"
|
|
257
|
-
};
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
## Common Pitfalls
|
|
261
|
-
|
|
262
|
-
1. **Field names case sensitive** - Must match exactly
|
|
263
|
-
2. **OutFields required** - Fields must be in outFields
|
|
264
|
-
3. **GeoJSON prefix** - Use `properties/fieldName`
|
|
265
|
-
4. **Expression reference** - Use `expression/name` prefix
|
|
266
|
-
5. **Async content** - Function must return a value or Promise
|