Agent guide

Making maps with an AI agent

GISMap Online opens a map from a link. An agent that can only write text can make a map by writing one JSON object into a URL; agents that run code or drive a browser get validation, statistics and live control. Preparing a link needs no GISMap Online account or GISMap Online API key. Loading its remote sources needs network access; an AI provider has its own setup and terms.

When to use this workflow

For people asking an assistant to make a map, and developers integrating a code-running or browser-driving agent. Choose the interface that the agent actually has: writing a link, importing the standalone JavaScript utilities, or controlling an open GISMap Online page.

1. Chat-only model: write a link

Look at the service's fields first by opening the layer URL with ?f=pjson appended, and pick a numeric field. Then write a map-v1 spec and put it after #map=json: in the address (URI-encode it when you can).

Worked example: U.S. county corn sales. The publisher's own style labels -1 as "Not Disclosed" (546 of 3,074 counties), so -1 is listed in exclude: those counties are drawn grey as "No data" instead of pulling the colour classes down. sources.inspect reports codes like this as sentinels.

"method": "auto" lets the app choose the class breaks from the data (corn sales are skewed, so it picks quantile classes). Not sure which style suits a field at all? Write { "type": "auto", "field": "CORN_SALES_IN_DOLLARS" } and the app chooses. Saving or sharing from the app records the chosen classes, so the map then looks the same for everyone.

{
  "version": 1,
  "basemap": "gray-vector",
  "layers": [
    {
      "url": "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/Corn/FeatureServer/0",
      "renderer": {
        "type": "choropleth",
        "field": "CORN_SALES_IN_DOLLARS",
        "method": "auto",
        "ramp": "greens",
        "exclude": [
          -1
        ]
      }
    }
  ]
}

Link: https://gismap.online/#map=json:%7B%22version%22%3A1%2C%22basemap%22%3A%22gray-vector%2…

For one layer and one field there is a shorter form with no JSON: https://gismap.online/?layer=https%3A%2F%2Fservices.arcgis.com%2FP3ePLMYs2RVChkJx%2FArc…

2. Code-running agent: inspect, validate, link

Import the pure core (a browser, Deno, or Node with a clone of the repository: import ./js/gismap-core.js), inspect the source, validate the spec, and create a link. Python can build the readable link by hand.

import { sources, mapSpec } from "https://gismap.online/js/gismap-core.js";

const url = "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/Corn/FeatureServer/0";
const meta = await sources.inspect(url); // fields, scale range, freshness, sentinels
const exclude = meta.sentinels
  .filter((code) => code.field === "CORN_SALES_IN_DOLLARS" && code.source !== "heuristic")
  .map((code) => code.value); // [-1]
const spec = { version: 1, basemap: "gray-vector", layers: [{ url, renderer: { type: "choropleth", field: "CORN_SALES_IN_DOLLARS", exclude } }] };
const { valid, issues } = mapSpec.validate(spec);
const { url: link, qr } = await mapSpec.createLink(spec); // compressed; { compress: false } gives #map=json:
import json, urllib.parse

spec = {"version": 1, "basemap": "gray-vector", "layers": [{"url": "https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/Corn/FeatureServer/0",
        "renderer": {"type": "choropleth", "field": "CORN_SALES_IN_DOLLARS", "exclude": [-1]}}]}
link = "https://gismap.online/#map=json:" + urllib.parse.quote(json.dumps(spec, separators=(",", ":")), safe="")

3. Browser-automation agent: drive the page

Wait for gisMapOnline.ready (or the gismap:ready event, or <html data-gismap-state="ready">), add layers, fit the camera, and read describe() to check the result. layers.suggestStyles ranks the styles that suit a field, each with a reason and its class breaks; apply one with its pinnedSpec.

await gisMapOnline.ready;
const layer = await gisMapOnline.layers.add("https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/Corn/FeatureServer/0", {
  renderer: { type: "choropleth", field: "CORN_SALES_IN_DOLLARS", ramp: "greens" }, // sentinels excluded by default
});
await gisMapOnline.camera.fitTo(layer.id);
const { options } = await gisMapOnline.layers.suggestStyles(layer.id, { field: "CORN_SALES_IN_DOLLARS" });
await gisMapOnline.layers.update(layer.id, { renderer: options[0].pinnedSpec }); // the recommended style
console.log(gisMapOnline.describe().state); // layers, basemap, camera, issues
const { url } = await gisMapOnline.mapSpec.createLink(gisMapOnline.mapSpec.fromCurrent());

Discover the live registry with gisMapOnline.actions.list() and actions.describe(id). Execute an action with actions.execute({ id, input, expectedRevision }); the revision is optional and only detects changes in the public state projection, not all private or camera changes. Inputs are checked against the declared schema and the existing tool validator before execution; unsupported schema keywords fail closed. Tools without input schemas remain available through the legacy application.runTool but cannot be executed through actions.execute. Outputs are not yet schema-validated; action results can contain session data, so invoke explicitly in a trusted page context. The public state snapshot remains privacy-preserving. This does not provide REST or MCP endpoints.

Verify the artifact: Michigan county health

Inspect the layer metadata and query actual values before choosing fields. The 2024 County Health Rankings layer 2 is polygon geometry; statecode is a string containing state FIPS, and v001_rawvalue is age-adjusted years of potential life lost per 100,000. On 2026-10-20, statecode = '26' returned 83 Michigan counties. Counts and service availability can change.

Source metadata: https://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS/rest/services/County%20Health%20Ran… Test each where clause using that layer's /query endpoint with f=json and returnCountOnly=true. A successful service query does not prove the GISMap Online layer loaded, rendered or reopened.

The following filters were accepted by that layer on 2026-10-20. IS NULL tests database null, not missing-value codes; inspect the publisher's metadata and sentinels before deciding which values to exclude. Do not assume other services use these names or codes.

Use mapSpec.prepareVerification(spec) in the browser or core for an offline report; not_checked means exactly that. In a browser, await mapSpec.load(spec).ready, examine issues, layer configuration and rendered features, then open the generated URL in a fresh page and verify again. Report any unavailable steps. Always provide the actual URL, not just a button label.

statecode = '26'
v001_rawvalue > 0
statecode = '26' AND v001_rawvalue > 0
statecode = '26' AND v001_rawvalue IS NULL
statecode = '26' AND v001_rawvalue IS NOT NULL

Michigan share URL (prepared; browser rendering and reopening not independently verified): https://gismap.online/#map=json:%7B%22version%22%3A1%2C%22title%22%3A%22Michigan%20coun…

Prepared: spec or URL constructed. Validated: GISMap Online's validator accepted it (review warnings). Loaded: required layers loaded in the application. Verified: intended features, filter, style and camera were confirmed, including reopening the share link. Do not imply a later stage was completed when it was not.

Refine an existing map into multiple views

Choose the simplest working interface: simple ?layer= parameters for basic filtering and a supported style; map-v1 JSON for independent layers, categorized colors, camera, opacity and legends; or the in-page API for the currently open map. Do not stop at advice when a requested change can be expressed declaratively.

For an existing #map= link use mapSpec.decode(payload), which also handles supported compressed map payloads. For a simple ?layer= URL, parseShareParameters and mapSpec.fromShareParameters reconstruct the spec. For a hosted ?spec= fetch the trusted file; for an open map use gisMapOnline.mapSpec.fromCurrent(). If compressed decoding is unavailable, ask for the original JSON or an uncompressed #map=json: link rather than guessing. Preserve filters, camera and basemap, check validation warnings, and don't replace the user's source with a different one.

The example begins with a California historical fire-perimeters filter and derives two independent maps. On 2026-10-20 the layer metadata identified polygon geometry, numeric YEAR_ and GIS_ACRES fields, and its service accepted the filter. These links are prepared and statically validated; rendered styles and share-link reopening still need a browser check.

import { mapSpec } from "https://gismap.online/js/gismap-core.js";
import { parseShareParameters } from "https://gismap.online/js/share.js";
const previous = new URL("https://gismap.online/?layer=https%3A%2F%2Fservices1.arcgis.com%2FjUJYIo9tSA7EHvfZ%2FArcGIS%2Frest%2Fservices%2FCalifornia_Historic_Fire_Perimeters%2FFeatureServer%2F0&layerType=feature&where=YEAR_%20%3E%3D%202000%20AND%20YEAR_%20%3C%3D%202010&basemap=gray-vector&center=-120%2C37.5&level=5");
const payload = new URLSearchParams(previous.hash.slice(1)).get("map");
const base = payload ? await mapSpec.decode(payload) : mapSpec.fromShareParameters(parseShareParameters(previous.search));
const colors = ["#8e0152", "#d73027", "#f46d43", "#fdae61", "#fee08b", "#66a61e", "#1b9e77", "#1f78b4", "#6a3d9a", "#a6761d", "#4d4d4d"];
const year = structuredClone(base), acres = structuredClone(base);
year.layers[0].renderer = { type: "categories", field: "YEAR_", maxCategories: 11, colors: Object.fromEntries(colors.map((c, i) => [String(2000 + i), c])) };
acres.layers[0].renderer = { type: "choropleth", field: "GIS_ACRES", classes: 5, method: "quantile", classColors: ["#ffffb2", "#fecc5c", "#fd8d3c", "#f03b20", "#bd0026"] };
for (const spec of [year, acres]) {
  const report = await mapSpec.prepareVerification(spec);
  console.log(report.url, report.checks, report.warnings, report.errors);
}

Inspect source fields and validate both renderers against them; then open each URL in GISMap Online, confirm the filter, map, legend, categories and acreage classes, and reopen it. Category and class generation can use sampled data. A generated URL alone is not verified. Numeric year-slider authoring is not defined in map-v1; treat it as an enhancement rather than claiming support.

Prepared examples and source JSON: https://gismap.online/examples/ai/california-fire-refinement/

4. Handling errors

Every error from the API is a GisMapError with a code and a hint written for agents. When a map spec opens, problems are listed in describe().state.issues instead of stopping the map.

CodeWhat to do
INVALID_URLPass a complete https:// URL to a service, layer or file.
HTTPS_REQUIREDUse the https:// form of the URL; GISMap Online only loads remote data over HTTPS.
CREDENTIAL_IN_URLRemove the token, key or password from the URL. Only public services can be shared.
UNSUPPORTED_LAYER_TYPEUse one of the layer types in map.layerTypes in capabilities.json.
TOO_MANY_LAYERSA map holds at most 10 data layers. Remove one with layers.remove before adding another.
LAYER_LOAD_FAILEDCheck the URL in a browser with ?f=pjson appended. The service may be down, private or not a layer URL.
CORS_BLOCKEDThe publisher does not allow browser access to this service. Use another source, or download the data and add it as a file.
SERVICE_ERRORThe service answered with an error. Check the URL, the layer number and any filter for typos.
FIELD_NOT_FOUNDUse a field name exactly as the service lists it; sources.inspect(url) returns the fields.
INVALID_SPECFix the listed issues; the schema in capabilities.json describes every property.
NOT_READYAwait gisMapOnline.ready before calling this.
NOT_FOUNDCall layers.list() to see the layers on the map and their ids.
PRINT_LAYERS_NOT_LOADEDOne or more layers did not load before the timeout. Check describe().state.issues, report which layers failed, and export a partial map (allowPartial: true) only if the user agrees.
PRINT_RENDER_TIMEOUTThe map did not reach an idle render in time. Increase timeoutMs or reduce the extent.
PRINT_CANVAS_TAINTEDA layer or basemap blocked pixel export (CORS). Switch basemaps or report the source.
WEBGL_UNAVAILABLEThe browser has no WebGL, so the map cannot render. In headless Chromium, launch with --use-gl=angle --use-angle=swiftshader (or --enable-unsafe-swiftshader).
UNKNOWN_TEMPLATEUse an id from print.templates().
SPEC_TOO_LONGShorten the spec (fewer layers, no raw ArcGIS renderers) or use the compressed #map= form from mapSpec.createLink, or host the JSON and link to it with ?spec=.

5. Data caveats

  • Sentinels: some services store codes such as -1 or -9999 for "not disclosed" or "no data". sources.inspect and layers.list() report them; statistics leave them out and choropleths draw them as "No data". Sample-based guesses (source: heuristic) are reported but never applied.
  • Scale ranges: a publisher can hide a layer above or below a scale (Corn hides itself zoomed in past 1:144,447). Set ignoreServiceScaleRange: true to draw it at every zoom.
  • Record limits: services return at most maxRecordCount features per request. Statistics computed from loaded features are labelled as a sample when the layer has more.
  • Freshness: sources.inspect and layers.list() give dataLastEditDate; say how current the data is when you describe it.
  • Access: services must be public, HTTPS and allow browser (CORS) access. URLs with tokens or keys are refused.

Step-by-step: create and share an ArcGIS FeatureServer map with AI.

Write a location report

Ask an agent to report on a place and it can return a link that opens the map and offers a PDF Location Intelligence Report in fixed sections. The agent writes the summary, inferences (with the layers they rest on and a confidence) and context. Your browser adds the data at the place, the sources and a full-page map that links back. Try the central Oxnard example, or read the sections and rules.

What can AI agents create with GISMap Online?

Maps, briefings, guided tours, field task packages, 3D maps, themed maps and location reports: see the agent recipes (also as JSON), each with its interface, a checked example and its limits.

When another workflow fits better

A text-only assistant cannot prove that a remote source loaded or that a map rendered. Use an agent with the required tools or verify those steps yourself. The in-page API needs a browser session; it is not a hosted authoring endpoint.

Questions before you start

Can a text-only chatbot make a map?

It can prepare a supported JSON map link using known source details. If it cannot inspect the publisher metadata or open a browser, source access and rendering remain unverified.

Which workflow should an agent start with?

Start with the recipe for the requested result: an interactive map, briefing, tour, field task or another supported artifact. Each recipe lists inputs, interfaces, verification steps and limitations. Combine recipes only when their required settings and outputs are compatible.

What should the agent return?

Return the actual link or artifact, source attribution, the checks completed and any remaining limits. Keep prepared, validated, loaded, rendered and verified results distinct. Never place private credentials in a URL.

Related workflows

Data and AI privacy. Local file import runs in your browser. Remote services and basemaps are requested from their publishers. Exporting or sharing transfers the content you choose; using a configured AI provider can send your question and relevant map context to that provider. Review the AI connection guide before using sensitive data.

Continue exploring

Use the public GIS examples catalog to open a working dataset, or return to the GISMap Online viewer to add your own source.