arcgis-maps-sdk-js-ai-context / arcgis-interaction
AGENTS.md0 starsChanged 7 months agoMITView on GitHub
Quick-reference decisions, checklists, and tables for user interaction patterns. Recommendation: Use immediate-click for hit testing and feature selection. It fires instantly without waiting for a potential double-click. Always clean up handles and event listeners to prevent memory leaks.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,542 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository47 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/arcgis-ai-components/AGENTS.mdAGENTS.md
- skills/arcgis-authentication/AGENTS.mdAGENTS.md
- skills/arcgis-charts/AGENTS.mdAGENTS.md
- skills/arcgis-coding-components/AGENTS.mdAGENTS.md
- skills/arcgis-core-maps/AGENTS.mdAGENTS.md
- skills/arcgis-editing/AGENTS.mdAGENTS.md
- skills/arcgis-embeddable-maps/AGENTS.mdAGENTS.md
- skills/arcgis-layers/AGENTS.mdAGENTS.md
- skills/arcgis-starter-app/AGENTS.mdAGENTS.md
- skills/arcgis-visualization/AGENTS.mdAGENTS.md
- skills/arcgis-widgets-ui/AGENTS.mdAGENTS.md
- arcgis-3d-layersSkill
- arcgis-advanced-layersSkill
- arcgis-ai-componentsSkill
- arcgis-arcadeSkill
- arcgis-authenticationSkill
- arcgis-chartsSkill
- arcgis-cim-symbolsSkill
- arcgis-coding-componentsSkill
- arcgis-coordinates-projectionSkill
- arcgis-core-mapsSkill
- arcgis-core-utilitiesSkill
- arcgis-custom-renderingSkill
- arcgis-editingSkill
- arcgis-embeddable-mapsSkill
- arcgis-feature-effectsSkill
- arcgis-geometry-operationsSkill
- arcgis-imagerySkill
- arcgis-interactionSkill
- arcgis-knowledge-graphsSkill
- arcgis-layersSkill
- arcgis-map-toolsSkill
- arcgis-performanceSkill
- arcgis-popup-templatesSkill
- arcgis-portal-contentSkill
- arcgis-rest-servicesSkill
- arcgis-scene-environmentSkill
- arcgis-smart-mappingSkill
- arcgis-spatial-analysisSkill
- arcgis-starter-appSkill
- arcgis-tables-formsSkill
- arcgis-time-animationSkill
- arcgis-utility-networksSkill
- arcgis-visualizationSkill
- arcgis-widgets-advancedSkill
- arcgis-widgets-uiSkill
The file
We split this AGENTS.md into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 47
Always clean up handles and event listeners to prevent memory leaks.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Guide: arcgis-interaction
Quick-reference decisions, checklists, and tables for user interaction patterns.
Hit Test vs Query vs Popup Decision Matrix
| Need | Approach | Method |
| User clicks a feature and sees info | Popup (built-in) | Set popupTemplate on layer, it works automatically |
| User clicks and you run custom logic | Hit test | view.hitTest(event) in a click handler |
| Find all features in an area | Spatial query | featureLayer.queryFeatures(query) |
| Highlight features by attribute | Attribute query + highlight | queryObjectIds() then layerView.highlight(oids) |
| Show a cursor change on hover | Hit test on pointer-move | view.hitTest(event) in a pointer-move handler |
| Draw a shape and select features in it | Sketch + spatial query | Sketch widget for drawing, then query with the geometry |
When to use each:
- Popup -- Simplest. Just configure
popupTemplateon the layer. No code for the interaction itself. - Hit test -- Returns the graphic at a screen point. Use when you need the actual feature object for custom behavior (not just a popup).
- Server query -- Returns features matching SQL/spatial criteria from the service. Use for bulk operations or features not visible on screen.
- Client query --
layerView.queryFeatures()queries only loaded features. Faster but limited to what is in the view.
Click Event Selection Guide
| Event | Delay | Use Case |
click | ~300ms (waits for double-click check) | When double-click behavior matters |
immediate-click | None | Hit testing, feature selection (recommended) |
double-click | N/A | Override default zoom-in |
immediate-double-click | None | Cannot be prevented by immediate-click stopPropagation |
Recommendation: Use
immediate-clickfor hit testing and feature selection. It fires instantly without waiting for a potential double-click.
Click-to-Select Implementation Checklist
- Get a reference to the target
FeatureLayer - Get the LayerView:
const layerView = await view.whenLayerView(featureLayer) - Store a highlight handle variable:
let highlightHandle = null - Add click handler:
view.on("immediate-click", async (event) => { ... }) - Inside handler, run hit test:
const response = await view.hitTest(event, { include: [featureLayer] }) - Remove previous highlight:
highlightHandle?.remove() - If results found, highlight:
highlightHandle = layerView.highlight(graphic) - Optionally open popup or update side panel with feature attributes
Cleanup Pattern
Always clean up handles and event listeners to prevent memory leaks.
Handle-based cleanup (highlight, watch)
const handle = layerView.highlight(graphic);
// Later:
handle.remove();Event listener cleanup
const handle = view.on("click", handler);
// Later:
handle.remove();reactiveUtils cleanup
import * as reactiveUtils from "@arcgis/core/core/reactiveUtils.js";
const handle = reactiveUtils.watch(() => view.zoom, callback);
// Later:
handle.remove();Destroy pattern (widgets)
widget.destroy(); // Removes from DOM and cleans upChecklist for cleanup
- Store all
view.on()return handles - Store all
reactiveUtils.watch()/when()/once()return handles - Store all
layerView.highlight()return handles - Call
.remove()on handles when the interaction is no longer needed - Call
.destroy()on widgets when removing them - In frameworks (React/Angular): clean up in unmount/destroy lifecycle hooks
Event Types Quick Reference
| Event | Fires when | Common use |
click | User clicks the map (with delay) | Non-latency-sensitive selection |
immediate-click | User clicks (no delay) | Feature selection, hit testing |
double-click | User double-clicks | Override default zoom behavior |
immediate-double-click | Double-click (no delay) | Cannot be stopped by immediate-click |
pointer-move | Mouse moves over map | Hover highlighting, coordinate display |
pointer-down / pointer-up | Mouse button pressed/released | Custom drag interactions |
drag | User drags the map | Custom pan behavior |
key-down / key-up | Keyboard input while map focused | Keyboard shortcuts |
hold | Long press | Mobile context menu |
Preventing Default Behavior
view.on("double-click", (event) => {
event.stopPropagation(); // Prevents default zoom-in
});Coordinate Conversion Quick Reference
| Direction | Method |
| Screen (pixels) to Map (geographic) | view.toMap({ x, y }) |
| Map (geographic) to Screen (pixels) | view.toScreen(mapPoint) |
| Click event to Map point | event.mapPoint (already available) |
| Pointer event to Map point | view.toMap(event) (must convert) |
Highlight Options
| Property | Default | Purpose |
color | [0, 255, 255, 1] (cyan) | Highlight outline/halo color |
haloOpacity | 1 | Opacity of the halo around features |
fillOpacity | 0.25 | Opacity of the fill inside features |
Set on view.highlightOptions at the MapView / SceneView level.
Sketch Component vs Widget vs Draw
| Approach | UI | Snapping | Undo/Redo | Use Case |
<arcgis-sketch> | Full toolbar | Yes | Yes | Quick setup with web components |
Sketch widget | Full toolbar | Yes | Yes | Core API with programmatic control |
Draw tool | None | No | No | Low-level drawing with custom UI |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

