@nika-js/onlymap 0.11.6 → 0.11.8
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/CHANGELOG.md +13 -0
- package/README.md +2 -2
- package/dist/{basemap-jgiazq81.js → basemap-CFBn4Xl9.js} +2 -2
- package/dist/elements/om-map.d.ts +34 -2
- package/dist/elements/om-overlay.d.ts +21 -1
- package/dist/{geoparquet-BqlfpNfW.js → geoparquet-4Do2vscp.js} +1 -1
- package/dist/{globe-view-BwEj9ar9.js → globe-view-CkJR_AnY.js} +1 -1
- package/dist/{hillshade-50jNXHyP.js → hillshade-BYgQgSDu.js} +1 -1
- package/dist/{index-CCVeg1y8.js → index-BXjiBP1F.js} +3 -3
- package/dist/{index-jPifVRWa.js → index-BvNIWDg6.js} +1 -1
- package/dist/{index-mLeavkEr.js → index-COjrgKX8.js} +7365 -7309
- package/dist/{index-BBeBWH6b.js → index-D57ncSYm.js} +1 -1
- package/dist/{index-ALKRO96X.js → index-D7Xj3dSg.js} +1 -1
- package/dist/{index-BPRV9yxf.js → index-DT2RpSxM.js} +2 -2
- package/dist/{index-BVIktcJJ.js → index-DVQmGY-A.js} +3 -3
- package/dist/{index-CiSq4_Va.js → index-Du-3KfDZ.js} +1 -1
- package/dist/{index-CmfYI2km.js → index-DyXu8wbK.js} +1 -1
- package/dist/internal-ids.d.ts +7 -0
- package/dist/{lerc-B9Q9wT5l.js → lerc-CWZuxmH2.js} +1 -1
- package/dist/onlymap.standalone.js +17054 -16998
- package/dist/onlymapjs.js +1 -1
- package/dist/{post-process-effect-Dzn0f8iO.js → post-process-effect-BrfN_OHZ.js} +1 -1
- package/dist/{raster-C-WM-KNb.js → raster-BvmCiRyN.js} +3 -3
- package/dist/{raster-pipeline-qYYrkOdi.js → raster-pipeline-BpQIs6kC.js} +1 -1
- package/dist/{text-on-path-1qHOZW1K.js → text-on-path-CZgp3O8w.js} +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/{zarr-CqHkmYTv.js → zarr-0D_FIxaR.js} +2 -2
- package/docs/cartograph.md +2 -2
- package/llms.txt +2 -1
- package/onlymapjs.html-data.json +1 -1
- package/package.json +1 -1
- package/skills/onlymapjs/SKILL.md +2 -1
- package/skills/onlymapjs/references/syntax.md +5 -3
package/dist/onlymapjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bP as e, bQ as r, bR as t, as as c, C as o, bS as i, c as n, bT as d, bU as l, bV as S, bW as E, ah as g, bX as L, bY as T, bZ as _, b_ as A, b$ as p, c0 as m, c1 as I, c2 as D, L as M, g as u, c3 as b, c4 as y, c5 as f, c6 as O, c7 as P, bE as R, c8 as C, ap as N, c9 as F, aB as h, ca as B, W as v, cb as x, aA as G, cc as U, cd as W, ce as w, cf as Y, cg as k, ch as X, ci as H, cj as K, ck as V, cl as j, cm as z, cn as J, co as q, cp as Q, cq as Z, cr as $, ak as aa, cs as sa, ct as ea, cu as ra, cv as ta, cw as ca, cx as oa, cy as ia, cz as na, cA as da, cB as la, cC as Sa, cD as Ea, aq as ga, cE as La, cF as Ta, ae as _a, cG as Aa, cH as pa, cI as ma, cJ as Ia, cK as Da, cL as Ma, cM as ua, cN as ba, cO as ya, cP as fa, cQ as Oa, cR as Pa, cS as Ra, cT as Ca, cU as Na, cV as Fa, cW as ha, cX as Ba, cY as va, cZ as xa, c_ as Ga, c$ as Ua, d0 as Wa, d1 as wa, d2 as Ya, d3 as ka, d4 as Xa, d5 as Ha, d6 as Ka, aC as Va, d7 as ja, d8 as za, d9 as Ja, da as qa, db as Qa, dc as Za, dd as $a, de as as, df as ss, dg as es, dh as rs, di as ts, dj as cs, dk as os, dl as is, dm as ns, dn as ds } from "./index-
|
|
1
|
+
import { bP as e, bQ as r, bR as t, as as c, C as o, bS as i, c as n, bT as d, bU as l, bV as S, bW as E, ah as g, bX as L, bY as T, bZ as _, b_ as A, b$ as p, c0 as m, c1 as I, c2 as D, L as M, g as u, c3 as b, c4 as y, c5 as f, c6 as O, c7 as P, bE as R, c8 as C, ap as N, c9 as F, aB as h, ca as B, W as v, cb as x, aA as G, cc as U, cd as W, ce as w, cf as Y, cg as k, ch as X, ci as H, cj as K, ck as V, cl as j, cm as z, cn as J, co as q, cp as Q, cq as Z, cr as $, ak as aa, cs as sa, ct as ea, cu as ra, cv as ta, cw as ca, cx as oa, cy as ia, cz as na, cA as da, cB as la, cC as Sa, cD as Ea, aq as ga, cE as La, cF as Ta, ae as _a, cG as Aa, cH as pa, cI as ma, cJ as Ia, cK as Da, cL as Ma, cM as ua, cN as ba, cO as ya, cP as fa, cQ as Oa, cR as Pa, cS as Ra, cT as Ca, cU as Na, cV as Fa, cW as ha, cX as Ba, cY as va, cZ as xa, c_ as Ga, c$ as Ua, d0 as Wa, d1 as wa, d2 as Ya, d3 as ka, d4 as Xa, d5 as Ha, d6 as Ka, aC as Va, d7 as ja, d8 as za, d9 as Ja, da as qa, db as Qa, dc as Za, dd as $a, de as as, df as ss, dg as es, dh as rs, di as ts, dj as cs, dk as os, dl as is, dm as ns, dn as ds } from "./index-COjrgKX8.js";
|
|
2
2
|
export {
|
|
3
3
|
e as ALL_POSITION_VALUES,
|
|
4
4
|
r as AUDIT_EXEMPTIONS,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as se, t as $e, i as Ct, a as ke, s as Lt, C as It, b as Gt, F as vt, A as Et, d as Ft, R as ye, e as At, p as jt, m as Rt, f as Mt, g as We, h as Ut, r as le, j as Ot, k as xt, l as Kt, n as Dt } from "./raster-pipeline-
|
|
1
|
+
import { c as se, t as $e, i as Ct, a as ke, s as Lt, C as It, b as Gt, F as vt, A as Et, d as Ft, R as ye, e as At, p as jt, m as Rt, f as Mt, g as We, h as Ut, r as le, j as Ot, k as xt, l as Kt, n as Dt } from "./raster-pipeline-BpQIs6kC.js";
|
|
2
2
|
import { N as Nt, c as zt } from "./hillshade-apron-Bem3DWyJ.js";
|
|
3
3
|
import { r as Bt } from "./hillshade-shader-DI2uLSNU.js";
|
|
4
|
-
import { bK as _t, bL as $t } from "./index-
|
|
4
|
+
import { bK as _t, bL as $t } from "./index-COjrgKX8.js";
|
|
5
5
|
import we from "./index-CW1n5LdO.js";
|
|
6
6
|
function kt(e, t) {
|
|
7
7
|
const n = e.length / 3, r = new Uint8ClampedArray(n * 4), o = 0, i = n, a = n * 2;
|
|
@@ -1072,7 +1072,7 @@ j.set(f.Zstd, () => import("./zstd-jXobGRcq.js").then((e) => e.decode));
|
|
|
1072
1072
|
j.set(f.Jpeg, () => Promise.resolve(ce));
|
|
1073
1073
|
j.set(f.Jpeg6, () => Promise.resolve(ce));
|
|
1074
1074
|
j.set(f.Webp, () => Promise.resolve(ce));
|
|
1075
|
-
j.set(f.Lerc, () => import("./lerc-
|
|
1075
|
+
j.set(f.Lerc, () => import("./lerc-CWZuxmH2.js").then((e) => e.decode));
|
|
1076
1076
|
async function ue(e, t, n) {
|
|
1077
1077
|
const r = j.get(t);
|
|
1078
1078
|
if (!r)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { w as he } from "./mgrs-BY9bIvp4.js";
|
|
2
|
-
import { a3 as de, bD as fe, bE as re, c as oe, bF as me, G as pe, bG as ge, aK as Z, bH as ve, N as be, bI as xe, bJ as Pe, al as Te, ap as ie } from "./index-
|
|
2
|
+
import { a3 as de, bD as fe, bE as re, c as oe, bF as me, G as pe, bG as ge, aK as Z, bH as ve, N as be, bI as xe, bJ as Pe, al as Te, ap as ie } from "./index-COjrgKX8.js";
|
|
3
3
|
import { p as ye, a as Le, h as we } from "./hillshade-shader-DI2uLSNU.js";
|
|
4
4
|
function Oe(n, e, t) {
|
|
5
5
|
const { projectedCorners: s } = e, { topLeft: r, topRight: o, bottomRight: i, bottomLeft: a } = s, c = t(r[0], r[1]), u = t(o[0], o[1]), l = t(i[0], i[1]), d = t(a[0], a[1]), f = [
|
package/dist/version.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ur, d as lr, R as zt, e as fr, m as dr, p as St, f as hr, k as pr, l as mr } from "./raster-pipeline-
|
|
2
|
-
import { c as gr } from "./index-
|
|
1
|
+
import { A as ur, d as lr, R as zt, e as fr, m as dr, p as St, f as hr, k as pr, l as mr } from "./raster-pipeline-BpQIs6kC.js";
|
|
2
|
+
import { c as gr } from "./index-COjrgKX8.js";
|
|
3
3
|
import $t from "./index-CW1n5LdO.js";
|
|
4
4
|
var Et;
|
|
5
5
|
function h(e, t, n) {
|
package/docs/cartograph.md
CHANGED
|
@@ -22,8 +22,8 @@ to PDF at true page size via CSS `@page` and exports PNG/JPEG at print DPI throu
|
|
|
22
22
|
<html>
|
|
23
23
|
<head>
|
|
24
24
|
<meta charset="utf-8">
|
|
25
|
-
<script type="module" src="https://unpkg.com/@nika-js/onlymap@0.11.
|
|
26
|
-
<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.
|
|
25
|
+
<script type="module" src="https://unpkg.com/@nika-js/onlymap@0.11.8/dist/cartograph.standalone.js"></script>
|
|
26
|
+
<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.8/dist/cartograph.css">
|
|
27
27
|
</head>
|
|
28
28
|
<body>
|
|
29
29
|
<om-cartograph cartograph-id="cg-lot-12" format="cartograph/2" size="A4" theme="minimal"
|
package/llms.txt
CHANGED
|
@@ -28,6 +28,7 @@ Programmatic/native bridge rule: `MapController.setLayers()` accepts normal func
|
|
|
28
28
|
- Dashed lines are a single attribute: `dash="[6, 3]"` (or SVG-style `dash="6 3"`, plus optional `dash-justified`) on a path-stroking layer (`PathLayer`, `GeoJsonLayer`, `PolygonLayer`, `TripsLayer`). Do NOT hand-wire deck's `PathStyleExtension`/`getDashArray` — the attribute mounts it for you. Values are `[dashLength, gapLength]` in the SAME units as the line width; `dash` on a non-path layer (ScatterplotLayer, etc.) is ignored with a warning.
|
|
29
29
|
- To capture where the user CLICKS on the map (a measure tool, drop-a-pin, a custom rectangle/circle AOI, snap-to-feature), listen for the `om-map-point` event on `<om-map>`: `mapEl.addEventListener('om-map-point', e => { const { coordinate, kind } = e.detail; })` — `coordinate` is `[lng,lat]` (or `null` off-globe), `kind` is `"click"`|`"hover"`, and it fires on every click/hover including empty-map clicks. Do NOT reach for deck.gl internals (`mapEl.getMap()`, `.deckInstance`, `.deck.viewManager`) — those are not exposed on `<om-map>` and return nothing — and do not unproject canvas pixels by hand: `mapEl.unproject([x, y])` returns `[lng, lat]` (0.11.5+). The built-in `draw` widget handles polygon/line/point sketching; `om-map-point` is for tools it doesn't cover.
|
|
30
30
|
- To ask what is UNDER a pixel or INSIDE a screen rectangle from page code (a picker that tells an assistant which feature the user means, box-select, a hit-test), call `mapEl.pickAt([x, y], {radius, layers})` → one `Selection` (`{layerId, object, index, coordinate, pixel, type}`) or `null`, searching 4px around the point; and `mapEl.pickRect({x, y, width, height}, {layers, maxObjects})` → `Selection[]` front to back, default cap 100, each `coordinate` null (0.11.5+). These are queries: they change no `ctx.selection`, fire no `om-map-point`, run no behaviors. Only `pickable` layers answer — for a tool that must see every layer set the PROPERTY `mapEl.pickMode = "all"` while armed and back to `"authored"` after; never write `pickable` attributes or fire `set-pickable` for this, which edits the author's document. While `"all"`, hover, click and `pick-cursor` also see every layer. `MapController` has the same `pickAt`/`pickRect`/`unproject`/`pickMode`.
|
|
31
|
+
- A host tool that reads the rest of the map WITHOUT editing it (0.11.7+): legend rows, sub-legends and layer-switcher rows carry `data-layer="<om-layer id>"` in the widget's shadow root, so a click on a row names its layer; an `<om-overlay>`'s `templateSource` is its authored template with `{{fields}}` intact (its rendered content has them filled in); and the PROPERTY `mapEl.diagnostics = true` makes the map dispatch `om-validation-error` (`detail = {valid, errors, warnings}`, every entry with `element`, `attribute`, `message` and a `fix`) on every reconcile, with no panel — `mapEl.getDiagnostics()` returns the latest, null while off. Use it instead of writing `validate` from a tool, which edits the author's document; an authored `validate` keeps working either way.
|
|
31
32
|
- `<om-widget type="draw" modes="point line polygon" target="sketch" save="both" autosave="<key>">` is the sketch-capture toolbar — `target` binds the store a `data="draw:<target>"` layer reads. Lines/polygons complete via double-click, touch double-tap (iOS WebViews never synthesize `dblclick` from taps — the library detects the tap pair itself, so touch parity is native), Enter, or the toolbar's explicit **Finish** button; Escape cancels the in-progress shape. `export-3d` (bare = GLB, `="b3dm"` for Cesium/3D-Tiles pipelines) adds an "Export 3D" button (issue #34), separate from `save` (that's the drawn shape's own GeoJSON): outline a polygon over loaded `Tile3DLayer`/`BIMLayer` content, close it, and it clips every loaded tile's triangles to that footprint (a plain 2D clip, no elevation-picking involved), re-frames them to a local coordinate frame at the footprint's centroid, and downloads it, each triangle carrying its own source color (vertex colors) — no textures (BIM/IFC materials are flat colors, not textured meshes). Only currently-VISIBLE 3D Tiles/BIM layers are included — `visible="false"` (or `toggle-layer`) excludes a layer, with distinct console warnings for "nothing loaded" vs. "everything hidden." Validation warns on an unrecognized `export-3d` value.
|
|
32
33
|
- Clip box (issue #34): `<om-map clip-box-min="[lng,lat,elev]" clip-box-max="[lng,lat,elev]">` cuts a real axis-aligned 3D box through the whole scene — geometry outside it discarded, every layer clipped by default (`clip="off"` on an `<om-layer>` opts out), works on ANY layer type including georeferenced `Tile3DLayer`/`BIMLayer` content (not just flat `GeoJsonLayer` extrusions). `clip-box-invert` shows outside instead of inside; `clip-box-highlight` dims clipped-out geometry instead of discarding it (non-destructive preview). Attribute-backed (undoable, story-steppable) via `set-clip-box {min, max, invert?, highlight?}` (`{clear:true}` removes it) and `<om-widget type="clip-box">` (six number inputs + invert/highlight checkboxes + clear button). v1 is axis-aligned only — rotation is a documented follow-up.
|
|
33
34
|
- `<om-widget type="measure" modes="distance area volume" units="metric|imperial|nautical">` is the geodesic ruler: click to place points, live labels + a totals panel, read the value programmatically via the `om-measure` event (`detail.mode`/`.totalMeters`/`.areaMeters2`/`.perimeterMeters`/`.cutMeters3`/`.fillMeters3`/`.netMeters3`/`.totalMeters3`/`.cutAdjustedMeters3`/`.fillAdjustedMeters3`/`.cutMassKg`/`.fillMassKg`/`.stale`/`.profileSeries` — profile points are `{x: metres from the first vertex, y: elevation}` plus `vertexIndex` on the samples that ARE drawn corners, so a chart can mark them; vertex 0 is the leftmost, and with `profile` on the map badges the first two vertices `1 · Start` and `2` in draw order so the ring's winding direction is readable at constant cost, while the chart marks every corner). `volume` outlines a footprint like `area` (close it with a double-click/double-tap/Enter — it turns solid teal, "ready"), then a fixed-screen-pixel-size double-headed arrow gizmo appears at the centroid: drag up to fill, down to cut (unbounded distance), reading Cut/Fill/Net (signed, fill−cut)/Total (unsigned, cut+fill) — always RAW geometric volumes, never altered by `swell`/`shrink`. It REQUIRES `terrain` on `<om-map>` (validation warns a `volume` mode with none — cut/fill against flat ground with no elevation surface has nothing to measure against). The math is a REAL per-cell grid integration: closing a footprint bulk-loads its covering DEM tiles and integrates terrain-vs-base per cell on a metric tangent-plane grid (cell size = the DEM's GSD, scanline point-in-polygon, bilinear seam-correct sampling, worker-offloaded) — mixed cut AND fill in one footprint on undulating ground, with `cellSizeM`/`gsdM`/`cutErrorM3`/`fillErrorM3` (± = per-cell cellArea × 1.5 × GSD, per side)/`nodataFraction` published on the readout; without terrain a flat-plane fallback runs with no error figures. `base-surface` picks the reference: `custom` (default — the gizmo's target plane) or boundary-derived stockpile strategies with no gizmo (`triangulated` boundary TIN, `plane`, `lowest`, `highest`, `average`). Five more volume-only attributes (no-ops, and validation warns, without `volume` in `modes`): `base-surface` (above); `profile` (elevation samples around the footprint's own perimeter, live while sketching, dispatched on `profileSeries` for a paired `dynamic-chart`); `deadband` (m³, zeroes a Cut/Fill figure below the threshold); `density` (t/m³ metric, lb/yd³ imperial) and `swell`/`shrink` (multipliers, default 1×) populate a separate Material section instead — Bank/Loose/Compacted convention, `cutAdjustedMeters3` = raw × swell (loose/haul, bigger), `fillAdjustedMeters3` = raw ÷ shrink (loose/borrow needed, also bigger), tonnage from the raw (mass-conserving) volume — shown only once one of the three is actually configured.
|
|
@@ -42,7 +43,7 @@ Programmatic/native bridge rule: `MapController.setLayers()` accepts normal func
|
|
|
42
43
|
- Chunked N-dimensional Zarr / GeoZarr rasters (climate/weather grids, datacubes) are the library-owned `ZarrLayer` type (built on `@developmentseed/deck.gl-zarr` + zarrita, a lazy chunk): `<om-layer type="ZarrLayer" src="./x.zarr" variable="temp" select="time=0" colormap="viridis" min="…" max="…">`. `src` not `data` (chunks stream through the layer's reader, never parsed rows). Pick the `variable` and pin EVERY non-spatial dimension in `select` ("init_time=0, lead_time=0, ensemble_member=0"); the two spatial dims are handled for you (a 2-D array needs no select). A GeoZarr-compliant store georeferences itself; a plain Zarr needs manual `bounds="[w,s,e,n]"` + `crs="EPSG:4326"` + `spatial-dims="<yName> <xName>"` (bounds without crs+spatial-dims is a validation error). `min`/`max`/`colormap`/`nodata` and the auto legend reuse the exact COGLayer raster pipeline. Beware store chunking: a dataset chunked coarsely over non-spatial dims (e.g. all forecast steps in one chunk) decodes far more than the pinned frame needs. `src` may be any absolute URL (`https://…/store.zarr`) — an external/remote store works with no server setup (a static host serves Zarr's extensionless chunk keys natively), but zarrita fetches it directly from the browser so the store MUST send CORS headers (`Access-Control-Allow-Origin`), and it must be PUBLIC — authenticated stores are not yet supported (ZarrLayer uses zarrita's own fetch, not `OmMap.configureData`).
|
|
43
44
|
- `<om-widget type="legend|layer-switcher|basemap-switcher|lighting|clip-box|zoom-controls|undo-redo|scale-bar|attribution|filter|vega-lite|dynamic-chart|measure" position="bottom-end">` — static UI panels. `position` takes one of 8 managed slots (logical, RTL-aware: `top-start|top-center|top-end|center-start|center-end|bottom-start|bottom-center|bottom-end`; legacy corners `top-left` etc. alias) — same-slot widgets stack with flush edges and a shared gap (never overlap); provider attribution joins `bottom-end` and the license badge joins `bottom-start` as in-flow members, so required chrome never covers a widget; `order="1"` orders within a slot; adjacent compact button widgets (zoom-controls, undo-redo, widgets-toggle) auto-merge into ONE control group with dividers (`cluster="false"` opts a widget out); `position="manual"` renders a plain block you place with your own CSS (even outside the map). At narrow map widths managed widgets auto-fold into one accessible drawer per map side — at ≤640px when some row (top/center/bottom) has widgets on more than one of its slots, and only at ≤416px when every occupied row is one-sided (a lone legend at center-start keeps the row to itself and survives narrower maps); `fold="never"` exempts an essential widget, `widgets-fold="off"` opts the map out, `--om-widget-fold-breakpoint` changes the threshold. Layout tokens on `<om-map>`: `widget-style="gap:10 opacity:0.9 inset:16"` (keys inset/gap/inset-x/-y/gap-x/-y/opacity/radius/size, px except opacity) or the `--om-widget-inset-x/-y/-gap-x/-gap-y/-opacity/-radius/-fold-breakpoint` custom properties. Built-ins are themeable from page CSS via custom properties (they inherit through the shadow root): `om-map { --om-widget-bg: #111827; --om-widget-fg: #f9fafb; }` — full set: `--om-widget-bg/-fg/-muted/-border/-hover-bg/-accent`; scope to a single widget with an `om-widget[type=legend]` selector instead. `measure` is a geodesic ruler: `modes="distance area volume"` (default `distance area`), `units="metric|imperial|nautical"` — click the map to place points, live per-segment + total labels render on the map, and it dispatches an `om-measure` event; it reuses the draw capture stack (measure/draw mutually exclusive) and its geometry is ephemeral (never saved, not an undo step) — see the dedicated `measure`/`volume` bullet above for the full event shape and the `profile`/`density`/`swell`/`shrink`/`deadband` volume-mode attributes. `scale-bar` now takes the same `units`. `dynamic-chart` is the same Vega-Lite rendering as `vega-lite` but fed by a live DOM event instead of a layer: `on="<event-name>"` (required) + `series-field="<name>"` (default `series`) reads `event.detail[seriesField]` as `data.values` and re-embeds on every event where it's a present array, at a fixed `width`; omitting the field on a later event freezes the chart with no separate pause API — built for a feature (a drawn line's elevation profile) that computes its own series live and has no layer to bind to. No `type` + HTML + `<script type="om/widget">` = custom widget with `ctx` (`ctx.layers`, `ctx.data(id)`, `ctx.dataInViewport(id)`, `ctx.stats(id, field)`, `ctx.viewport`, `ctx.selection`, `ctx.emit(action, payload)`), `this.watch = ['data:<layerId>', 'viewport', 'selection', 'layers', 'history', 'basemap']` (`layers` also fires on visibility/filter changes; `basemap` on basemap switches; `history` on undo/redo availability), `this.$(sel)`, `vegaEmbed`/`d3` as globals.
|
|
44
45
|
- Custom-widget event emission (the #1 custom-widget bug — a widget that renders but does nothing): a widget DRIVES the map ONLY by EMITTING a registered action; it never mutates the map or dispatches its own `CustomEvent`. Two ways: (1) declarative `data-emit="<action>"` + `data-*` payload keys on an element (fires on click, or change for form controls whose `.value` is auto-added; `data-*` values are STRINGS — use `ctx.emit` for numeric/array payloads like a slider's range); (2) `ctx.emit(action, payload)` for typed payloads, wired INSIDE `render` (so `ctx` is in scope) by assigning `.oninput`/`.onclick` — e.g. a day slider: `this.render = (ctx) => { this.$("#day").oninput = e => ctx.emit("filter-layer", { layer: "quakes", field: "day", range: [+e.target.value, +e.target.value] }); }`. Actions + payloads: `filter-layer {layer, field?, range:[min,max]}`, `toggle-layer {layer, visible?}`, `fly-to {center:[lng,lat], zoom?, duration?}`, `zoom-to-feature {layer, featureId}`, `set-basemap {basemap}`, `highlight-feature {layer, featureId}`, `show-overlay`/`hide-overlay {target}`, `story-play`/`story-pause`/`story-seek {story, t?}`, `undo`/`redo`, `zoom-in`/`zoom-out`, `set-widgets-visible {visible}`; register more with `OmMap.registerAction(name, handler)`. NEVER inline `onclick=`/`oninput=` — `ctx` isn't a global and CSP blocks them, so it silently fires nothing (validation errors on it). For a plain value/time slider prefer the built-in `<om-widget type="filter" layer=… field=…>` — it wires `filter-layer` for you; hand-author only for bespoke UI.
|
|
45
|
-
- `<om-overlay id="..." anchor-from="selection">` — rich geo-anchored HTML (≤ ~20 per map). Anchors: `anchor="[lng, lat]"` (static), `anchor-from="selection"` (follows picks), or `anchor-layer="regions" anchor-feature-id="mission"` (anchored to a feature's own geometry — bbox center — no coordinates in markup; `{{field}}` interpolates that feature's attributes). Selection-anchored overlays scope with `layer="…"` (one layer's picks only) and `selection-type="click"|"hover"` (one pick type only) — a click-
|
|
46
|
+
- `<om-overlay id="..." anchor-from="selection">` — rich geo-anchored HTML (≤ ~20 per map). Anchors: `anchor="[lng, lat]"` (static), `anchor-from="selection"` (follows picks), or `anchor-layer="regions" anchor-feature-id="mission"` (anchored to a feature's own geometry — bbox center — no coordinates in markup; `{{field}}` interpolates that feature's attributes). Selection-anchored overlays scope with `layer="…"` (one layer's picks only) and `selection-type="click"|"hover"` (one pick type only) — a popup an `<om-behavior on="click" action="show-overlay">` opens behaves as `selection-type="click"` without the attribute (0.11.8+): hovers neither move, re-template nor close it, and a click elsewhere moves it or (on empty map) dismisses it. Set `selection-type="click"` anyway for pages pinned to an older version, or when the popup is opened some other way; an authored value always wins, and an overlay shown by script, `on="load"` or a hover reacts to every pick unless scoped. `{{field}}` interpolates the picked feature HTML-escaped; `{{{field}}}` is raw (avoid); `{{z}}` is the pick's ELEVATION in meters, present only when a `pickable="3d"` layer ran deck's depth pass for that pick (absent — not `0` — otherwise, so "no elevation" is distinguishable from sea level). `clip-to-map` (opt-in) hides the overlay when its own BOX would spill past the map viewport rather than only when its anchor leaves — for small transient tips that track the cursor; an overhanging absolutely-positioned box inflates the page's scrollable overflow and the scrollbar -> map resize -> reprojection loop shows as view jitter. For labels on many features use `PopupLayer`, not overlays. STYLING: overlay content renders inside a shadow root (style isolation, like widgets) — page stylesheets/classes do NOT reach it; use inline `style="…"` on the content or a `<style>` element INSIDE the overlay (children move into the shadow root wholesale, so it applies there); inheritable props + CSS custom properties pierce. A card with an image or link (`<img src="{{photo}}">`) goes inside a `<template>` child (`<om-overlay …><template>…</template></om-overlay>`, 0.11.1): inert at parse, so the literal `{{photo}}` is never requested; tokens stay blank until a pick fills them.
|
|
46
47
|
- `<om-behavior on="click|hover|drag|load|data-loaded" layer="..." action="...">` — declarative interaction (`pick="point"|"cluster"` narrows it to standalone points or count bubbles on a `cluster="true"` layer). Built-in actions: `show-overlay`, `hide-overlay`, `show-tooltip`, `hide-tooltip`, `toggle-layer`, `set-layer-attribute` (`{layer, name, value}` — write ANY layer attribute at runtime by its kebab-case name, `value: null` removes; the generic on/off switch for a widget button, e.g. `name: "cluster"`), `expand-cluster` (`{feature, layer}` or `{layer, clusterId}` — fly to where a bubble splits), `set-pickable` (`{layer, pickable: true|false|"3d"}` — runtime picking/popup toggle, story-capturable; the per-layer popup on/off switch a viewer-facing export needs), `filter-layer`, `highlight-feature`, `zoom-to-feature`, `set-basemap`, `undo`, `redo`; scene/tool actions `set-lighting`, `set-effect` (`{preset}` — swap a post-process finish; see the effects bullet), `set-terrain`, `set-clip-box` (`{min,max,invert?,highlight?}` / `{clear:true}`), `clip-box-edit` (`{editing}`), `export-region-3d` (`{target?, format?:"glb"|"b3dm"}` — what the draw widget's `export-3d` button emits), the draw actions `draw-mode` (`{target?:"sketch", mode:"point"|"line"|"polygon"|null}` — null exits drawing), `draw-commit`, `draw-cancel`, `draw-delete` (removes the last shape), `draw-clear`, `draw-config` (`{target?, autosave?, fillColor?, lineColor?}`) and `draw-save` (`{target?, format?:"download"|"file-system"|"both"}`) — every one of these drives the same store a `data="draw:<target>"` layer reads, so a custom toolbar can replace `<om-widget type="draw">` entirely; and the measure actions `measure-mode` (`{mode:"distance"|"area"|"volume"|null}`), `measure-units`, `measure-clear`, `measure-config` (`{profile?, baseSurface?, density?, swell?, shrink?, deadband?}`), `measure-flat-target-plane` (`{flat}`). One payload contract everywhere: `{ layer, target, feature, featureId, coordinate }`. A `show-tooltip` popup DISMISSES ITSELF when the selection clears — the pointer leaving the feature for a hover, or a click on empty map for a click — so you never wire `hide-tooltip` by hand for that. A tooltip whose template contains an interactive `[data-emit]` element takes pointer events and so does NOT close when clicked, which is what lets it carry its own close button.
|
|
47
48
|
- Undo/redo is built in: user-facing manifest changes (layer toggles, filter changes, basemap switches, element add/remove, drawn sketches) are recorded automatically — the manifest is the state. `<om-widget type="undo-redo">` renders the buttons; Cmd/Ctrl-Z, Shift-Cmd/Ctrl-Z, and Ctrl-Y work on any map (text inputs keep their native undo). Camera moves, hover effects, and story playback are deliberately NOT undo steps. Widget scripts: `ctx.history.canUndo/canRedo` with watch token `history`; `ctx.emit("undo")`/`ctx.emit("redo")`.
|
|
48
49
|
- `<om-fallback>` — static no-JS fallback, direct child of `<om-map>` (one per map, no attributes, plain HTML content — links allowed). Shown ONLY where scripts never run (chat-app/email file previews — iOS QuickLook renders HTML attachments with JS off — file managers, sandboxed webviews); hidden automatically once the map boots. GOOD PRACTICE: include one on every complete page, especially pages that may be shared as a file. To PRODUCE a shareable single file, `npx @nika-js/onlymap export map.html` embeds every relative data/src/scenegraph URL as a data: URL (format detection preserved — the original extension rides a #name.ext fragment), pins relative library refs to the CDN, adds a generic om-fallback when missing, and warns when embedded data is heavy (>1 MB per file / >5 MB total) or when a source cannot be embedded (shapefile sidecars, COG Range streams, Zarr directories, {z}/{x}/{y} templates — those need hosting) ("This interactive map requires JavaScript — open this file in a web browser", plus a hosted-version link when one exists). Without one, the stylesheet shows a generic text-only banner. The gate is pure CSS (`om-map:not(:defined)` in onlymapjs.css) refined by the `scripting` media feature on 2023+ engines: with scripting DISABLED the fallback shows instantly; with scripting ENABLED it never flashes during a slow load and only surfaces after a ~4s grace with load-failure wording (blocked/unreachable bundle). The CSS must load without JS — a real `<link rel="stylesheet">` or inlined `<style>` on no-build pages; a bundler-emitted stylesheet is fine in npm projects.
|
package/onlymapjs.html-data.json
CHANGED
|
@@ -2238,7 +2238,7 @@
|
|
|
2238
2238
|
},
|
|
2239
2239
|
{
|
|
2240
2240
|
"name": "selection-type",
|
|
2241
|
-
"description": "Scope selection-anchored overlays to one pick type — \"click\" keeps a click-opened popup from following hover picks; \"hover\" is the mirror. Absent: every pick
|
|
2241
|
+
"description": "Scope selection-anchored overlays to one pick type — \"click\" keeps a click-opened popup from following hover picks; \"hover\" is the mirror. Absent: a popup a click behavior opened behaves as \"click\" (0.11.8+); any other overlay reacts to every pick.",
|
|
2242
2242
|
"values": [
|
|
2243
2243
|
{
|
|
2244
2244
|
"name": "click"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nika-js/onlymap",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.8",
|
|
4
4
|
"description": "Declarative deck.gl maps for HTML and React — interactive WebGL mapping with GeoJSON/CSV/Arrow data, MapLibre basemaps, widgets, popups, and live streams from a custom-element manifest or typed React components. TypeScript, no build step.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"publishConfig": {
|
|
@@ -23,7 +23,7 @@ Use OnlyMapJS as a declarative HTML map library. Write custom elements such as `
|
|
|
23
23
|
</script>
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
For no-build CDN pages, use the single-file standalone bundle from a raw-file CDN — `https://unpkg.com/@nika-js/onlymap@0.11.
|
|
26
|
+
For no-build CDN pages, use the single-file standalone bundle from a raw-file CDN — `https://unpkg.com/@nika-js/onlymap@0.11.8` (the bare package URL serves `dist/onlymap.standalone.js`) — plus `<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.8/dist/onlymapjs.css">`. Never a rebundling CDN (esm.sh, skypack): re-bundling duplicates the deck.gl/luma.gl runtime and every layer fails shader compilation.
|
|
27
27
|
|
|
28
28
|
## React Projects
|
|
29
29
|
|
|
@@ -106,6 +106,7 @@ Load the smallest reference needed for the task:
|
|
|
106
106
|
- Small transient overlay that tracks the cursor near a map edge (a snap tip, a live readout badge) -> add `clip-to-map` to the `<om-overlay>`: it hides when the overlay's own BOX would spill past the map viewport, not just when its anchor leaves. Without it an overhanging absolutely-positioned box inflates the page's scrollable overflow and the scrollbar -> map resize -> reprojection loop shows as view jitter. Opt-in on purpose — an authored popup near an edge normally wants to keep showing its visible half.
|
|
107
107
|
- Capture raw map clicks/hovers yourself (measure distance, drop a pin where the user clicks, a custom rectangle/circle AOI, snap-to-feature) -> listen for the **`om-map-point`** DOM event on `<om-map>`: `mapEl.addEventListener('om-map-point', e => { const { coordinate, kind } = e.detail; /* [lng,lat] or null; kind is "click"|"hover" */ })`. It fires on EVERY click/hover including empty-map clicks. NEVER read deck.gl internals (`getMap()`, `deckInstance`, `deck.viewManager`) — those are not on `<om-map>` and will silently return nothing — or unproject canvas pixels by hand: `mapEl.unproject([x, y])` does it (0.11.5+). The built-in `draw` widget covers polygon/line/point sketching; `om-map-point` is for tools it doesn't. (`MapController` twin: the `onMapPoint` option. See patterns.md.)
|
|
108
108
|
- Ask what is UNDER a pixel or INSIDE a screen rectangle from your own code (a picker that tells an assistant which feature the user means, a box-select, a hit-test before a custom popup) -> `mapEl.pickAt([x, y])` (one `Selection` or null, 4px search radius; `{radius, layers}`) and `mapEl.pickRect({x, y, width, height})` (front to back, `{layers, maxObjects}` default 100, each `coordinate` null), 0.11.5+. They are QUERIES: no `ctx.selection` change, no `om-map-point`, no behaviors. Layers answer only when `pickable` — for a tool that must see every layer, set the PROPERTY `mapEl.pickMode = "all"` while it is armed and `"authored"` after; never `set-pickable` or a `pickable` attribute write, which edits the author's document. `pickMode="all"` makes hover/click and `pick-cursor` see every layer too. Same four on `MapController`.
|
|
109
|
+
- A host tool that must read the map's own problems, or which layer a legend row or popup is about, without editing the document -> the PROPERTY `mapEl.diagnostics = true` (fires `om-validation-error` with `{valid, errors, warnings}` on every reconcile, no panel; `mapEl.getDiagnostics()` for the latest), `data-layer` on legend/sub-legend/layer-switcher rows, and an overlay's `templateSource` (its `{{fields}}` before filling), 0.11.7+. Never write `validate` from a tool — that edits the author's document.
|
|
109
110
|
- Page may travel as a file (shared, emailed, downloaded) or be embedded -> add an `<om-fallback>` child to `<om-map>`. Chat-app and email previews render HTML with JavaScript disabled (iOS QuickLook), so the map cannot boot there; the fallback is what recipients see instead. It is hidden automatically once the map boots. Good practice on every complete page — without one, the stylesheet shows a generic text-only banner.
|
|
110
111
|
|
|
111
112
|
## Output Expectations
|
|
@@ -16,8 +16,8 @@ Vite/npm project:
|
|
|
16
16
|
Static CDN page (raw-file CDNs only — unpkg/jsDelivr; never esm.sh or another rebundling CDN, which duplicates the WebGL runtime and breaks layer shaders):
|
|
17
17
|
|
|
18
18
|
```html
|
|
19
|
-
<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.
|
|
20
|
-
<script type="module" src="https://unpkg.com/@nika-js/onlymap@0.11.
|
|
19
|
+
<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.8/dist/onlymapjs.css">
|
|
20
|
+
<script type="module" src="https://unpkg.com/@nika-js/onlymap@0.11.8"></script>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Always include `onlymapjs.css` — it carries the MapLibre basemap styles and the no-JS fallback rules (`<om-fallback>` / default banner). For the fallback to work in script-disabled previews it must load without JavaScript: a real `<link rel="stylesheet">` or inlined `<style>` on no-build pages (a bundler-emitted stylesheet is fine in npm projects).
|
|
@@ -92,6 +92,8 @@ Events: `om-map-ready` (boot complete; `await mapEl.ready` is the promise twin),
|
|
|
92
92
|
|
|
93
93
|
Programmatic picking (0.11.5+, also on `MapController`): `mapEl.pickAt([x, y], { radius?, layers? })` returns the `Selection` under a screen pixel (CSS px from the map's top-left; 4px search radius by default) or `null`; `mapEl.pickRect({ x, y, width, height }, { layers?, maxObjects? })` returns every `Selection` inside a rectangle, front to back, at most 100 by default, each with `coordinate: null` (deck reports no per-object position for a rectangle; raster layers are not sampled); `mapEl.unproject([x, y])` and `mapEl.project([lng, lat])` convert between pixels and `[lng, lat]`. All are queries — they leave `ctx.selection`, `om-map-point` and `<om-behavior>`s alone. They see only `pickable` layers unless the `pickMode` PROPERTY is `"all"`, which makes every layer pickable for every pick path (hover, click and `pick-cursor` included) until set back to `"authored"`. It is a property, not an attribute: it never reaches the document, undo history, or a save — arm it for a picker tool instead of writing `pickable`.
|
|
94
94
|
|
|
95
|
+
Reading the map without editing it (0.11.7+), for host tools such as an assistant's picker: `mapEl.diagnostics = true` (a PROPERTY) makes the map dispatch `om-validation-error` with `{ valid, errors, warnings }` after every reconcile — the same entries `validate` shows, each with a `fix` — but draws no panel and writes nothing; `mapEl.getDiagnostics()` returns the latest result (`null` while off and no `validate` is authored). Legend rows, sub-legends and layer-switcher rows carry `data-layer="<layer id>"` in the widget's shadow root. An `<om-overlay>`'s `templateSource` returns its authored template with `{{fields}}` intact; its rendered content has them filled in.
|
|
96
|
+
|
|
95
97
|
Example:
|
|
96
98
|
|
|
97
99
|
```html
|
|
@@ -678,7 +680,7 @@ Anchors:
|
|
|
678
680
|
Selection scoping (both only apply with `anchor-from="selection"`):
|
|
679
681
|
|
|
680
682
|
- `layer="quakes"` — only that layer's picks move/re-template the overlay.
|
|
681
|
-
- `selection-type="click"` (or `"hover"`) — only that pick type does. A click-
|
|
683
|
+
- `selection-type="click"` (or `"hover"`) — only that pick type does. A popup a click behavior opens (`<om-behavior on="click" action="show-overlay">`) behaves as `selection-type="click"` even without the attribute (0.11.8+): hover is inert — it neither drags the popup, re-interpolates its template against the hovered object, nor closes it when the pointer leaves — and a click on empty space still dismisses. Before 0.11.8 the attribute was REQUIRED for that; keep writing it for pages pinned to older versions, and for a popup opened by script or `on="load"`, which otherwise reacts to every pick. An authored value always wins. `"hover"` is the mirror for hover-driven overlays.
|
|
682
684
|
|
|
683
685
|
Viewport clipping:
|
|
684
686
|
|