@nika-js/onlymap 0.11.4 → 0.11.5
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 +11 -0
- package/README.md +2 -2
- package/dist/{basemap-UE11uf6w.js → basemap-CnjAGLZo.js} +14 -2
- package/dist/basemap.d.ts +9 -0
- package/dist/elements/om-map.d.ts +31 -1
- package/dist/elements/om-overlay.d.ts +0 -14
- package/dist/{geoparquet-D7ZKVPDh.js → geoparquet-CHtunmD2.js} +1 -1
- package/dist/{globe-view-B7Yn2BbK.js → globe-view-CgQa-07O.js} +1 -1
- package/dist/{hillshade-tQaqlPhn.js → hillshade-BgXgVdjg.js} +1 -1
- package/dist/{index-DzxpYTfi.js → index-BTTCf4nb.js} +5488 -5305
- package/dist/{index-DIoKYXlh.js → index-BTsRqhXB.js} +1 -1
- package/dist/{index-DPV7mwIc.js → index-ClLMdW3k.js} +2 -2
- package/dist/{index-C09RUa1s.js → index-D4x57ql0.js} +1 -1
- package/dist/{index-N5acD4ii.js → index-DjtM8ecq.js} +1 -1
- package/dist/{index-CWtaL88w.js → index-DoNtp5Nh.js} +3 -3
- package/dist/{index-CFWt9qS0.js → index-NCXX8bDe.js} +1 -1
- package/dist/{index-B_L_7lV0.js → index-aOe9cOFs.js} +1 -1
- package/dist/{index-C8a3EKM8.js → index-k7l7kqTk.js} +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/{lerc-BDcZeX07.js → lerc-BtdiMDO7.js} +1 -1
- package/dist/onlymap.standalone.js +13650 -13455
- package/dist/onlymapjs.js +1 -1
- package/dist/{post-process-effect-C1iDE90L.js → post-process-effect-BWrq5IR8.js} +1 -1
- package/dist/programmatic.d.ts +10 -1
- package/dist/{raster-D4nwLneR.js → raster-iGwPuAgo.js} +3 -3
- package/dist/{raster-pipeline-DX-rZjRG.js → raster-pipeline-Dxs9TpD6.js} +1 -1
- package/dist/react.js +128 -125
- package/dist/runtime-core.d.ts +50 -1
- package/dist/selection.d.ts +31 -0
- package/dist/{text-on-path-onhHN4AZ.js → text-on-path-C8h_3Snf.js} +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/viewport-cull.d.ts +15 -0
- package/dist/{zarr-CBGaInwF.js → zarr-C1zXD9VD.js} +2 -2
- package/docs/cartograph.md +2 -2
- package/llms.txt +2 -1
- package/package.json +1 -1
- package/skills/onlymapjs/SKILL.md +3 -2
- package/skills/onlymapjs/references/syntax.md +4 -2
package/dist/selection.d.ts
CHANGED
|
@@ -53,6 +53,37 @@ export interface Selection {
|
|
|
53
53
|
featureKey?: string;
|
|
54
54
|
rawMetadata?: Tile3DPickMetadata["rawMetadata"];
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Programmatic picking (docs/design/pick-api.md). `"authored"` picks only the
|
|
58
|
+
* layers the author made `pickable`; `"all"` makes every layer pickable for as
|
|
59
|
+
* long as it is set — every pick path, hover and click included, not only the
|
|
60
|
+
* query methods. A property, never an attribute: a picker tool arms it and
|
|
61
|
+
* restores it, and it never reaches the manifest, undo history, or a save.
|
|
62
|
+
*/
|
|
63
|
+
export type PickMode = "authored" | "all";
|
|
64
|
+
/** `pickAt` searches this many CSS pixels around the point unless told otherwise — deck's own default of 0 misses a 2px point under a finger or a mouse. */
|
|
65
|
+
export declare const PICK_AT_DEFAULT_RADIUS = 4;
|
|
66
|
+
/** `pickRect` returns at most this many objects unless told otherwise. */
|
|
67
|
+
export declare const PICK_RECT_DEFAULT_MAX = 100;
|
|
68
|
+
export interface PickAtOptions {
|
|
69
|
+
/** CSS pixels around the point to search. Default {@link PICK_AT_DEFAULT_RADIUS}. */
|
|
70
|
+
radius?: number;
|
|
71
|
+
/** Restrict to these authored `<om-layer id>`s. Default: every layer. */
|
|
72
|
+
layers?: readonly string[];
|
|
73
|
+
}
|
|
74
|
+
export interface PickRectOptions {
|
|
75
|
+
/** Restrict to these authored `<om-layer id>`s. Default: every layer. */
|
|
76
|
+
layers?: readonly string[];
|
|
77
|
+
/** Upper bound on returned objects. Default {@link PICK_RECT_DEFAULT_MAX}. */
|
|
78
|
+
maxObjects?: number;
|
|
79
|
+
}
|
|
80
|
+
/** A screen rectangle in CSS pixels relative to the map's top-left corner. */
|
|
81
|
+
export interface PickRect {
|
|
82
|
+
x: number;
|
|
83
|
+
y: number;
|
|
84
|
+
width: number;
|
|
85
|
+
height: number;
|
|
86
|
+
}
|
|
56
87
|
interface PickingInfoLike {
|
|
57
88
|
layer?: {
|
|
58
89
|
id: string;
|
package/dist/version.d.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a projected anchor sits behind the camera, from the depth
|
|
3
|
+
* `viewport.project` returns as its third component.
|
|
4
|
+
*
|
|
5
|
+
* Only a perspective (geographic) camera has a "behind". A projected map
|
|
6
|
+
* (`crs=`) renders through an orthographic viewport, whose depth for every
|
|
7
|
+
* ground point is about -1 — read as "behind the camera", that hid every
|
|
8
|
+
* `<om-overlay>` on every projected map, popups included (reproduced on an
|
|
9
|
+
* EPSG:5070 cartograph frame, e2e/plane-pick.spec.ts). deck marks the
|
|
10
|
+
* orthographic viewport `isGeospatial: false`; the basemap adapter's viewport
|
|
11
|
+
* returns no depth at all.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isBehindCamera(viewport: {
|
|
14
|
+
isGeospatial?: boolean;
|
|
15
|
+
}, depth: number | undefined): boolean;
|
|
@@ -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-Dxs9TpD6.js";
|
|
2
|
+
import { c as gr } from "./index-BTTCf4nb.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.5/dist/cartograph.standalone.js"></script>
|
|
26
|
+
<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.5/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
|
@@ -26,7 +26,8 @@ Programmatic/native bridge rule: `MapController.setLayers()` accepts normal func
|
|
|
26
26
|
- `id` is required on every `<om-layer>`. `label` and `color` feed the legend; an explicit `get-fill-color` overrides `color` for rendering (both together is valid and common). The legend widget also reads `get-fill-color` itself: a `sequential`/`diverging` scale renders as a gradient ramp with domain labels, a `threshold` scale as discrete class ranges, and an equality ternary chain (`$f == 'a' ? '#c1' : '#c2'`) as a category palette — write those canonical shapes and the legend describes the symbology automatically.
|
|
27
27
|
- Full JavaScript in accessor blocks needs the `js` attribute on the layer (`<om-layer js>` + `<script type="om/accessors">`). Without it, blocks are restricted to `export const name = d => <expression>` — no statements, no loops, no nested functions.
|
|
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
|
-
- 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`)
|
|
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
|
+
- 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`.
|
|
30
31
|
- `<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.
|
|
31
32
|
- 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.
|
|
32
33
|
- `<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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nika-js/onlymap",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
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.5` (the bare package URL serves `dist/onlymap.standalone.js`) — plus `<link rel="stylesheet" href="https://unpkg.com/@nika-js/onlymap@0.11.5/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
|
|
|
@@ -104,7 +104,8 @@ Load the smallest reference needed for the task:
|
|
|
104
104
|
- Measure cut/fill volume (earthworks/stockpiles — how much material a shape holds, or how much to add/remove to reach a target elevation) -> `modes="distance area volume"` on the same `measure` widget. Outline a footprint (closes like `area`); the math is a REAL per-cell grid integration against the map's terrain DEM (metric tangent-plane grid at the DEM's own GSD, scanline point-in-polygon, bilinear seam-correct sampling, worker-offloaded) — mixed cut AND fill within one footprint on undulating ground, with `cellSizeM`/`gsdM`/`cutErrorM3`/`fillErrorM3` (± = per-cell cellArea × 1.5 × GSD) and `nodataFraction` published on the readout. `base-surface` picks the reference: `custom` (default — a draggable gizmo target plane, re-summed live per drag frame) or boundary-derived stockpile strategies with NO gizmo (`triangulated` boundary TIN — recommend this for "measure this pile/mound", `plane`, `lowest`, `highest`, `average`). Reads out `cutMeters3`/`fillMeters3`/`netMeters3` (signed, fill−cut)/`totalMeters3` (unsigned, cut+fill) — always RAW geometric volumes, never altered by `swell`/`shrink`. REQUIRES `terrain` on `<om-map>` — a `volume` mode with none is a validation warning (falls back to a flat-plane approximation with no error figures). Volume-only attributes, all no-ops (validation warns) without `volume` in `modes`: `base-surface`; `profile` (elevation samples around the footprint's own perimeter, live while sketching — dispatched on `profileSeries` for a `dynamic-chart` widget to plot; each point is `{x, y}` plus `vertexIndex` on the samples that ARE the drawn corners, so a spec can mark them with `isValid(datum.vertexIndex)` — vertex 0 is the chart's leftmost point, and the map badges the FIRST TWO vertices `1 · Start` and `2` in draw order (1-based display; the field stays 0-based) so the ring's winding direction is readable rather than guessed — two badges fix a direction at constant cost, while the chart still marks every corner — that widget is generic: `<om-widget type="dynamic-chart" on="om-measure" series-field="profileSeries" width="320">` reads `event.detail[seriesField]` on every matching event and redraws, and "freezes" for free when a later event simply omits that field); `deadband` (zeroes a Cut/Fill figure below the threshold); `density`/`swell`/`shrink` populate a SEPARATE Material section (Bank/Loose/Compacted convention — `cutAdjustedMeters3` = raw × swell, `fillAdjustedMeters3` = raw ÷ shrink, `cutMassKg`/`fillMassKg` from the raw, mass-conserving volume), shown only once one of the three is configured — never baked into the primary Cut/Fill/Net/Total numbers. A `stale` readout field flags the window between a footprint committing and its integration resolving.
|
|
105
105
|
- Need a real ELEVATION on a click/hover (a z readout, a tooltip showing the height of the building face under the cursor, a coordinate that lands on 3D content rather than the ground behind it) -> `pickable="3d"` on the layer instead of a bare `pickable` (issue #34): it opts the layer into deck's depth-pick pass, and the resolved coordinate carries a third component. Read it as `{{z}}` in an `<om-overlay>` / `show-tooltip` template or `ctx.selection.coordinate` in a widget script. `terrain` sets this on itself. `{{z}}` is ABSENT (not `0`) when no layer in the scene ran the depth pass for that pick — do not treat a missing elevation as sea level.
|
|
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
|
-
- 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`)
|
|
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
|
+
- 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`.
|
|
108
109
|
- 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.
|
|
109
110
|
|
|
110
111
|
## 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.5/dist/onlymapjs.css">
|
|
20
|
+
<script type="module" src="https://unpkg.com/@nika-js/onlymap@0.11.5"></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).
|
|
@@ -90,6 +90,8 @@ Events: `om-map-ready` (boot complete; `await mapEl.ready` is the promise twin),
|
|
|
90
90
|
|
|
91
91
|
`await mapEl.snapshot()` (also on `MapController`) returns a canvas-only PNG dataURL of the scene — basemap + layers composited at device pixels (`{as: "blob"}` for files; `type`/`quality` for jpeg/webp). DOM widgets, overlays, and the provider attribution are NOT in the pixels: exports must render credits themselves. Await `ready` first; headless maps reject.
|
|
92
92
|
|
|
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
|
+
|
|
93
95
|
Example:
|
|
94
96
|
|
|
95
97
|
```html
|