<!-- GENERATED by scripts/build-llms.mjs from llms/viewers.md — do not edit this file. -->

# `lr-geojson-view`

- **Import** `import '@aceshooting/lyra-ui/components/lr-geojson-view.js';` (stable tag alias; registers the tag)
- **Class** `LyraGeojsonView`, also available unregistered from `@aceshooting/lyra-ui/components/viewers/geojson-view/geojson-view.class.js`
- **Family** `components/viewers/` — see `llms/index.md` for its siblings
- **Status** `stable` since `4.0.0` — see the maturity and deprecation policy in `llms/shared.md`
- **Release history** [CHANGELOG.md](../../CHANGELOG.md)
- **Deprecations** none
- **Optional peers** `maplibre-gl` — see `llms/peers.md`
- **Themeable via** 7 parts, 0 custom properties — see this component's own `@csspart`/`@cssprop` list below
- **Documented with** `lr-geojson-viewer` (same section below)
- **Library-wide behavior** (events, form association, `locale`/`strings`, tokens, TS types): `llms/shared.md`

---

## `lr-geojson-viewer` / `lr-geojson-view`

Document-registry bridge that fetches, validates, and renders a GeoJSON file through `<lr-map>`'s
`dataLayers`. The canonical class is `LyraGeoJsonViewer`; the pre-v9 `lr-geojson-view` tag and
`LyraGeojsonView` class name remain compatibility aliases. The document registry renders the
canonical tag and matches `application/geo+json` and `.geojson` filenames.

Validates the parsed JSON is a `Feature`/`FeatureCollection`/bare geometry (one of `Point`,
`LineString`, `Polygon`, `MultiPoint`, `MultiLineString`, `MultiPolygon`, `GeometryCollection`) before
rendering; anything else renders the localized `geojsonViewInvalid` error. On success, it walks every
value and object key first, rejecting more than 50,000 graph units, nesting beyond 64 levels, more
than 2 Mi UTF-16 units of aggregate keys/string values, or more than 4 Mi UTF-16 units of formatted
metadata before serialization or peer handoff. It then walks every coordinate under a separate
10,000-position ceiling to compute a bounding box and fits a `center`/`zoom` to it (a Web-Mercator-fit
approximation weighting latitude span ~2x, with 40% padding), then hands the parsed value to
`<lr-map>` as a single `dataLayers` entry (`sourceId: 'lr-geojson'`). When the optional
`maplibre-gl` peer isn't installed, it falls back to a status line plus a `<lr-json-viewer
collapsed-depth="2">` of the raw value instead of the map.

The root owns the named `region` landmark while loading, in fallback/error/idle states, and while a
lazy map initializes. After `lr-map-load`, landmark ownership transfers to the map canvas so there
is exactly one named region. Serialized metadata is locally inline-scrollable, preventing long
unbroken values from widening a 320px allocation.

**Properties:** `src: string = ''` — URL to fetch and parse. `name: string = ''` — accessible label,
used as `<lr-map>`'s `label` and the root's `aria-label` (falling back to the localized
`geojsonViewLabel` when unset). A host `aria-label` takes precedence over `name`. The shared
text-viewer contract adds `highlights`, `activeHighlightId`, `anchor`, and
`anchorKinds` (`['text-quote', 'fragment']`), plus `search()`, `searchNext()`, `searchPrevious()`,
`clearSearch()`, and `scrollToAnchor()` for the ordinary-DOM serialized feature metadata and status
text, independent of whether the optional map peer is available. Fragment resolution is an exact
DOM `id` lookup, but the generated metadata, status, and map output define no fragment ids, so a
fragment jump reports `found: false`. Use a text-quote anchor for serialized metadata.

**Events:**

- `lr-render-error` — `detail: { error }` — fetch, parse, shape-validation, or missing-map capability
  failure. A missing optional MapLibre peer also keeps the serialized metadata fallback visible.
- `lr-search-change` — `detail: { query: string; matchCount: number; matchCountExact: boolean; activeIndex: number }` — fired
  whenever serialized-metadata search state changes.
- `lr-anchor-result` — `detail: { found: boolean }` — fired after an `anchor` assignment or
  `scrollToAnchor()` call is applied.
- `lr-text-select` — `detail: TextSelectDetail` (`{ text: string; anchor: LyraAnchor | null; rects:
DOMRect[] }`) — fired after a selection ends inside the serialized metadata.

`lr-highlight-activate` is not part of this registry bridge's event contract: serialized-metadata
highlights are passive and cannot be activated.

The three shared text-viewer events bubble and compose and are non-cancelable.

**CSS parts:** `base` (the root container with explicit `aria-busy="true"|"false"`), `status` (the
ordinary feature-count line, shown only in the `<lr-map>` path; a successful transition uses the
shared document-level polite sink), `metadata` (selectable/searchable serialized GeoJSON `<pre>`,
rendered in both map and fallback paths), `missing-library` (the missing-`maplibre-gl` callout shown
alongside the `lr-json-viewer` fallback; its transition uses the shared document-level assertive
sink), `error` (ordinary visible error text; later transitions use the same assertive sink),
`spinner` (a decorative skeleton plus an ordinary visually-hidden localized label; later loading
transitions use the shared document-level polite sink), and `anchor-live-region` (an aria-hidden,
non-live shadow mirror of the latest anchor-jump message; the spoken copy is appended to the shared
document-level polite sink only while the viewer and its composed ancestors are exposed to the
accessibility tree). No active live semantics are rendered in the viewer's shadow tree.

Those states carry the same visual tones the rest of this family uses rather than plain inherited
body text: `error` is `--lr-color-danger` (matching `lr-docx-viewer`/`lr-email-viewer`/
`lr-html-viewer`), `missing-library` is `--lr-color-warning` -- a missing optional peer is a degraded
but working state, since the `lr-json-viewer` fallback below it still renders the data, not a failure
-- and `status` is the quiet `--lr-color-text-quiet` metadata tone.

The canonical tag is registered by importing `geojson-viewer/geojson-viewer.js`; the permanent
compatibility tag and old deep route remain available through `geojson-view/geojson-view.js`.
Remote
resources are capped at 25 MB; exceeding it surfaces the localized `documentPreviewResourceTooLarge`
message instead of the map. Lyra supports MapLibre v5 and v6; consumers must import its CSS.
MapLibre v5's standard build includes its worker, while v6 is ESM-only, requires WebGL2, and needs
its module-worker URL configured for the bundler before this viewer constructs the nested map. See
`llms/components/lr-map.md` for the Vite v6 example and the other bundler variants.
