@nika-js/onlymap 0.8.1 → 0.8.3

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/dist/basemap.d.ts CHANGED
@@ -162,6 +162,8 @@ export declare class MapLibreBasemapAdapter {
162
162
  * back, while a controller maximum simply refuses to go further.
163
163
  */
164
164
  setMaxPitch(maxPitch: number | null): void;
165
+ /** Floor how far the user can zoom out. Null restores MapLibre's own minimum. */
166
+ setMinZoom(minZoom: number | null): void;
165
167
  isLoaded(): boolean;
166
168
  getViewport(): ViewportLike;
167
169
  getViewState(): BasemapViewState;
@@ -33,6 +33,8 @@ export declare class OmFrameElement extends CartographElementBase implements Car
33
33
  private liveMapOwned;
34
34
  /** A capture standing in for the live map during export/print. */
35
35
  private captureImage;
36
+ /** The authored camera last driven into the map, so a re-render can tell an edit from a repaint. */
37
+ private appliedCameraKey;
36
38
  private printing;
37
39
  get mode(): FrameMode;
38
40
  /** The mounted `<om-map>`, once a live frame has one. */
@@ -62,6 +64,16 @@ export declare class OmFrameElement extends CartographElementBase implements Car
62
64
  /** Leave live mode without deleting an authored inline map. */
63
65
  private suspendLiveMode;
64
66
  private releaseLiveMap;
67
+ /** The mounted map's own camera, or null before it can report one. */
68
+ private liveCamera;
69
+ /**
70
+ * The map settled somewhere new. Re-derive the georeference from where it
71
+ * actually is, and tell the page — its north arrow, scale bar, graticule,
72
+ * locator inset and {{scale}} tokens all describe THIS view now. A frozen
73
+ * frame captures these corners too, so a freeze after a rotate places the
74
+ * raster by the view that was captured, not the one that was authored.
75
+ */
76
+ private readonly onLiveViewSettled;
65
77
  private updateLiveCorners;
66
78
  private mountLive;
67
79
  private sizeLiveMap;
@@ -74,7 +86,6 @@ export declare class OmFrameElement extends CartographElementBase implements Car
74
86
  * is the frame's own, recomputed whenever its box changes, because it
75
87
  * depends on the box's aspect and the current zoom.
76
88
  */
77
- private capMapPitch;
78
89
  /**
79
90
  * Draw another frame's footprint on this one. The outline is DENSIFIED —
80
91
  * sampled along each edge and projected point by point — because a
@@ -84,16 +84,26 @@ export interface FrameGeoref {
84
84
  /** Millimetres from the frame's top-left → lon/lat. Null when unmappable. */
85
85
  unproject(xMm: number, yMm: number): LngLat | null;
86
86
  /** Ground metres per page millimetre along the frame's horizontal centre line. */
87
+ /**
88
+ * Corners and queries are taken as continuous longitudes (a live frame's,
89
+ * from the renderer) rather than folded into one turn of the world.
90
+ */
91
+ readonly continuous: boolean;
87
92
  groundMetersPerMm(): number;
93
+ /** Ground length of one row of the frame, walked in segments so a world-wrapping row measures true. */
94
+ rowGroundMeters(yMm: number, segments?: number): number | null;
88
95
  }
96
+ export declare const wrapLng: (lng: number) => number;
89
97
  export interface CreateGeorefOptions {
90
98
  corners: readonly [LngLat, LngLat, LngLat, LngLat];
91
99
  widthMm: number;
92
100
  heightMm: number;
93
101
  /** Resolved CRS plane; defaults to Web Mercator (what live frames always are). */
94
102
  crsForward?: CrsForward | null;
103
+ /** Trust the corners' longitudes as continuous; see `FrameGeoref.continuous`. */
104
+ continuous?: boolean;
95
105
  }
96
- export declare function createFrameGeoref({ corners, widthMm, heightMm, crsForward }: CreateGeorefOptions): FrameGeoref;
106
+ export declare function createFrameGeoref({ corners, widthMm, heightMm, crsForward, continuous }: CreateGeorefOptions): FrameGeoref;
97
107
  /**
98
108
  * Parse a `corners=` attribute: JSON `[[lng,lat],[lng,lat],[lng,lat],[lng,lat]]`
99
109
  * (tl, tr, br, bl) or a flat list of eight numbers in the same order. Returns
@@ -13,7 +13,7 @@
13
13
  * visibly bow away from the truth on a wide or rotated frame.
14
14
  */
15
15
  import type { LngLat } from "../geodesy";
16
- import type { FrameGeoref } from "./georef";
16
+ import { type FrameGeoref } from "./georef";
17
17
  export interface GraticuleLine {
18
18
  /** Points in frame millimetres. */
19
19
  points: {
@@ -36,29 +36,28 @@ export interface FrameCamera {
36
36
  /** Read the frame's own camera; null when it has not authored one. */
37
37
  export declare function readCamera(el: Element): FrameCamera | null;
38
38
  /**
39
- * The four ground corners a camera sees in a `widthPx × heightPx` box, in
40
- * tl, tr, br, bl order.
39
+ * The steepest pitch this frame can still georeference, in whole degrees.
41
40
  *
42
- * Null when the view cannot be georeferenced as a quad: past roughly 60° of
43
- * pitch the top edge unprojects at or beyond the horizon, where "the ground
44
- * under this pixel" has no finite answer. Returning null there — rather than
45
- * a huge number that looks like a coordinate — is what lets the frame mark
46
- * itself degenerate and the furniture refuse to draw.
41
+ * Since 0.8.3 a live frame's georeference is continuous — it follows the
42
+ * world's wrap and the blank ground past the Mercator band the way the map
43
+ * does — so for any real box this is simply the ceiling: at deck's own 60°
44
+ * and field of view no corner ever loses its finite answer. Kept as the
45
+ * honest way to ask the question (and for a degenerate box, where the answer
46
+ * is 0), not because a frame constrains its map with it any more.
47
47
  */
48
+ export declare function maxGeoreferenceablePitch(core: CoreModule, camera: FrameCamera, widthPx: number, heightPx: number, ceiling?: number): number;
48
49
  /**
49
- * The steepest pitch this frame can still georeference, in whole degrees.
50
- *
51
- * There is no constant to use here. The corners are unprojected through the
52
- * frame's OWN box, so the ceiling moves with its aspect and the zoom: a wide
53
- * frame tilts further than a tall one, and zooming in raises the limit again.
54
- * A fixed 45° or 60° would be wrong in both directions — too strict on the
55
- * frames that could tilt, too lax on the ones that cannot.
50
+ * The four ground corners a camera sees in a `widthPx × heightPx` box, in
51
+ * tl, tr, br, bl order — CONTINUOUS longitudes, as the renderer reports them.
56
52
  *
57
- * Coarse then fine: the answer only needs to be whole degrees, and each probe
58
- * is four unprojections, so this is a handful of microseconds rather than
59
- * something worth caching.
53
+ * Not folded into one turn of the world and not clamped to the Mercator band:
54
+ * a frame zoomed out far enough shows the world wrapping, exactly as the map
55
+ * inside it does, and its corners say so (a corner can read −360°, or 88°).
56
+ * The georeference fitted from them is `continuous`, so furniture places
57
+ * every copy where the renderer draws it. Null only when a corner has no
58
+ * finite answer at all — which, at deck's own 60° pitch ceiling and field of
59
+ * view, no camera produces; it guards a degenerate box, not a steep one.
60
60
  */
61
- export declare function maxGeoreferenceablePitch(core: CoreModule, camera: FrameCamera, widthPx: number, heightPx: number, ceiling?: number): number;
62
61
  export declare function cornersFromCamera(core: CoreModule, camera: FrameCamera, widthPx: number, heightPx: number): Corners | null;
63
62
  /** Load the core and build an `<om-map>` for a frame, from `src=` or an inline child. */
64
63
  export declare function buildLiveMap(frame: Element): Promise<{