@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,294 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
applyTo: "**/*.{js,ts,jsx,tsx,html}"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# ArcGIS Maps SDK - Analysis & Utilities
|
|
6
|
-
|
|
7
|
-
## Coordinate Conversion
|
|
8
|
-
|
|
9
|
-
```javascript
|
|
10
|
-
import CoordinateFormatter from "@arcgis/core/geometry/coordinateFormatter.js";
|
|
11
|
-
|
|
12
|
-
await CoordinateFormatter.load();
|
|
13
|
-
|
|
14
|
-
// To DMS
|
|
15
|
-
const dms = CoordinateFormatter.toLatitudeLongitude(point, "dms", 2);
|
|
16
|
-
|
|
17
|
-
// To MGRS
|
|
18
|
-
const mgrs = CoordinateFormatter.toMgrs(point, "automatic", 5, false);
|
|
19
|
-
|
|
20
|
-
// To UTM
|
|
21
|
-
const utm = CoordinateFormatter.toUtm(point, "latitude-band-indicators", true);
|
|
22
|
-
|
|
23
|
-
// From string
|
|
24
|
-
const point = CoordinateFormatter.fromLatitudeLongitude("34.05N, 118.24W");
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## esriRequest (HTTP)
|
|
28
|
-
|
|
29
|
-
```javascript
|
|
30
|
-
import esriRequest from "@arcgis/core/request.js";
|
|
31
|
-
|
|
32
|
-
const response = await esriRequest(url, {
|
|
33
|
-
query: { f: "json" },
|
|
34
|
-
responseType: "json"
|
|
35
|
-
});
|
|
36
|
-
console.log(response.data);
|
|
37
|
-
|
|
38
|
-
// POST request
|
|
39
|
-
const response = await esriRequest(url, {
|
|
40
|
-
method: "post",
|
|
41
|
-
body: formData,
|
|
42
|
-
responseType: "json"
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Print Task
|
|
47
|
-
|
|
48
|
-
```javascript
|
|
49
|
-
import PrintTask from "@arcgis/core/tasks/PrintTask.js";
|
|
50
|
-
import PrintTemplate from "@arcgis/core/tasks/support/PrintTemplate.js";
|
|
51
|
-
import PrintParameters from "@arcgis/core/tasks/support/PrintParameters.js";
|
|
52
|
-
|
|
53
|
-
const printTask = new PrintTask({
|
|
54
|
-
url: "https://utility.arcgisonline.com/.../PrintingTools/GPServer/Export%20Web%20Map%20Task"
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const template = new PrintTemplate({
|
|
58
|
-
format: "pdf",
|
|
59
|
-
layout: "letter-ansi-a-landscape",
|
|
60
|
-
exportOptions: { dpi: 150 }
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const params = new PrintParameters({
|
|
64
|
-
view: view,
|
|
65
|
-
template: template
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const result = await printTask.execute(params);
|
|
69
|
-
console.log("PDF URL:", result.url);
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Route Task
|
|
73
|
-
|
|
74
|
-
```javascript
|
|
75
|
-
import RouteTask from "@arcgis/core/tasks/RouteTask.js";
|
|
76
|
-
import RouteParameters from "@arcgis/core/tasks/support/RouteParameters.js";
|
|
77
|
-
import Stop from "@arcgis/core/tasks/support/Stop.js";
|
|
78
|
-
|
|
79
|
-
const routeTask = new RouteTask({
|
|
80
|
-
url: "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World"
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const params = new RouteParameters({
|
|
84
|
-
stops: new FeatureSet({
|
|
85
|
-
features: [
|
|
86
|
-
new Graphic({ geometry: startPoint }),
|
|
87
|
-
new Graphic({ geometry: endPoint })
|
|
88
|
-
]
|
|
89
|
-
}),
|
|
90
|
-
returnDirections: true
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const result = await routeTask.solve(params);
|
|
94
|
-
const route = result.routeResults[0].route;
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Geocoding
|
|
98
|
-
|
|
99
|
-
```javascript
|
|
100
|
-
import Locator from "@arcgis/core/tasks/Locator.js";
|
|
101
|
-
|
|
102
|
-
const locator = new Locator({
|
|
103
|
-
url: "https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer"
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Address to location
|
|
107
|
-
const results = await locator.addressToLocations({
|
|
108
|
-
address: { SingleLine: "380 New York St, Redlands, CA" }
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Location to address
|
|
112
|
-
const result = await locator.locationToAddress({ location: point });
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Feature Clustering
|
|
116
|
-
|
|
117
|
-
```javascript
|
|
118
|
-
layer.featureReduction = {
|
|
119
|
-
type: "cluster",
|
|
120
|
-
clusterRadius: 80,
|
|
121
|
-
clusterMinSize: 16,
|
|
122
|
-
clusterMaxSize: 60,
|
|
123
|
-
popupTemplate: {
|
|
124
|
-
title: "Cluster of {cluster_count}",
|
|
125
|
-
content: [{ type: "fields", fieldInfos: [{ fieldName: "cluster_count" }] }]
|
|
126
|
-
},
|
|
127
|
-
fields: [{
|
|
128
|
-
name: "cluster_avg_value",
|
|
129
|
-
alias: "Average",
|
|
130
|
-
onStatisticField: "value",
|
|
131
|
-
statisticType: "avg"
|
|
132
|
-
}]
|
|
133
|
-
};
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## Measurement
|
|
137
|
-
|
|
138
|
-
```html
|
|
139
|
-
<arcgis-distance-measurement-2d slot="top-right"></arcgis-distance-measurement-2d>
|
|
140
|
-
<arcgis-area-measurement-2d slot="top-right"></arcgis-area-measurement-2d>
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
```javascript
|
|
144
|
-
import Measurement from "@arcgis/core/widgets/Measurement.js";
|
|
145
|
-
|
|
146
|
-
const measurement = new Measurement({
|
|
147
|
-
view: view,
|
|
148
|
-
activeTool: "distance" // distance, area
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
view.ui.add(measurement, "top-right");
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Swipe
|
|
155
|
-
|
|
156
|
-
```html
|
|
157
|
-
<arcgis-map basemap="streets-vector">
|
|
158
|
-
<arcgis-swipe slot="top-right" position="50"></arcgis-swipe>
|
|
159
|
-
</arcgis-map>
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
```javascript
|
|
163
|
-
import Swipe from "@arcgis/core/widgets/Swipe.js";
|
|
164
|
-
|
|
165
|
-
const swipe = new Swipe({
|
|
166
|
-
view: view,
|
|
167
|
-
leadingLayers: [layer1],
|
|
168
|
-
trailingLayers: [layer2],
|
|
169
|
-
position: 50
|
|
170
|
-
});
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
## Bookmarks
|
|
174
|
-
|
|
175
|
-
```html
|
|
176
|
-
<arcgis-bookmarks slot="top-right"></arcgis-bookmarks>
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
```javascript
|
|
180
|
-
import Bookmarks from "@arcgis/core/widgets/Bookmarks.js";
|
|
181
|
-
|
|
182
|
-
const bookmarks = new Bookmarks({
|
|
183
|
-
view: view,
|
|
184
|
-
bookmarks: [
|
|
185
|
-
{
|
|
186
|
-
name: "Los Angeles",
|
|
187
|
-
viewpoint: { targetGeometry: extent1 }
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
name: "New York",
|
|
191
|
-
viewpoint: { targetGeometry: extent2 }
|
|
192
|
-
}
|
|
193
|
-
]
|
|
194
|
-
});
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## Portal Operations
|
|
198
|
-
|
|
199
|
-
### Save WebMap
|
|
200
|
-
|
|
201
|
-
```javascript
|
|
202
|
-
import WebMap from "@arcgis/core/WebMap.js";
|
|
203
|
-
|
|
204
|
-
const webmap = new WebMap({ basemap: "topo-vector" });
|
|
205
|
-
webmap.add(layer);
|
|
206
|
-
|
|
207
|
-
await webmap.save({
|
|
208
|
-
folder: portal.user.username + "/My Maps",
|
|
209
|
-
title: "My WebMap",
|
|
210
|
-
description: "Description",
|
|
211
|
-
tags: ["tag1", "tag2"]
|
|
212
|
-
});
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Load and Update WebMap
|
|
216
|
-
|
|
217
|
-
```javascript
|
|
218
|
-
const webmap = new WebMap({
|
|
219
|
-
portalItem: { id: "EXISTING_WEBMAP_ID" }
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
await webmap.load();
|
|
223
|
-
webmap.add(newLayer);
|
|
224
|
-
await webmap.save();
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
## Time-Aware Layers
|
|
228
|
-
|
|
229
|
-
```javascript
|
|
230
|
-
// TimeSlider
|
|
231
|
-
import TimeSlider from "@arcgis/core/widgets/TimeSlider.js";
|
|
232
|
-
|
|
233
|
-
const timeSlider = new TimeSlider({
|
|
234
|
-
view: view,
|
|
235
|
-
fullTimeExtent: layer.timeInfo.fullTimeExtent,
|
|
236
|
-
mode: "time-window",
|
|
237
|
-
stops: { interval: { value: 1, unit: "hours" } }
|
|
238
|
-
});
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
```html
|
|
242
|
-
<arcgis-time-slider slot="bottom" mode="time-window" loop></arcgis-time-slider>
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
## Statistics
|
|
246
|
-
|
|
247
|
-
```javascript
|
|
248
|
-
const query = layer.createQuery();
|
|
249
|
-
query.outStatistics = [
|
|
250
|
-
{ statisticType: "sum", onStatisticField: "population", outStatisticFieldName: "total" },
|
|
251
|
-
{ statisticType: "avg", onStatisticField: "population", outStatisticFieldName: "average" },
|
|
252
|
-
{ statisticType: "min", onStatisticField: "population", outStatisticFieldName: "minimum" },
|
|
253
|
-
{ statisticType: "max", onStatisticField: "population", outStatisticFieldName: "maximum" },
|
|
254
|
-
{ statisticType: "count", onStatisticField: "population", outStatisticFieldName: "count" }
|
|
255
|
-
];
|
|
256
|
-
|
|
257
|
-
query.groupByFieldsForStatistics = ["category"];
|
|
258
|
-
|
|
259
|
-
const result = await layer.queryFeatures(query);
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
## Hit Test
|
|
263
|
-
|
|
264
|
-
```javascript
|
|
265
|
-
view.on("click", async (event) => {
|
|
266
|
-
const response = await view.hitTest(event);
|
|
267
|
-
|
|
268
|
-
if (response.results.length > 0) {
|
|
269
|
-
const graphic = response.results[0].graphic;
|
|
270
|
-
console.log("Clicked:", graphic.attributes);
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
## Screenshot
|
|
276
|
-
|
|
277
|
-
```javascript
|
|
278
|
-
const screenshot = await view.takeScreenshot({
|
|
279
|
-
format: "png",
|
|
280
|
-
quality: 100,
|
|
281
|
-
width: 1920,
|
|
282
|
-
height: 1080
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
const image = document.createElement("img");
|
|
286
|
-
image.src = screenshot.dataUrl;
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
## Common Pitfalls
|
|
290
|
-
|
|
291
|
-
1. **API key required** - Many services need API key or OAuth
|
|
292
|
-
2. **Async operations** - Always await async methods
|
|
293
|
-
3. **CORS** - Configure proxy for cross-origin services
|
|
294
|
-
4. **Rate limits** - Be aware of service rate limits
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
applyTo: "**/*.{js,ts,jsx,tsx,html}"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# ArcGIS Maps SDK - Arcade Expressions
|
|
6
|
-
|
|
7
|
-
## Arcade Basics
|
|
8
|
-
|
|
9
|
-
Arcade is used for:
|
|
10
|
-
- Dynamic popup content
|
|
11
|
-
- Data-driven rendering
|
|
12
|
-
- Custom labels
|
|
13
|
-
- Field calculations
|
|
14
|
-
- Form validation
|
|
15
|
-
|
|
16
|
-
### Basic Syntax
|
|
17
|
-
```arcade
|
|
18
|
-
var population = $feature.population;
|
|
19
|
-
var area = $feature.area_sqkm;
|
|
20
|
-
var density = population / area;
|
|
21
|
-
return Round(density, 2);
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Arcade in PopupTemplates
|
|
25
|
-
|
|
26
|
-
```javascript
|
|
27
|
-
layer.popupTemplate = {
|
|
28
|
-
title: "{name}",
|
|
29
|
-
expressionInfos: [
|
|
30
|
-
{
|
|
31
|
-
name: "density",
|
|
32
|
-
title: "Population Density",
|
|
33
|
-
expression: "Round($feature.population / $feature.area, 2)"
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
content: "Density: {expression/density} people/km²"
|
|
37
|
-
};
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Arcade in Renderers
|
|
41
|
-
|
|
42
|
-
```javascript
|
|
43
|
-
layer.renderer = {
|
|
44
|
-
type: "unique-value",
|
|
45
|
-
valueExpression: `
|
|
46
|
-
if ($feature.value > 100) {
|
|
47
|
-
return "High";
|
|
48
|
-
} else {
|
|
49
|
-
return "Low";
|
|
50
|
-
}
|
|
51
|
-
`,
|
|
52
|
-
uniqueValueInfos: [
|
|
53
|
-
{ value: "High", symbol: { type: "simple-fill", color: "red" } },
|
|
54
|
-
{ value: "Low", symbol: { type: "simple-fill", color: "blue" } }
|
|
55
|
-
]
|
|
56
|
-
};
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Visual Variable Expression
|
|
60
|
-
```javascript
|
|
61
|
-
visualVariables: [{
|
|
62
|
-
type: "size",
|
|
63
|
-
valueExpression: "Sqrt($feature.population) * 0.1",
|
|
64
|
-
stops: [
|
|
65
|
-
{ value: 10, size: 4 },
|
|
66
|
-
{ value: 100, size: 40 }
|
|
67
|
-
]
|
|
68
|
-
}]
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Arcade in Labels
|
|
72
|
-
|
|
73
|
-
```javascript
|
|
74
|
-
layer.labelingInfo = [{
|
|
75
|
-
symbol: { type: "text", color: "black", font: { size: 10 } },
|
|
76
|
-
labelExpressionInfo: {
|
|
77
|
-
expression: `
|
|
78
|
-
var pop = $feature.population;
|
|
79
|
-
if (pop > 1000000) {
|
|
80
|
-
return $feature.name + " (" + Round(pop/1000000, 1) + "M)";
|
|
81
|
-
}
|
|
82
|
-
return $feature.name;
|
|
83
|
-
`
|
|
84
|
-
}
|
|
85
|
-
}];
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## Math Functions
|
|
89
|
-
|
|
90
|
-
```arcade
|
|
91
|
-
Round(3.14159, 2) // 3.14
|
|
92
|
-
Floor(3.9) // 3
|
|
93
|
-
Ceil(3.1) // 4
|
|
94
|
-
Abs(-5) // 5
|
|
95
|
-
Sqrt(16) // 4
|
|
96
|
-
Pow(2, 3) // 8
|
|
97
|
-
Min(1, 2, 3) // 1
|
|
98
|
-
Max(1, 2, 3) // 3
|
|
99
|
-
Sum([1, 2, 3]) // 6
|
|
100
|
-
Mean([1, 2, 3]) // 2
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
## Text Functions
|
|
104
|
-
|
|
105
|
-
```arcade
|
|
106
|
-
Upper("hello") // "HELLO"
|
|
107
|
-
Lower("HELLO") // "hello"
|
|
108
|
-
Trim(" hello ") // "hello"
|
|
109
|
-
Left("hello", 2) // "he"
|
|
110
|
-
Right("hello", 2) // "lo"
|
|
111
|
-
Find("l", "hello") // 2
|
|
112
|
-
Replace("hello", "l", "L") // "heLLo"
|
|
113
|
-
Split("a,b,c", ",") // ["a", "b", "c"]
|
|
114
|
-
Concatenate(["a", "b"]) // "ab"
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
## Date Functions
|
|
118
|
-
|
|
119
|
-
```arcade
|
|
120
|
-
Now() // Current date/time
|
|
121
|
-
Today() // Current date
|
|
122
|
-
Year($feature.date_field) // Extract year
|
|
123
|
-
Month($feature.date_field) // Extract month
|
|
124
|
-
Day($feature.date_field) // Extract day
|
|
125
|
-
DateDiff(Now(), $feature.date, "days") // Days between
|
|
126
|
-
Text($feature.date, "MMMM D, YYYY") // Format date
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Geometry Functions
|
|
130
|
-
|
|
131
|
-
```arcade
|
|
132
|
-
Area($feature, "square-kilometers")
|
|
133
|
-
Length($feature, "kilometers")
|
|
134
|
-
Centroid($feature)
|
|
135
|
-
Buffer($feature, 100, "meters")
|
|
136
|
-
Intersects($feature, $otherFeature)
|
|
137
|
-
Contains($feature, $point)
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Conditional Functions
|
|
141
|
-
|
|
142
|
-
```arcade
|
|
143
|
-
// IIf (inline if)
|
|
144
|
-
IIf($feature.value > 100, "High", "Low")
|
|
145
|
-
|
|
146
|
-
// When (multiple conditions)
|
|
147
|
-
When(
|
|
148
|
-
$feature.type == "A", "Type A",
|
|
149
|
-
$feature.type == "B", "Type B",
|
|
150
|
-
"Other"
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
// Decode (value matching)
|
|
154
|
-
Decode($feature.code,
|
|
155
|
-
1, "One",
|
|
156
|
-
2, "Two",
|
|
157
|
-
"Unknown"
|
|
158
|
-
)
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
## Array Functions
|
|
162
|
-
|
|
163
|
-
```arcade
|
|
164
|
-
var arr = [1, 2, 3, 4, 5];
|
|
165
|
-
Count(arr) // 5
|
|
166
|
-
First(arr) // 1
|
|
167
|
-
Last(arr) // 5
|
|
168
|
-
IndexOf(arr, 3) // 2
|
|
169
|
-
Includes(arr, 3) // true
|
|
170
|
-
Push(arr, 6) // adds 6
|
|
171
|
-
Reverse(arr) // reverses
|
|
172
|
-
Sort(arr) // sorts
|
|
173
|
-
Slice(arr, 1, 3) // [2, 3]
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Feature Access
|
|
177
|
-
|
|
178
|
-
```arcade
|
|
179
|
-
// Current feature
|
|
180
|
-
$feature.fieldName
|
|
181
|
-
|
|
182
|
-
// All features in layer
|
|
183
|
-
var allFeatures = FeatureSet($layer);
|
|
184
|
-
var filtered = Filter(allFeatures, "type = 'A'");
|
|
185
|
-
var total = Sum(filtered, "value");
|
|
186
|
-
|
|
187
|
-
// Related records
|
|
188
|
-
var related = FeatureSetByRelationshipName($feature, "relationshipName");
|
|
189
|
-
|
|
190
|
-
// Global variables
|
|
191
|
-
$map, $view, $datastore
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Execute Programmatically
|
|
195
|
-
|
|
196
|
-
```javascript
|
|
197
|
-
import Arcade from "@arcgis/core/arcade/Arcade.js";
|
|
198
|
-
|
|
199
|
-
const profile = {
|
|
200
|
-
variables: [{ name: "$feature", type: "feature" }]
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
const executor = await Arcade.createArcadeExecutor(
|
|
204
|
-
"Round($feature.value * 100, 2)",
|
|
205
|
-
profile
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
const result = executor.execute({ $feature: graphic });
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## Arcade in HTML
|
|
212
|
-
|
|
213
|
-
```html
|
|
214
|
-
<script type="text/plain" id="my-expression">
|
|
215
|
-
var total = $feature.value_a + $feature.value_b;
|
|
216
|
-
return Round(total, 1);
|
|
217
|
-
</script>
|
|
218
|
-
|
|
219
|
-
<script type="module">
|
|
220
|
-
const expression = document.getElementById("my-expression").text;
|
|
221
|
-
layer.popupTemplate = {
|
|
222
|
-
expressionInfos: [{ name: "calc", expression }],
|
|
223
|
-
content: "Value: {expression/calc}"
|
|
224
|
-
};
|
|
225
|
-
</script>
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
## Common Pitfalls
|
|
229
|
-
|
|
230
|
-
1. **Null values** - Check with `IsEmpty($feature.field)`
|
|
231
|
-
2. **Type coercion** - Use `Number()` or `Text()` for conversion
|
|
232
|
-
3. **Case sensitivity** - Functions case-insensitive, field names exact
|
|
233
|
-
4. **Performance** - Complex expressions slow down rendering
|
|
234
|
-
5. **Debugging** - Use `Console()` function
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
applyTo: "**/*.{js,ts,jsx,tsx,html}"
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# ArcGIS Maps SDK - Authentication
|
|
6
|
-
|
|
7
|
-
## OAuth 2.0 Authentication
|
|
8
|
-
|
|
9
|
-
### Basic OAuth Setup
|
|
10
|
-
```javascript
|
|
11
|
-
import OAuthInfo from "@arcgis/core/identity/OAuthInfo.js";
|
|
12
|
-
import esriId from "@arcgis/core/identity/IdentityManager.js";
|
|
13
|
-
|
|
14
|
-
const oauthInfo = new OAuthInfo({
|
|
15
|
-
appId: "YOUR_APP_ID",
|
|
16
|
-
popup: false // false = redirect, true = popup
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
esriId.registerOAuthInfos([oauthInfo]);
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Check Sign-In Status
|
|
23
|
-
```javascript
|
|
24
|
-
async function checkSignIn() {
|
|
25
|
-
try {
|
|
26
|
-
await esriId.checkSignInStatus(oauthInfo.portalUrl + "/sharing");
|
|
27
|
-
const portal = new Portal({ authMode: "immediate" });
|
|
28
|
-
await portal.load();
|
|
29
|
-
console.log("Signed in as:", portal.user.username);
|
|
30
|
-
return portal;
|
|
31
|
-
} catch {
|
|
32
|
-
console.log("Not signed in");
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Sign In
|
|
39
|
-
```javascript
|
|
40
|
-
async function signIn() {
|
|
41
|
-
const credential = await esriId.getCredential(
|
|
42
|
-
oauthInfo.portalUrl + "/sharing"
|
|
43
|
-
);
|
|
44
|
-
return credential;
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Sign Out
|
|
49
|
-
```javascript
|
|
50
|
-
function signOut() {
|
|
51
|
-
esriId.destroyCredentials();
|
|
52
|
-
window.location.reload();
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### OAuth Component
|
|
57
|
-
```html
|
|
58
|
-
<arcgis-oauth app-id="YOUR_APP_ID"></arcgis-oauth>
|
|
59
|
-
|
|
60
|
-
<script type="module">
|
|
61
|
-
const oauth = document.querySelector("arcgis-oauth");
|
|
62
|
-
oauth.addEventListener("arcgisSignIn", (e) => console.log(e.detail.credential));
|
|
63
|
-
oauth.addEventListener("arcgisSignOut", () => console.log("Signed out"));
|
|
64
|
-
</script>
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## API Keys
|
|
68
|
-
|
|
69
|
-
```javascript
|
|
70
|
-
import esriConfig from "@arcgis/core/config.js";
|
|
71
|
-
|
|
72
|
-
esriConfig.apiKey = "YOUR_API_KEY";
|
|
73
|
-
|
|
74
|
-
const map = new Map({
|
|
75
|
-
basemap: "arcgis/streets" // Requires API key
|
|
76
|
-
});
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### API Key in HTML
|
|
80
|
-
```html
|
|
81
|
-
<script>
|
|
82
|
-
window.esriConfig = { apiKey: "YOUR_API_KEY" };
|
|
83
|
-
</script>
|
|
84
|
-
<script src="https://js.arcgis.com/4.34/"></script>
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Enterprise Portal
|
|
88
|
-
|
|
89
|
-
```javascript
|
|
90
|
-
const oauthInfo = new OAuthInfo({
|
|
91
|
-
appId: "YOUR_APP_ID",
|
|
92
|
-
portalUrl: "https://your-portal.com/portal",
|
|
93
|
-
popup: true
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// Or set globally
|
|
97
|
-
import esriConfig from "@arcgis/core/config.js";
|
|
98
|
-
esriConfig.portalUrl = "https://your-portal.com/portal";
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## Portal User Information
|
|
102
|
-
|
|
103
|
-
```javascript
|
|
104
|
-
import Portal from "@arcgis/core/portal/Portal.js";
|
|
105
|
-
|
|
106
|
-
const portal = new Portal({ authMode: "immediate" });
|
|
107
|
-
await portal.load();
|
|
108
|
-
|
|
109
|
-
console.log("Username:", portal.user.username);
|
|
110
|
-
console.log("Full name:", portal.user.fullName);
|
|
111
|
-
console.log("Email:", portal.user.email);
|
|
112
|
-
console.log("Role:", portal.user.role);
|
|
113
|
-
console.log("Org:", portal.name);
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
## Query User Items
|
|
117
|
-
|
|
118
|
-
```javascript
|
|
119
|
-
import PortalQueryParams from "@arcgis/core/portal/PortalQueryParams.js";
|
|
120
|
-
|
|
121
|
-
const queryParams = new PortalQueryParams({
|
|
122
|
-
query: `owner:${portal.user.username}`,
|
|
123
|
-
sortField: "modified",
|
|
124
|
-
sortOrder: "desc",
|
|
125
|
-
num: 20
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const result = await portal.queryItems(queryParams);
|
|
129
|
-
result.results.forEach(item => console.log(item.title, item.type));
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
## Token Management
|
|
133
|
-
|
|
134
|
-
```javascript
|
|
135
|
-
// Get token
|
|
136
|
-
const credential = await esriId.getCredential("https://services.arcgis.com/...");
|
|
137
|
-
console.log("Token:", credential.token);
|
|
138
|
-
console.log("Expires:", new Date(credential.expires));
|
|
139
|
-
|
|
140
|
-
// Register token
|
|
141
|
-
esriId.registerToken({
|
|
142
|
-
server: "https://services.arcgis.com/",
|
|
143
|
-
token: "YOUR_TOKEN"
|
|
144
|
-
});
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
## Trusted Servers
|
|
148
|
-
|
|
149
|
-
```javascript
|
|
150
|
-
import esriConfig from "@arcgis/core/config.js";
|
|
151
|
-
|
|
152
|
-
esriConfig.request.trustedServers.push("https://services.arcgis.com");
|
|
153
|
-
esriConfig.request.trustedServers.push("https://your-server.com");
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
## CORS and Proxy
|
|
157
|
-
|
|
158
|
-
```javascript
|
|
159
|
-
esriConfig.request.proxyUrl = "/proxy/";
|
|
160
|
-
|
|
161
|
-
esriConfig.request.proxyRules.push({
|
|
162
|
-
urlPrefix: "https://services.arcgis.com",
|
|
163
|
-
proxyUrl: "/proxy/"
|
|
164
|
-
});
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## Error Handling
|
|
168
|
-
|
|
169
|
-
```javascript
|
|
170
|
-
esriId.on("credential-create", (event) => {
|
|
171
|
-
console.log("New credential:", event.credential);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
layer.on("layerview-create-error", (event) => {
|
|
175
|
-
if (event.error.name === "identity-manager:not-authorized") {
|
|
176
|
-
signIn();
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Common Pitfalls
|
|
182
|
-
|
|
183
|
-
1. **App ID registration** - Must be registered with correct redirect URIs
|
|
184
|
-
2. **Popup blockers** - Use redirect flow as fallback
|
|
185
|
-
3. **Token expiration** - Handle refresh or re-authentication
|
|
186
|
-
4. **CORS errors** - Configure trusted servers or use proxy
|
|
187
|
-
5. **Portal URL mismatch** - Trailing slashes matter
|