A two-layer briefing with spatial queries, built by an agent
U.S. states are the briefing's main layer; Major League ballparks are a second layer. On each state slide the ballparks layer is limited to the ballparks the state contains, answered by the ballparks service itself. The agent checked those answers before writing the slides, and found two places where geography needed care.
What it shows off
- Other layers on each slide: the ballparks are shown with the states and limited per slide
- Spatial relationships as the ArcGIS REST API defines them (contains), with a distance where needed
- "method": "auto": the states' population density classes are chosen from the data
- "transition": "cut": slides jump between states instead of flying across the country
- A whole map and briefing in one map-v1 spec, opened from one link or QR code
Ask a chatbot
The same request to a chatbot that can run code:
Make a GISMap Online (https://gismap.online) briefing of Major League ballparks by state. Main layer: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_States_Generalized_Boundaries/FeatureServer/0 (shade POP_SQMI as a choropleth with method "auto"). Second layer: https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/Major_League_Baseball_Stadiums/FeatureServer/0 (colour by LEAGUE). Add a title slide, one feature slide for each state with two or more teams, and a closing "how this was built" slide. On each state slide show only the ballparks the state contains (slide layers with relation type "contains"); use transition "cut". Before writing the slides, query the ballparks service with each state's geometry and compare the result with each ballpark's STATE field; fix any mismatch and say how. Put it all in one map-v1 spec (https://gismap.online/schemas/map-v1.schema.json) and return the link and a QR code.
For an AI agent: check the relationship, then write the spec
The agent asked the ballparks service the same question each slide will ask, before relying on it. Ohio's generalized outline leaves Cincinnati's ballpark (on the Ohio River, the state line) in Kentucky, so the Ohio slide grows Ohio by 1 mile; growing Illinois the same way would wrongly pick up St. Louis's Busch Stadium across the Mississippi, so only Ohio is grown.
import { mapSpec } from "https://gismap.online/js/gismap-core.js";
const STATES = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_States_Generalized_Boundaries/FeatureServer/0";
const PARKS = "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/Major_League_Baseball_Stadiums/FeatureServer/0";
// The same query a slide runs: which ballparks does this state contain?
async function ballparksIn(stateId, miles = 0) {
const state = await (await fetch(`${STATES}/query?objectIds=${stateId}&returnGeometry=true&f=json`)).json();
const body = new URLSearchParams({
geometry: JSON.stringify(state.features[0].geometry), geometryType: "esriGeometryPolygon",
inSR: JSON.stringify(state.spatialReference), spatialRel: "esriSpatialRelContains",
outFields: "NAME,STATE", returnGeometry: "false", f: "json",
...(miles ? { distance: String(miles), units: "esriSRUnit_StatuteMile" } : {}),
});
const result = await (await fetch(`${PARKS}/query`, { method: "POST", body })).json();
return result.features.map((feature) => feature.attributes.NAME);
}
await ballparksIn(36); // Ohio: ["Progressive Field"], Cincinnati's park is missing
await ballparksIn(36, 1); // Ohio grown by 1 mile: both Ohio ballparks
await ballparksIn(14, 1); // Illinois grown by 1 mile: also Busch Stadium (Missouri), so don't
// Two layers, and slides that limit the ballparks per state (see map.json).
const spec = await (await fetch("https://gismap.online/examples/ai/mlb-ballparks-by-state/map.json")).json();
const { valid, issues } = mapSpec.validate(spec);
const { url, qr } = await mapSpec.createLink(spec); // compressed #map= link; qr: true when it fits a QR codeEach state slide's layer setting is one line of the spec:
{
"layers": [
{
"layer": "https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/Major_League_Baseball_Stadiums/FeatureServer/0",
"visible": true,
"relation": {
"type": "contains",
"distance": 1,
"units": "miles"
}
}
]
}
The result

Open the Major League ballparks by state in GISMap Online. The map configuration is in the link (2,304 characters); the referenced public data and basemap still load from their publishers. No GISMap Online account or separate hosting project is required.
Map spec with the briefing (JSON)
Show the full link
https://gismap.online/#map=z5Zltb9s2EID_CsF96BYojmVbtqN9coKuS5c0Xp0MGIYgOFEniwtFaiRl1wv8u_Z9v2wg5Re5axMv6AuGAI2jVEf5Xp67I0_3dIbacCVpHAbUciuQxvQCfleanCNMKyQJCFGCvjMkWRBjwSINaAIGCyhpTKcaFoczZFZpGlAGBWqg8T3NuKUxFbBAbegyWF_Fv93TSgsa09za0sRHRwb1jDM0LdBsyk2LqeJo3MXx-cWvpvP2l9P87vW7o_rekUZjNwuOriej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6HvTDcH6RE2ZxwSdZak1NuFw9RtBF8EkbdKEtYxtrPF6MSpTQLMYM9dknjXdkdnI6_CE7tYdbLOu29cRrnXECKoszdbkemZMyt9ZUpfwiqpqFPAwu6w0HU7z9jsFTO1WNAXdYyOyD1vwRI7TCDQTjM9gbpVOAMhSPI_ZxyybiUYHmrcf3CECdNDLfu2OPRchaSt3yGut6p1-cjwSUGxChic25Wp6WpdqclL-8PViEpuMCDA5JgpjQSMHfu0DjPOcubxNoNfw38Oqzb6afA_p_4BTTlxoJk6OcLleTWweb88WnYLLgxqtL8MT4vtnJNRjtfhNFOGqa9HuvvzehPIA0Y3zE3W7FzVXHzUKlbm_i0Mnc8jAb9QdT9f3L2KVDiQnCp-KPHwbOt3M5-_oucCLv97rAT9fcvd-tt2GnOGUzVQwCtDXviMKEdpsdJFj1fgHI132UH_CzTNNj5Uc3rTrEZHc7BkKRyE7_PMC0U3LjncouFR-0CuKwnmDFpDOpb5NLmqNd3dubVARG84BZT1wfx_cGgG3iSNSN_VKgXxKr36No2y2Z7u8qRTLdzYaIq63qpIWVldzvx-knBhzrx75Wxa35_QmkrdrdY9eOV4Id6ct2RSca1sU6ZV1rNXTA2GeB1hgLJHBZkriqRkrISwiXSpha_MOSkMiwnKwIJMK1MvdbVYvevLLnXxo9O_bdz43WR7mvfqilqQ05RWo3k2yullbSKnIgKyWtYmO-ctMtdkJCCf5BUHxjMcm_ExM-_CassSdDOEeUqvESDD6_NQZJMLJylDV2ZqqTVi1azYTHMcBilzSojuPRvL-rfdWYn6N4wXE9GZDWFbkz6yXbST4Ov-L7KmbDWdGfav64g6_h9SjX_Y6laNgY2YcIgxXq_t1uQnjRDvwmo1eBeAPjKR1nlKoJLVf8u6X65XP4DCheck before you share
- Rogers Centre (Toronto Blue Jays) is in Canada, so no state slide shows it.
- Public data has small errors (this source spells Chase Field's city "Phoeniz"); check a field before quoting it on a slide.
- State outlines are generalized; spatial answers near rivers and coasts are worth checking, as above.
- Ballpark data last edited May 30, 2025.