lecodes-sdk 0.19.1 → 0.20.0

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.
@@ -0,0 +1,174 @@
1
+ import { NativeView } from "../ui/NativeView";
2
+ import type { FetchResponse } from "../runtime/fetch";
3
+ /** The ready-made styles a map falls back on — [OpenFreeMap](https://openfreemap.org): OSM data,
4
+ * no key, no registration, no request limits, commercial use allowed, and the whole stack is
5
+ * open-source if you'd rather self-host. `liberty` is the default. Credit them (and OSM) in your
6
+ * app: "© OpenFreeMap © OpenMapTiles, data from OpenStreetMap". A public free instance is a
7
+ * donation-funded service with no SLA — for a product with real traffic, run your own tiles and
8
+ * pass that style's URL instead. */
9
+ export type MapStyleName = "liberty" | "bright" | "positron" | "dark" | "fiord";
10
+ /**
11
+ * Where the map's style comes from:
12
+ *
13
+ * - a **name** — `"liberty"` (the default), `"positron"`, … see {@link MapStyleName}: a ready-made
14
+ * style on a free public tile server, so `MapView()` alone already draws a world map;
15
+ * - a **URL** — `"https://tiles.example.com/styles/city/style.json"`, the map fetches it;
16
+ * - a **bundled style** — `asset("./map/style.json")`: the file ships inside the app and the
17
+ * wrapper hands its text to the map, so the style itself needs no server (tiles, sprites and
18
+ * glyphs are still fetched from whatever urls it names);
19
+ * - an **already-read file** — a `FetchResponse` from `fetchLocal("style.json")` or
20
+ * `await fetch(url)` (a style downloaded once and cached in `files`);
21
+ * - the **style object** itself — the natural way to substitute a tile-server address at runtime:
22
+ * `{ ...style, sources: { openmaptiles: { type: "vector", url: `${server}/data/v3.json` } } }`.
23
+ *
24
+ * Whichever form: **every url INSIDE the style (`sources[].url`, `sprite`, `glyphs`) must be
25
+ * absolute.** maplibre-native, unlike maplibre-gl-js, resolves no relative ones — a style with
26
+ * them loads to an empty basemap (your layers still draw). A tileserver-gl instance emits
27
+ * relative urls until its `publicUrl` is configured.
28
+ */
29
+ export type MapStyle = MapStyleName | (string & {}) | FetchResponse | object;
30
+ /** `[longitude, latitude]` — GeoJSON order, the same as the style, the tiles and your data. */
31
+ export type LngLat = [number, number];
32
+ export interface MapCamera {
33
+ center: LngLat;
34
+ zoom: number;
35
+ /** Degrees clockwise from north. */
36
+ bearing: number;
37
+ /** Degrees from the vertical. */
38
+ pitch: number;
39
+ }
40
+ export interface MapOptions {
41
+ /** The MapLibre style: a ready-made name (`"liberty"` — the default, `"positron"`, …), a URL,
42
+ * a style bundled with the app (`asset("./style.json")`), an already-read file
43
+ * (`fetchLocal("style.json")`, `await fetch(url)`) or the style object itself — see
44
+ * {@link MapStyle}. */
45
+ style?: MapStyle;
46
+ center?: LngLat;
47
+ zoom?: number;
48
+ minZoom?: number;
49
+ maxZoom?: number;
50
+ bearing?: number;
51
+ pitch?: number;
52
+ /** Two-finger rotate gesture (default true). */
53
+ rotate?: boolean;
54
+ /** Two-finger tilt gesture (default false — most city maps stay flat). */
55
+ tilt?: boolean;
56
+ }
57
+ /** A tap on the map itself — not on a feature of a managed layer. */
58
+ export interface MapTap {
59
+ lngLat: LngLat;
60
+ /** View-space point, px. */
61
+ point: [number, number];
62
+ }
63
+ export interface CameraMove {
64
+ zoom?: number;
65
+ bearing?: number;
66
+ pitch?: number;
67
+ /** Animation length, ms (flyTo only; default 600). */
68
+ duration?: number;
69
+ }
70
+ export interface MapPaddingValues {
71
+ top?: number | string;
72
+ left?: number | string;
73
+ bottom?: number | string;
74
+ right?: number | string;
75
+ }
76
+ export interface FitOptions {
77
+ /** Px around the points, or per edge. Added to the view padding set by `setPadding`. */
78
+ padding?: number | MapPaddingValues;
79
+ maxZoom?: number;
80
+ /** Default true. */
81
+ animate?: boolean;
82
+ }
83
+ /** One marker. `id` comes back in `onTap`; `icon` names an image of the style's sprite; `color` /
84
+ * `title` feed the default layers; extra keys become feature properties. */
85
+ export interface MarkerItem {
86
+ id: string | number;
87
+ lngLat: LngLat;
88
+ icon?: string;
89
+ color?: string;
90
+ title?: string;
91
+ [property: string]: any;
92
+ }
93
+ export interface MarkerTap {
94
+ id: string | number;
95
+ lngLat: LngLat;
96
+ /** Every property of the tapped feature (the item's keys, `id` and `lngLat` excluded). */
97
+ properties: Record<string, any>;
98
+ }
99
+ export interface MarkerLayerOptions {
100
+ /** Group nearby markers into clusters (a cluster tap zooms in). Default false. */
101
+ cluster?: boolean;
102
+ /** Cluster radius, px (default 50). */
103
+ clusterRadius?: number;
104
+ /** Zoom at which clusters stop forming (default: maxZoom − 1). */
105
+ clusterMaxZoom?: number;
106
+ }
107
+ export interface LineLayerOptions {
108
+ color?: string;
109
+ /** Px (default 4). */
110
+ width?: number;
111
+ /** 0–1 (default 1). */
112
+ opacity?: number;
113
+ }
114
+ export interface UserLocationOptions {
115
+ /** Horizontal accuracy radius, meters — drawn as the halo around the dot. */
116
+ accuracy?: number | null;
117
+ /** Degrees clockwise from north — drawn as the direction wedge; null hides it. */
118
+ heading?: number | null;
119
+ }
120
+ export interface MarkerLayer {
121
+ readonly name: string;
122
+ /** Replace the layer's markers. */
123
+ set(items: MarkerItem[]): this;
124
+ clear(): this;
125
+ /** A marker (or any feature of this layer's source) was tapped. */
126
+ onTap(callback: (marker: MarkerTap) => void): this;
127
+ }
128
+ export interface LineLayer {
129
+ readonly name: string;
130
+ /** Replace the line with these vertices. */
131
+ set(coordinates: LngLat[]): this;
132
+ clear(): this;
133
+ }
134
+ export interface MapView extends NativeView {
135
+ /** The style loaded and the map is interactive (queued calls have been replayed). */
136
+ onReady(callback: () => void): this;
137
+ /** A tap that hit no feature of a managed layer. */
138
+ onTap(callback: (tap: MapTap) => void): this;
139
+ /** The camera settled after a gesture or an animation. */
140
+ onMove(callback: (camera: MapCamera) => void): this;
141
+ /** The map reported a problem — a style that wouldn't load, a source it couldn't reach. Never
142
+ * fatal; with no handler the message goes to `console.error`, so it is never silent. */
143
+ onError(callback: (error: {
144
+ message: string;
145
+ }) => void): this;
146
+ /** A named marker layer (one GeoJSON source). If the style already declares a source with this
147
+ * name, its layers are used as-is and only the data is pushed; otherwise the plugin creates the
148
+ * source and default marker layers (colored dot, `icon`, `title` label; clusters on request). */
149
+ markers(name: string, options?: MarkerLayerOptions): MarkerLayer;
150
+ /** A named line layer (one GeoJSON source) — same style-first rule as `markers`. */
151
+ line(name: string, options?: LineLayerOptions): LineLayer;
152
+ /** Raw escape hatch: replace the data of any GeoJSON source in the style. */
153
+ setData(source: string, geojson: object): this;
154
+ flyTo(center: LngLat, options?: CameraMove): this;
155
+ jumpTo(center: LngLat, options?: CameraMove): this;
156
+ /** Fit the camera to these points (padding + the view padding respected). */
157
+ fitPoints(points: LngLat[], options?: FitOptions): this;
158
+ /** Content inset: the part of the view covered by your UI (`"40%"` = of the view's size).
159
+ * Camera operations center inside the remaining area. */
160
+ setPadding(padding: MapPaddingValues): this;
161
+ getCamera(): Promise<MapCamera>;
162
+ /** Move the user puck (the map draws it; the position comes from you — `Geolocation.watch`).
163
+ * `null` hides it. */
164
+ setUserLocation(lngLat: LngLat | null, options?: UserLocationOptions): this;
165
+ }
166
+ /**
167
+ * Create a map view. `MapView.isSupported` reports whether this host registered a "map" view —
168
+ * check it before offering the feature (web, headless and shells without the plugin have none).
169
+ */
170
+ export declare const MapView: {
171
+ (options?: MapOptions): MapView;
172
+ /** Whether this host registered a "map" view. */
173
+ readonly isSupported: boolean;
174
+ };