@yarrow-uz/rn-map-sdk 0.3.0 → 0.5.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.
- package/CHANGELOG.md +22 -0
- package/README.md +48 -8
- package/dist/index.d.ts +2 -1277
- package/dist/index.js +3 -2554
- package/dist/preflight.d.ts +15 -0
- package/dist/preflight.js +37 -0
- package/dist/surface-BY-U7jnq.js +2689 -0
- package/dist/surface-CvmTHryW.d.ts +1336 -0
- package/dist/surface.d.ts +2 -0
- package/dist/surface.js +3 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,1277 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { NativeSyntheticEvent, ViewProps } from "react-native";
|
|
4
|
-
declare const YARROW_MAP_URL: string;
|
|
5
|
-
declare const YARROW_SEARCH_API_URL: string;
|
|
6
|
-
export declare function setYarrowApiKey(apiKey: string): void;
|
|
7
|
-
export declare function getYarrowApiKey(): string;
|
|
8
|
-
/**
|
|
9
|
-
* Appends the configured API key as the `api_key` query parameter. Returns the
|
|
10
|
-
* url unchanged when no key is configured yet or the url cannot be parsed.
|
|
11
|
-
*/
|
|
12
|
-
export declare function addApiKeyToUrl(url: string): string;
|
|
13
|
-
type CacheConfig = {
|
|
14
|
-
enabled?: boolean;
|
|
15
|
-
lifespanDays?: number;
|
|
16
|
-
};
|
|
17
|
-
type NormalizedCacheConfig = {
|
|
18
|
-
enabled: boolean;
|
|
19
|
-
lifespanDays: number;
|
|
20
|
-
};
|
|
21
|
-
type CachedArrayBufferResponse = {
|
|
22
|
-
data: ArrayBuffer;
|
|
23
|
-
cacheControl: string | null;
|
|
24
|
-
expires: string | null;
|
|
25
|
-
contentType: string | null;
|
|
26
|
-
};
|
|
27
|
-
type BoundsInput = {
|
|
28
|
-
type?: string;
|
|
29
|
-
features: Array<{
|
|
30
|
-
geometry?: {
|
|
31
|
-
type?: string;
|
|
32
|
-
coordinates?: unknown;
|
|
33
|
-
};
|
|
34
|
-
}>;
|
|
35
|
-
};
|
|
36
|
-
type RouteFeature = {
|
|
37
|
-
type: 'Feature';
|
|
38
|
-
geometry: {
|
|
39
|
-
type: 'LineString';
|
|
40
|
-
coordinates: [number, number][];
|
|
41
|
-
};
|
|
42
|
-
properties: {
|
|
43
|
-
duration: number;
|
|
44
|
-
distance: number;
|
|
45
|
-
[key: string]: unknown;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
/** Style-API endpoint returning the icon registry (`IconListItem[]`). */
|
|
49
|
-
export declare const ICONS_ENDPOINT = "/icons-image";
|
|
50
|
-
type SearchResult = {
|
|
51
|
-
id?: string | number;
|
|
52
|
-
latitude?: number;
|
|
53
|
-
longitude?: number;
|
|
54
|
-
icon_img?: string;
|
|
55
|
-
name?: string;
|
|
56
|
-
/** Backend category, e.g. `{ id: 789, name: "school" }`. The `name` field
|
|
57
|
-
* matches sprite names loaded into the map's icon registry at init, so
|
|
58
|
-
* it's used as a fallback icon source when `icon_img` is missing. */
|
|
59
|
-
category?: {
|
|
60
|
-
id?: number;
|
|
61
|
-
name?: string;
|
|
62
|
-
};
|
|
63
|
-
[key: string]: unknown;
|
|
64
|
-
};
|
|
65
|
-
export declare const DEFAULT_CACHE_LIFESPAN_DAYS = 30;
|
|
66
|
-
export declare const MILLISECONDS_PER_DAY: number;
|
|
67
|
-
export declare const TILE_CACHE_NAME = "yarrow-cache-v1-tile";
|
|
68
|
-
export declare const ICON_CACHE_NAME = "yarrow-cache-v1-icon";
|
|
69
|
-
export declare const CACHE_PROTOCOL = "yarrowcache";
|
|
70
|
-
export declare const CACHED_AT_HEADER = "x-yarrow-cached-at";
|
|
71
|
-
/** A geographic bounding box in degrees. */
|
|
72
|
-
type BoundingBox = {
|
|
73
|
-
xMin: number;
|
|
74
|
-
xMax: number;
|
|
75
|
-
yMin: number;
|
|
76
|
-
yMax: number;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Computes the geographic bounding box of a FeatureCollection whose features
|
|
80
|
-
* are Points, LineStrings or Polygons. Pure platform-agnostic math shared by
|
|
81
|
-
* the web and React Native SDKs' camera helpers.
|
|
82
|
-
*/
|
|
83
|
-
export declare function getBoundingBox(data: BoundsInput): BoundingBox;
|
|
84
|
-
/**
|
|
85
|
-
* Structural subset of maplibre-gl's `RequestParameters` covering the fields
|
|
86
|
-
* used for the network fetch. Any real maplibre `RequestParameters` object is
|
|
87
|
-
* assignable to this type.
|
|
88
|
-
*/
|
|
89
|
-
type RequestParametersLike = {
|
|
90
|
-
method?: string;
|
|
91
|
-
headers?: {
|
|
92
|
-
[key: string]: string;
|
|
93
|
-
};
|
|
94
|
-
body?: BodyInit | null;
|
|
95
|
-
credentials?: 'omit' | 'same-origin' | 'include';
|
|
96
|
-
};
|
|
97
|
-
export declare const hasCacheStorage: () => boolean;
|
|
98
|
-
export declare const fetchArrayBufferWithCache: (url: string, cacheName: string, lifespanMs: number, abortController: AbortController, requestParameters?: RequestParametersLike) => Promise<CachedArrayBufferResponse>;
|
|
99
|
-
/** Routing API endpoint used by `fetchRoutes()`. */
|
|
100
|
-
export declare const ROUTE_API_URL = "https://api.yarrow.uz/api/routing/route";
|
|
101
|
-
/**
|
|
102
|
-
* Turn modifier returned by the routing API for a direction step.
|
|
103
|
-
* Falls back to `string` for any value not enumerated here.
|
|
104
|
-
*/
|
|
105
|
-
type RouteDirectionModifier = 'move' | 'left' | 'right' | 'slight left' | 'slight right' | 'sharp left' | 'sharp right' | 'straight' | 'uturn' | (string & {});
|
|
106
|
-
/**
|
|
107
|
-
* A single turn-by-turn step in a route's directions.
|
|
108
|
-
*
|
|
109
|
-
* `distance`/`duration` are omitted on terminal steps (e.g. the final
|
|
110
|
-
* "arrive" instruction), so they are optional. `to_street` is only present
|
|
111
|
-
* when the step transitions onto a named street.
|
|
112
|
-
*/
|
|
113
|
-
type RouteDirection = {
|
|
114
|
-
instruction: string;
|
|
115
|
-
modifier?: RouteDirectionModifier;
|
|
116
|
-
modifier_key?: string;
|
|
117
|
-
to_street?: string;
|
|
118
|
-
distance?: number;
|
|
119
|
-
duration?: number;
|
|
120
|
-
[key: string]: unknown;
|
|
121
|
-
};
|
|
122
|
-
/** Platform-agnostic input for `fetchRoutes()` — the network half of
|
|
123
|
-
* `buildRoute()`. Rendering/callback options stay in the platform SDKs. */
|
|
124
|
-
type FetchRoutesInput = {
|
|
125
|
-
profile: string;
|
|
126
|
-
coordinates: [number, number][];
|
|
127
|
-
language?: string;
|
|
128
|
-
/** Cancels the routing request. */
|
|
129
|
-
signal?: AbortSignal;
|
|
130
|
-
};
|
|
131
|
-
interface RoutesMeta {
|
|
132
|
-
profile: string;
|
|
133
|
-
totalRoutes: number;
|
|
134
|
-
bestRouteIndex: number;
|
|
135
|
-
duration: number;
|
|
136
|
-
distance: number;
|
|
137
|
-
}
|
|
138
|
-
interface FetchRoutesResult {
|
|
139
|
-
features: RouteFeature[];
|
|
140
|
-
directions: RouteDirection[][];
|
|
141
|
-
meta: RoutesMeta;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Network half of the routing flow: POSTs the route request to the Yarrow
|
|
145
|
-
* routing API, parses and normalizes the response (coordinate order fix
|
|
146
|
-
* included). Rendering, events and camera work stay in the platform SDKs —
|
|
147
|
-
* they consume the returned features/directions/meta verbatim.
|
|
148
|
-
*
|
|
149
|
-
* Early "no route" outcomes resolve to an empty result (never throw), exactly
|
|
150
|
-
* like the web SDK's historic `buildRoute()` behavior.
|
|
151
|
-
*/
|
|
152
|
-
export declare function fetchRoutes(input: FetchRoutesInput): Promise<FetchRoutesResult>;
|
|
153
|
-
export declare const transformRouteCoordinates: (features: RouteFeature[]) => RouteFeature[];
|
|
154
|
-
export declare const haversineDistance: (lat1: number, lon1: number, lat2: number, lon2: number) => number;
|
|
155
|
-
interface FetchSearchResultsInput {
|
|
156
|
-
lat: number;
|
|
157
|
-
lon: number;
|
|
158
|
-
page?: number;
|
|
159
|
-
pageSize?: number;
|
|
160
|
-
signal: AbortSignal;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Queries the Yarrow search API around a coordinate. Pure network + mapping —
|
|
164
|
-
* marker rendering stays in the platform SDKs.
|
|
165
|
-
*/
|
|
166
|
-
export declare function fetchSearchResults(query: string, input: FetchSearchResultsInput): Promise<SearchResult[]>;
|
|
167
|
-
type YarrowStyleType = 'default' | 'satellite' | 'hybrid';
|
|
168
|
-
/**
|
|
169
|
-
* Validates a user-supplied style type, warning (and falling back to
|
|
170
|
-
* `"default"`) on anything unrecognized. Verbatim behavior of the web SDK's
|
|
171
|
-
* `changeStyles()` guard.
|
|
172
|
-
*/
|
|
173
|
-
export declare function normalizeStyleType(styleType?: string): YarrowStyleType;
|
|
174
|
-
/**
|
|
175
|
-
* Style-fetch endpoint for a style type/theme combination, e.g.
|
|
176
|
-
* `/styles/satellite/?dark=true`. Verbatim behavior of the web SDK's
|
|
177
|
-
* `YarrowStylesManager.buildStyleEndpoint()`.
|
|
178
|
-
*/
|
|
179
|
-
export declare function buildStyleEndpoint(styleType: YarrowStyleType, theme: 'light' | 'dark'): string;
|
|
180
|
-
export declare function trackDau(apiKey: string, sdkType?: string): void;
|
|
181
|
-
/**
|
|
182
|
-
* Public alias of `STORAGE_KEY` so platform SDKs can build storage adapters
|
|
183
|
-
* (e.g. React Native AsyncStorage bridges) without hard-coding the key.
|
|
184
|
-
*/
|
|
185
|
-
export declare const USER_TOKEN_STORAGE_KEY = "yarrow:user_token";
|
|
186
|
-
/**
|
|
187
|
-
* Minimal persistence contract for the anonymous user token. The default
|
|
188
|
-
* resolution uses `localStorage` when available (guarded — this is the only
|
|
189
|
-
* file in core allowed to touch it); shells without a DOM (e.g. React Native)
|
|
190
|
-
* can inject their own storage via `setTokenStorage`.
|
|
191
|
-
*/
|
|
192
|
-
interface TokenStorage {
|
|
193
|
-
getItem(key: string): string | null;
|
|
194
|
-
setItem(key: string, value: string): void;
|
|
195
|
-
}
|
|
196
|
-
export declare function setTokenStorage(storage: TokenStorage): void;
|
|
197
|
-
export declare function getOrCreateUserToken(): string;
|
|
198
|
-
type ClusterBadgeProps = {
|
|
199
|
-
/** Cluster centroid as `[longitude, latitude]`. */
|
|
200
|
-
lngLat: [number, number];
|
|
201
|
-
/** Number of markers the badge stands in for. */
|
|
202
|
-
count: number;
|
|
203
|
-
/** Visual theme — picks the badge colors (web parity). */
|
|
204
|
-
theme: 'light' | 'dark';
|
|
205
|
-
onPress?: () => void;
|
|
206
|
-
};
|
|
207
|
-
/**
|
|
208
|
-
* The count badge that stands in for clustered highlight/search markers —
|
|
209
|
-
* the native counterpart of the web SDK's cluster DOM marker (blue circle,
|
|
210
|
-
* white border, bold count).
|
|
211
|
-
*/
|
|
212
|
-
export declare const ClusterBadge: import("react").MemoExoticComponent<({ lngLat, count, theme, onPress }: ClusterBadgeProps) => import("react/jsx-runtime").JSX.Element>;
|
|
213
|
-
/**
|
|
214
|
-
* Clustering configuration and normalization — the declarative counterpart of
|
|
215
|
-
* the web SDK's `setClustering`. Defaults match the web SDK exactly:
|
|
216
|
-
* 60 px merge radius, no clustering above zoom 16, clusters need ≥ 2 markers.
|
|
217
|
-
*/
|
|
218
|
-
export declare const DEFAULT_CLUSTER_RADIUS_PX = 60;
|
|
219
|
-
export declare const DEFAULT_CLUSTER_MAX_ZOOM = 16;
|
|
220
|
-
export declare const DEFAULT_CLUSTER_MIN_POINTS = 2;
|
|
221
|
-
/** A single marker that belongs to a pressed cluster. */
|
|
222
|
-
type ClusterChild = {
|
|
223
|
-
/**
|
|
224
|
-
* The marker id. Web parity uses numeric POI ids; the RN SDK also accepts
|
|
225
|
-
* string keys (search results without an `id` get index-based keys).
|
|
226
|
-
*/
|
|
227
|
-
id: number | string;
|
|
228
|
-
lng: number;
|
|
229
|
-
lat: number;
|
|
230
|
-
};
|
|
231
|
-
/**
|
|
232
|
-
* Called when a cluster badge is pressed, with the POIs it represents. Return
|
|
233
|
-
* exactly `false` to suppress the default zoom-to-expand behaviour.
|
|
234
|
-
*/
|
|
235
|
-
type ClusterClickHandler = (children: ClusterChild[]) => unknown;
|
|
236
|
-
/**
|
|
237
|
-
* Clustering config for highlight/search markers. Off by default; pass `true`
|
|
238
|
-
* to enable with defaults, or an object to tune it (passing an object also
|
|
239
|
-
* enables it).
|
|
240
|
-
*/
|
|
241
|
-
type ClusteringConfig = boolean | {
|
|
242
|
-
/** Merge distance in screen points. Default 60. */
|
|
243
|
-
radius?: number;
|
|
244
|
-
/** Above this zoom, markers never cluster. Default 16. */
|
|
245
|
-
maxZoom?: number;
|
|
246
|
-
/** Minimum markers within `radius` to form a cluster. Min/default 2. */
|
|
247
|
-
minPoints?: number;
|
|
248
|
-
/** Overrides/augments the default zoom-to-expand on cluster press. */
|
|
249
|
-
onClusterClick?: ClusterClickHandler;
|
|
250
|
-
};
|
|
251
|
-
type NormalizedClusteringConfig = {
|
|
252
|
-
enabled: boolean;
|
|
253
|
-
radius: number;
|
|
254
|
-
maxZoom: number;
|
|
255
|
-
minPoints: number;
|
|
256
|
-
onClusterClick?: ClusterClickHandler;
|
|
257
|
-
};
|
|
258
|
-
/**
|
|
259
|
-
* Normalizes the public clustering option (`true` / config object / falsy)
|
|
260
|
-
* into a fully-resolved config. Passing an object enables clustering.
|
|
261
|
-
* `minPoints` is clamped to at least 2 — a "cluster" of one is just the
|
|
262
|
-
* marker itself.
|
|
263
|
-
*/
|
|
264
|
-
export declare function normalizeClusteringConfig(input: ClusteringConfig | undefined): NormalizedClusteringConfig;
|
|
265
|
-
/** A marker eligible for clustering: its id and coordinates. */
|
|
266
|
-
type ClusterPoint = {
|
|
267
|
-
id: number | string;
|
|
268
|
-
lng: number;
|
|
269
|
-
lat: number;
|
|
270
|
-
};
|
|
271
|
-
/** A computed cluster: badge position plus the members it stands in for. */
|
|
272
|
-
type PixelCluster = {
|
|
273
|
-
/**
|
|
274
|
-
* Key used to reuse a badge across recomputes (the first member's id —
|
|
275
|
-
* grouping is deterministic, so this is stable).
|
|
276
|
-
*/
|
|
277
|
-
key: number | string;
|
|
278
|
-
lng: number;
|
|
279
|
-
lat: number;
|
|
280
|
-
members: ClusterChild[];
|
|
281
|
-
};
|
|
282
|
-
/**
|
|
283
|
-
* Groups projected points greedily by pixel distance: each unvisited point
|
|
284
|
-
* seeds a group and absorbs every remaining point within `radius`. O(n²), but
|
|
285
|
-
* the highlighted/search-marker count is small (dozens at most), so this
|
|
286
|
-
* stays cheap and deterministic. Ported from the web SDK's cluster engine.
|
|
287
|
-
*/
|
|
288
|
-
export declare function groupByPixelRadius<T extends {
|
|
289
|
-
x: number;
|
|
290
|
-
y: number;
|
|
291
|
-
}>(items: T[], radius: number): T[][];
|
|
292
|
-
/**
|
|
293
|
-
* Base-style layer targets — mirrors the web SDK's `ClickLayerTarget`. Unlike
|
|
294
|
-
* the web SDK (which resolves layer ids dynamically from the loaded style),
|
|
295
|
-
* native cannot enumerate style layers, so these are the canonical Yarrow
|
|
296
|
-
* style layer ids, verified against the served `/styles/` document (identical
|
|
297
|
-
* in light and dark). Apps can override per target via the options argument
|
|
298
|
-
* of `useYarrowLayerPress` if the style changes.
|
|
299
|
-
*/
|
|
300
|
-
type ClickLayerTarget = 'pois' | 'buildings' | 'mahalla' | 'district' | 'region' | 'country';
|
|
301
|
-
export declare const YARROW_CLICK_LAYER_IDS: Record<ClickLayerTarget, string[]>;
|
|
302
|
-
type LayerPressInfo = {
|
|
303
|
-
lat: number;
|
|
304
|
-
lng: number;
|
|
305
|
-
properties: Record<string, unknown>;
|
|
306
|
-
/** `true` when the pressed POI is currently highlighted (pois target only). */
|
|
307
|
-
selected?: boolean;
|
|
308
|
-
};
|
|
309
|
-
type UseYarrowLayerPressOptions = {
|
|
310
|
-
/** Per-target layer-id overrides (the base map's layer ids). */
|
|
311
|
-
layerIds?: Partial<Record<ClickLayerTarget, string[]>>;
|
|
312
|
-
};
|
|
313
|
-
/**
|
|
314
|
-
* Base-style-layer press handler — the native counterpart of the web SDK's
|
|
315
|
-
* `onIconClick('pois' | 'buildings')` and `onLayerClick(<admin label>)`. On
|
|
316
|
-
* every map press it queries the rendered features at the press point for the
|
|
317
|
-
* target layers and invokes `handler` with the topmost hit. Must be called
|
|
318
|
-
* inside `<YarrowMapView>` — extract a child component rendered as a map
|
|
319
|
-
* child (hooks outside the map can't see the runtime):
|
|
320
|
-
*
|
|
321
|
-
* ```tsx
|
|
322
|
-
* function PoiPressReporter() {
|
|
323
|
-
* useYarrowLayerPress('pois', ({ lat, lng, properties, selected }) => {
|
|
324
|
-
* console.log('POI pressed', properties.id, selected);
|
|
325
|
-
* });
|
|
326
|
-
* return null;
|
|
327
|
-
* }
|
|
328
|
-
*
|
|
329
|
-
* <YarrowMapView apiKey={KEY}>
|
|
330
|
-
* <PoiPressReporter />
|
|
331
|
-
* </YarrowMapView>
|
|
332
|
-
* ```
|
|
333
|
-
*
|
|
334
|
-
* Unlike the web SDK, targets resolve to the canonical Yarrow style layer
|
|
335
|
-
* ids (verified against the served `/styles/` document, identical in light
|
|
336
|
-
* and dark) instead of dynamic style inspection — override `layerIds` if
|
|
337
|
-
* your style variant names them differently.
|
|
338
|
-
*/
|
|
339
|
-
export declare function useYarrowLayerPress(target: ClickLayerTarget | ClickLayerTarget[], handler: (info: LayerPressInfo) => void, options?: UseYarrowLayerPressOptions): void;
|
|
340
|
-
type UseYarrowSearchOptions = {
|
|
341
|
-
/** Latitude the search ranks results around. */
|
|
342
|
-
lat: number;
|
|
343
|
-
/** Longitude the search ranks results around. */
|
|
344
|
-
lon: number;
|
|
345
|
-
/** Result page. Default `1`. */
|
|
346
|
-
page?: number;
|
|
347
|
-
/** Results per page. Default `15`. */
|
|
348
|
-
pageSize?: number;
|
|
349
|
-
/** Debounce before querying, ms. Default `300`. */
|
|
350
|
-
debounceMs?: number;
|
|
351
|
-
/** Set `false` to pause querying — pending results clear while paused.
|
|
352
|
-
* Default `true`. */
|
|
353
|
-
enabled?: boolean;
|
|
354
|
-
};
|
|
355
|
-
type UseYarrowSearchResult = {
|
|
356
|
-
results: SearchResult[];
|
|
357
|
-
isLoading: boolean;
|
|
358
|
-
error: Error | null;
|
|
359
|
-
};
|
|
360
|
-
/**
|
|
361
|
-
* Debounced, abortable search against the Yarrow search API.
|
|
362
|
-
*
|
|
363
|
-
* Requires the API key to be configured (`YarrowMapView` does this on mount;
|
|
364
|
-
* otherwise call `setYarrowApiKey()` first).
|
|
365
|
-
*
|
|
366
|
-
* ```tsx
|
|
367
|
-
* const { results, isLoading } = useYarrowSearch(query, {
|
|
368
|
-
* lat: position?.lat ?? 41.2995,
|
|
369
|
-
* lon: position?.lng ?? 69.2401,
|
|
370
|
-
* });
|
|
371
|
-
* ```
|
|
372
|
-
*/
|
|
373
|
-
export declare const useYarrowSearch: (query: string, options: UseYarrowSearchOptions) => UseYarrowSearchResult;
|
|
374
|
-
type UseYarrowMapSearchOptions = UseYarrowSearchOptions & {
|
|
375
|
-
/**
|
|
376
|
-
* Re-runs the search when the camera moves at least `thresholdMeters`
|
|
377
|
-
* (default 500, web parity) after a `debounceMs` settle delay (default 250,
|
|
378
|
-
* web parity). Pass `false` to disable; `true` uses both defaults.
|
|
379
|
-
*/
|
|
380
|
-
refetchOnMove?: boolean | {
|
|
381
|
-
thresholdMeters?: number;
|
|
382
|
-
debounceMs?: number;
|
|
383
|
-
};
|
|
384
|
-
};
|
|
385
|
-
type UseYarrowMapSearchResult = UseYarrowSearchResult & {
|
|
386
|
-
/** The coordinate the current results were fetched around. */
|
|
387
|
-
center: {
|
|
388
|
-
lat: number;
|
|
389
|
-
lon: number;
|
|
390
|
-
};
|
|
391
|
-
};
|
|
392
|
-
/**
|
|
393
|
-
* `useYarrowSearch` plus web-parity re-query on camera movement: when the map
|
|
394
|
-
* moves ≥ 500 m from where the current results were fetched for, the search
|
|
395
|
-
* re-runs around the new center. Must be called inside `<YarrowMapView>` to
|
|
396
|
-
* observe camera moves (outside one it behaves exactly like `useYarrowSearch`).
|
|
397
|
-
*
|
|
398
|
-
* ```tsx
|
|
399
|
-
* const { results, isLoading, center } = useYarrowMapSearch(query, {
|
|
400
|
-
* lat: 41.2995,
|
|
401
|
-
* lon: 69.2401,
|
|
402
|
-
* refetchOnMove: true,
|
|
403
|
-
* });
|
|
404
|
-
* <SearchResultsLayer results={results} />
|
|
405
|
-
* ```
|
|
406
|
-
*/
|
|
407
|
-
export declare function useYarrowMapSearch(query: string, options: UseYarrowMapSearchOptions): UseYarrowMapSearchResult;
|
|
408
|
-
type UseYarrowRoutingOptions = {
|
|
409
|
-
/** Routing profile, e.g. `"driving"`, `"walking"`. Default `"driving"`. */
|
|
410
|
-
profile?: string;
|
|
411
|
-
/** Language for turn-by-turn directions. */
|
|
412
|
-
language?: string;
|
|
413
|
-
};
|
|
414
|
-
type BuildRouteInput = {
|
|
415
|
-
/** Waypoints as `[longitude, latitude][]` (minimum two). */
|
|
416
|
-
coordinates: [number, number][];
|
|
417
|
-
/** Overrides the hook-level profile for this request. */
|
|
418
|
-
profile?: string;
|
|
419
|
-
/** Overrides the hook-level language for this request. */
|
|
420
|
-
language?: string;
|
|
421
|
-
/** Cancels the request. */
|
|
422
|
-
signal?: AbortSignal;
|
|
423
|
-
};
|
|
424
|
-
type UseYarrowRoutingResult = {
|
|
425
|
-
/** Renderable route features — feed straight into `<RouteLayer routes={…}>`. */
|
|
426
|
-
routes: RouteFeature[];
|
|
427
|
-
/** Turn-by-turn directions per route. */
|
|
428
|
-
directions: RouteDirection[][];
|
|
429
|
-
/** Duration/distance/profile summary of the best route, when present. */
|
|
430
|
-
meta: RoutesMeta | null;
|
|
431
|
-
isLoading: boolean;
|
|
432
|
-
error: Error | null;
|
|
433
|
-
/** Fetches routes and stores them in state. Rejects on network failure —
|
|
434
|
-
* "no route found" resolves to an empty result instead. */
|
|
435
|
-
buildRoute: (input: BuildRouteInput) => Promise<FetchRoutesResult>;
|
|
436
|
-
/** Clears routes/directions/meta and any error. */
|
|
437
|
-
clearRoutes: () => void;
|
|
438
|
-
};
|
|
439
|
-
/**
|
|
440
|
-
* Headless routing state for the Yarrow routing API — pairs with
|
|
441
|
-
* `<RouteLayer>` for rendering.
|
|
442
|
-
*
|
|
443
|
-
* ```tsx
|
|
444
|
-
* const { routes, isLoading, buildRoute } = useYarrowRouting({ profile: 'driving' });
|
|
445
|
-
* <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
|
|
446
|
-
* <RouteLayer routes={routes} />
|
|
447
|
-
* </YarrowMapView>
|
|
448
|
-
* ```
|
|
449
|
-
*/
|
|
450
|
-
export declare const useYarrowRouting: (options?: UseYarrowRoutingOptions) => UseYarrowRoutingResult;
|
|
451
|
-
/** Icon registry: sprite name (e.g. `"school"`) → image URL. */
|
|
452
|
-
type YarrowIconsMap = Record<string, string>;
|
|
453
|
-
/**
|
|
454
|
-
* Fetches the Yarrow icon registry (`/icons-image`) and reduces it to a
|
|
455
|
-
* name → URL map. Native has no Cache Storage, so the result is not persisted
|
|
456
|
-
* — `<YarrowMapView>` fetches it once per mount when icons are enabled.
|
|
457
|
-
*
|
|
458
|
-
* Also seeds core's API-key module state (like every standalone client), so
|
|
459
|
-
* the key is current even if the hook runs before a map mounts.
|
|
460
|
-
*/
|
|
461
|
-
export declare function fetchYarrowIcons(apiKey?: string): Promise<YarrowIconsMap>;
|
|
462
|
-
/**
|
|
463
|
-
* Best-effort icon URL for a search-result `category.name` / tile
|
|
464
|
-
* `node_type`. The registry is keyed by sprite names, which usually match
|
|
465
|
-
* category names — the same fallback the web SDK applies via its icon
|
|
466
|
-
* expression.
|
|
467
|
-
*/
|
|
468
|
-
export declare function resolveCategoryIcon(iconsByName: YarrowIconsMap | undefined, name: string | undefined): string | undefined;
|
|
469
|
-
type YarrowImagesProps = {
|
|
470
|
-
/** Icon registry entries to add to the style: sprite name → image URL. */
|
|
471
|
-
iconsByName: YarrowIconsMap;
|
|
472
|
-
/**
|
|
473
|
-
* Fired when the style references an icon the registry doesn't cover —
|
|
474
|
-
* the map should re-fetch the registry (once) to recover.
|
|
475
|
-
*/
|
|
476
|
-
onMissingIcon?: (name: string) => void;
|
|
477
|
-
};
|
|
478
|
-
/**
|
|
479
|
-
* Adds the Yarrow icon images to the native style so symbol layers can
|
|
480
|
-
* resolve their `icon-image` names — the native counterpart of the web SDK's
|
|
481
|
-
* `addIconsToMap` prefetch plus its missing-image resolver. `Images` accepts
|
|
482
|
-
* remote URLs and downloads them natively; `onImageMissing` covers icons
|
|
483
|
-
* referenced before the registry fetch lands or after a failed fetch.
|
|
484
|
-
*/
|
|
485
|
-
export declare const YarrowImages: import("react").MemoExoticComponent<({ iconsByName, onMissingIcon }: YarrowImagesProps) => import("react/jsx-runtime").JSX.Element>;
|
|
486
|
-
/**
|
|
487
|
-
* Configuration for the React Native map — the `container`-free counterpart
|
|
488
|
-
* of the web SDK's `YarrowMapConfigOptions`. The native view is sized by the
|
|
489
|
-
* consuming component's layout, so there is no container to name.
|
|
490
|
-
*/
|
|
491
|
-
type YarrowMapConfigOptions = {
|
|
492
|
-
/** Yarrow API key from the dashboard. Required. */
|
|
493
|
-
apiKey: string;
|
|
494
|
-
/** Initial map center as `[longitude, latitude]`, e.g. Tashkent. */
|
|
495
|
-
center: [number, number];
|
|
496
|
-
/** Initial zoom level. Default `10`. */
|
|
497
|
-
zoom?: number;
|
|
498
|
-
/** Minimum zoom level. Default `0`. */
|
|
499
|
-
minZoom?: number;
|
|
500
|
-
/** Maximum zoom level. Default `19`. */
|
|
501
|
-
maxZoom?: number;
|
|
502
|
-
/** Style theme. Default `"light"`. */
|
|
503
|
-
theme?: 'light' | 'dark';
|
|
504
|
-
/** Base style. Default `"default"` (street map). */
|
|
505
|
-
styleType?: YarrowStyleType;
|
|
506
|
-
};
|
|
507
|
-
/**
|
|
508
|
-
* Validated, defaulted RN map configuration. Mirrors the web SDK's
|
|
509
|
-
* `YarrowMapConfig` minus the DOM container (the native view is sized by the
|
|
510
|
-
* consuming app's layout) and minus web-only rendering options (hover,
|
|
511
|
-
* clustering, controls, tile cache — none of which exist on native).
|
|
512
|
-
*/
|
|
513
|
-
export declare class YarrowMapConfig {
|
|
514
|
-
readonly center: [number, number];
|
|
515
|
-
readonly zoom: number;
|
|
516
|
-
readonly minZoom: number;
|
|
517
|
-
readonly maxZoom: number;
|
|
518
|
-
theme: 'light' | 'dark';
|
|
519
|
-
styleType: YarrowStyleType;
|
|
520
|
-
apiKey: string;
|
|
521
|
-
constructor(config: YarrowMapConfigOptions);
|
|
522
|
-
}
|
|
523
|
-
type RoutePressEvent = NativeSyntheticEvent<PressEventWithFeatures>;
|
|
524
|
-
/**
|
|
525
|
-
* Called when a rendered route is pressed, with the press event (carrying the
|
|
526
|
-
* GeoJSON feature) and the route's index in the `routes` array.
|
|
527
|
-
*/
|
|
528
|
-
type RoutePressHandler = (event: RoutePressEvent, routeIndex: number) => void;
|
|
529
|
-
type RouteLayerProps = {
|
|
530
|
-
/** Route line features — feed with `useYarrowRouting().routes` or your own
|
|
531
|
-
* `fetchRoutes()` result. Best route renders bold; the rest as fainter,
|
|
532
|
-
* thinner alternatives. */
|
|
533
|
-
routes: RouteFeature[];
|
|
534
|
-
/** Index of the route to highlight. Default `0`. */
|
|
535
|
-
bestIndex?: number;
|
|
536
|
-
/** Best-route color. Default `#22c55e`. */
|
|
537
|
-
routeColor?: string;
|
|
538
|
-
/** Best-route line width. Default `5`. */
|
|
539
|
-
routeWidth?: number;
|
|
540
|
-
/** Best-route opacity. Default `1`. */
|
|
541
|
-
routeOpacity?: number;
|
|
542
|
-
/** Alternative-route color. Default `#aaaaaa` — every alternative shares
|
|
543
|
-
* it, matching the web SDK's `buildRoute()`. */
|
|
544
|
-
alternativeColor?: string;
|
|
545
|
-
/** Alternative-route line width. Default `2.5`. */
|
|
546
|
-
alternativeWidth?: number;
|
|
547
|
-
/** Alternative-route opacity. Default `0.5`. */
|
|
548
|
-
alternativeOpacity?: number;
|
|
549
|
-
/** Prefix for source/layer ids. Default `"yarrow-route"`. */
|
|
550
|
-
layerPrefix?: string;
|
|
551
|
-
/** Called when a rendered route line is pressed. */
|
|
552
|
-
onPressRoute?: RoutePressHandler;
|
|
553
|
-
/**
|
|
554
|
-
* Distinct-series mode — web `renderRoutes()` parity. Every route draws in
|
|
555
|
-
* its own color from the shared `ROUTE_COLORS` palette (cycled), width 4
|
|
556
|
-
* and opacity 0.8, with no best/alternative distinction; the
|
|
557
|
-
* `bestIndex`/route/alternative style props are ignored.
|
|
558
|
-
*/
|
|
559
|
-
distinct?: boolean;
|
|
560
|
-
};
|
|
561
|
-
/**
|
|
562
|
-
* Declarative route rendering: one GeoJSON source + line layer per route.
|
|
563
|
-
* Compose inside `<YarrowMapView>` and drive it with `useYarrowRouting()`:
|
|
564
|
-
*
|
|
565
|
-
* ```tsx
|
|
566
|
-
* const { routes } = useYarrowRouting();
|
|
567
|
-
* <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
|
|
568
|
-
* <RouteLayer routes={routes} onPressRoute={…} />
|
|
569
|
-
* </YarrowMapView>
|
|
570
|
-
* ```
|
|
571
|
-
*
|
|
572
|
-
* Pass `distinct` to render independent series instead of best-route-plus-
|
|
573
|
-
* alternatives — the declarative counterpart of the web SDK's
|
|
574
|
-
* `renderRoutes()`.
|
|
575
|
-
*/
|
|
576
|
-
export declare const RouteLayer: import("react").MemoExoticComponent<({ routes, bestIndex, routeColor, routeWidth, routeOpacity, alternativeColor, alternativeWidth, alternativeOpacity, layerPrefix, onPressRoute, distinct }: RouteLayerProps) => import("react/jsx-runtime").JSX.Element[]>;
|
|
577
|
-
/**
|
|
578
|
-
* Full style URL for MapLibre React Native's `mapStyle` prop, built from the
|
|
579
|
-
* platform-agnostic style endpoint plus the configured API key. The key comes
|
|
580
|
-
* from core's module state (`setYarrowApiKey`) — `YarrowMapView` calls it for
|
|
581
|
-
* you; standalone callers must set it first.
|
|
582
|
-
*/
|
|
583
|
-
export declare function buildStyleUrl(styleType?: string, theme?: 'light' | 'dark'): string;
|
|
584
|
-
type YarrowMapViewProps = YarrowMapConfigOptions & {
|
|
585
|
-
/** Called once the native map finished loading its style. */
|
|
586
|
-
onReady?: (map: MapRef$1) => void;
|
|
587
|
-
/** Called when the style fails to load. */
|
|
588
|
-
onLoadError?: (error: Error) => void;
|
|
589
|
-
/** Called when the user presses the map (bubbles up from pressable
|
|
590
|
-
* sources unless they call `event.stopPropagation()`). */
|
|
591
|
-
onPress?: MapProps['onPress'];
|
|
592
|
-
/**
|
|
593
|
-
* Called when the camera finishes moving — web `onMoveEnd` parity:
|
|
594
|
-
* `(lat, lng, zoom)`.
|
|
595
|
-
*/
|
|
596
|
-
onMoveEnd?: (lat: number, lng: number, zoom: number) => void;
|
|
597
|
-
/** Forwarded to the inner camera — use it for `flyTo`/`fitBounds`/`zoomTo`.
|
|
598
|
-
* The outer component ref is the `MapRef` (getCenter, queryRenderedFeatures…). */
|
|
599
|
-
cameraRef?: Ref<CameraRef$1>;
|
|
600
|
-
/** Attribution button. Default `true`. */
|
|
601
|
-
attribution?: boolean;
|
|
602
|
-
/** MapLibre logo. Default `true`. */
|
|
603
|
-
logo?: boolean;
|
|
604
|
-
/** Compass ornament. Default `true`. */
|
|
605
|
-
compass?: boolean;
|
|
606
|
-
/** Fire-and-forget DAU ping when the style first loads. Default `true`. */
|
|
607
|
-
dauTracking?: boolean;
|
|
608
|
-
/**
|
|
609
|
-
* Fetch the Yarrow icon registry and add it to the style so POI symbols and
|
|
610
|
-
* category-icon fallbacks work (web icon-pipeline parity). Disable only if
|
|
611
|
-
* your style/labels don't need the Yarrow icons. Default `true`.
|
|
612
|
-
*/
|
|
613
|
-
icons?: boolean;
|
|
614
|
-
/** Style for the wrapping native view. Default `{ flex: 1 }`. */
|
|
615
|
-
style?: ViewProps['style'];
|
|
616
|
-
/** Sources/layers/markers rendered inside the map. */
|
|
617
|
-
children?: ReactNode;
|
|
618
|
-
};
|
|
619
|
-
/**
|
|
620
|
-
* React Native Yarrow map. Renders MapLibre Native with a Yarrow style URL
|
|
621
|
-
* (theme + styleType aware, API key attached) and a default camera, and
|
|
622
|
-
* provides the runtime (refs, icon registry, camera/event subscriptions) to
|
|
623
|
-
* the SDK layers rendered inside it.
|
|
624
|
-
*
|
|
625
|
-
* ```tsx
|
|
626
|
-
* const mapRef = useRef<MapRef>(null);
|
|
627
|
-
* <YarrowMapView
|
|
628
|
-
* apiKey="YOUR_API_KEY"
|
|
629
|
-
* center={[69.2401, 41.2995]} // Tashkent
|
|
630
|
-
* zoom={12}
|
|
631
|
-
* theme="dark"
|
|
632
|
-
* onReady={(map) => map.getCenter().then(console.log)}
|
|
633
|
-
* />
|
|
634
|
-
* ```
|
|
635
|
-
*
|
|
636
|
-
* Camera props (`center`, `zoom`) apply only on mount — recenter through
|
|
637
|
-
* `cameraRef` (`flyTo`, `jumpTo`, `fitBounds`). Theme and styleType changes
|
|
638
|
-
* hot-swap the style URL natively.
|
|
639
|
-
*/
|
|
640
|
-
export declare const YarrowMapView: import("react").ForwardRefExoticComponent<YarrowMapConfigOptions & {
|
|
641
|
-
/** Called once the native map finished loading its style. */
|
|
642
|
-
onReady?: (map: MapRef$1) => void;
|
|
643
|
-
/** Called when the style fails to load. */
|
|
644
|
-
onLoadError?: (error: Error) => void;
|
|
645
|
-
/** Called when the user presses the map (bubbles up from pressable
|
|
646
|
-
* sources unless they call `event.stopPropagation()`). */
|
|
647
|
-
onPress?: MapProps['onPress'];
|
|
648
|
-
/**
|
|
649
|
-
* Called when the camera finishes moving — web `onMoveEnd` parity:
|
|
650
|
-
* `(lat, lng, zoom)`.
|
|
651
|
-
*/
|
|
652
|
-
onMoveEnd?: (lat: number, lng: number, zoom: number) => void;
|
|
653
|
-
/** Forwarded to the inner camera — use it for `flyTo`/`fitBounds`/`zoomTo`.
|
|
654
|
-
* The outer component ref is the `MapRef` (getCenter, queryRenderedFeatures…). */
|
|
655
|
-
cameraRef?: Ref<CameraRef$1>;
|
|
656
|
-
/** Attribution button. Default `true`. */
|
|
657
|
-
attribution?: boolean;
|
|
658
|
-
/** MapLibre logo. Default `true`. */
|
|
659
|
-
logo?: boolean;
|
|
660
|
-
/** Compass ornament. Default `true`. */
|
|
661
|
-
compass?: boolean;
|
|
662
|
-
/** Fire-and-forget DAU ping when the style first loads. Default `true`. */
|
|
663
|
-
dauTracking?: boolean;
|
|
664
|
-
/**
|
|
665
|
-
* Fetch the Yarrow icon registry and add it to the style so POI symbols and
|
|
666
|
-
* category-icon fallbacks work (web icon-pipeline parity). Disable only if
|
|
667
|
-
* your style/labels don't need the Yarrow icons. Default `true`.
|
|
668
|
-
*/
|
|
669
|
-
icons?: boolean;
|
|
670
|
-
/** Style for the wrapping native view. Default `{ flex: 1 }`. */
|
|
671
|
-
style?: ViewProps['style'];
|
|
672
|
-
/** Sources/layers/markers rendered inside the map. */
|
|
673
|
-
children?: ReactNode;
|
|
674
|
-
} & import("react").RefAttributes<MapRef$1>>;
|
|
675
|
-
type HighlightMarkerViewProps = {
|
|
676
|
-
/** Coordinates as `[longitude, latitude]`. */
|
|
677
|
-
lngLat: [number, number];
|
|
678
|
-
/** Icon URL; when absent a blue dot is rendered (web parity). */
|
|
679
|
-
iconUrl?: string;
|
|
680
|
-
/** Label rendered under the icon. */
|
|
681
|
-
title?: string;
|
|
682
|
-
/** Icon size in points: a number (square) or `[width, height]`. Default 56. */
|
|
683
|
-
iconSize?: number | [number, number];
|
|
684
|
-
/** Plays the exit animation instead of the enter one. */
|
|
685
|
-
leaving?: boolean;
|
|
686
|
-
onPress?: () => void;
|
|
687
|
-
};
|
|
688
|
-
/**
|
|
689
|
-
* The animated icon+label marker shared by `<PoiHighlightLayer>` and
|
|
690
|
-
* `<SearchResultsLayer>` — the native counterpart of the web SDK's
|
|
691
|
-
* `createMarkerElement` + enter/exit CSS transitions. The scale/fade runs on
|
|
692
|
-
* an inner view (never on the `Marker` itself, which the map repositions
|
|
693
|
-
* every frame).
|
|
694
|
-
*/
|
|
695
|
-
export declare const HighlightMarkerView: import("react").MemoExoticComponent<({ lngLat, iconUrl, title, iconSize, leaving, onPress }: HighlightMarkerViewProps) => import("react/jsx-runtime").JSX.Element>;
|
|
696
|
-
type YarrowMarkerProps = {
|
|
697
|
-
/** Coordinates as `[longitude, latitude]`. */
|
|
698
|
-
lngLat: [number, number];
|
|
699
|
-
/** Which part of the marker sits on the coordinate. Default `'bottom'`. */
|
|
700
|
-
anchor?: MarkerProps['anchor'];
|
|
701
|
-
/** Pixel offset `[x, y]` applied relative to the anchor. */
|
|
702
|
-
offset?: [number, number];
|
|
703
|
-
/** Called when the marker is pressed. */
|
|
704
|
-
onPress?: () => void;
|
|
705
|
-
/** Marker content — a single view (icon, label, bubble, …). */
|
|
706
|
-
children: ReactElement;
|
|
707
|
-
};
|
|
708
|
-
/**
|
|
709
|
-
* Declarative counterpart of the web SDK's `addMarker()` / `removeMarker()`.
|
|
710
|
-
* Mounting places the marker, unmounting removes it; the React lifecycle
|
|
711
|
-
* replaces the imperative manager pair.
|
|
712
|
-
*
|
|
713
|
-
* ```tsx
|
|
714
|
-
* <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
|
|
715
|
-
* <YarrowMarker lngLat={[69.2401, 41.2995]} onPress={() => …}>
|
|
716
|
-
* <PinIcon />
|
|
717
|
-
* </YarrowMarker>
|
|
718
|
-
* </YarrowMapView>
|
|
719
|
-
* ```
|
|
720
|
-
*/
|
|
721
|
-
export declare const YarrowMarker: import("react").MemoExoticComponent<({ lngLat, anchor, offset, onPress, children }: YarrowMarkerProps) => import("react/jsx-runtime").JSX.Element>;
|
|
722
|
-
type ZoomToOptions = {
|
|
723
|
-
/** Animation duration in ms. Web's `speed` option has no native equivalent. */
|
|
724
|
-
duration?: number;
|
|
725
|
-
};
|
|
726
|
-
type FitBoundsOptions = {
|
|
727
|
-
/** Padding in points around the fitted bounds. Default `50`. */
|
|
728
|
-
padding?: number;
|
|
729
|
-
/** Animation duration in ms. Default `1000`. */
|
|
730
|
-
duration?: number;
|
|
731
|
-
};
|
|
732
|
-
type YarrowCamera = {
|
|
733
|
-
/** Flies the camera to a coordinate at `zoom`. */
|
|
734
|
-
zoomTo(lat: number, lng: number, zoom: number, options?: ZoomToOptions): void;
|
|
735
|
-
/**
|
|
736
|
-
* Fits the camera to the bounds of a GeoJSON FeatureCollection. Applies the
|
|
737
|
-
* web SDK's minimum-dimension expansion (0.003°) so single points don't
|
|
738
|
-
* over-zoom. Web's `maxZoom` cap is not supported natively.
|
|
739
|
-
*/
|
|
740
|
-
fitBounds(data: BoundsInput, options?: FitBoundsOptions): void;
|
|
741
|
-
/** Computes the geographic bounding box of a FeatureCollection. */
|
|
742
|
-
getBoundingBox(data: BoundsInput): BoundingBox;
|
|
743
|
-
};
|
|
744
|
-
/**
|
|
745
|
-
* Web-parity camera helpers on top of a `CameraRef`. Reads the enclosing
|
|
746
|
-
* `<YarrowMapView>` camera when called inside the map; otherwise pass a ref:
|
|
747
|
-
*
|
|
748
|
-
* ```tsx
|
|
749
|
-
* const cameraRef = useRef<CameraRef>(null);
|
|
750
|
-
* <YarrowMapView apiKey={KEY} cameraRef={cameraRef}>…</YarrowMapView>
|
|
751
|
-
* const camera = useYarrowCamera(cameraRef);
|
|
752
|
-
* camera.zoomTo(41.2995, 69.2401, 14);
|
|
753
|
-
* ```
|
|
754
|
-
*/
|
|
755
|
-
export declare function useYarrowCamera(cameraRefInput?: RefObject<CameraRef$1 | null>): YarrowCamera;
|
|
756
|
-
/** Download progress of an offline region (normalized native pack status). */
|
|
757
|
-
type OfflineRegionProgress = Omit<OfflinePackStatus, 'id'>;
|
|
758
|
-
/**
|
|
759
|
-
* Geographic bounds as `[west, south, east, north]` — the flat corner order
|
|
760
|
-
* MapLibre React Native's `LngLatBounds` uses.
|
|
761
|
-
*/
|
|
762
|
-
type OfflineBounds = [west: number, south: number, east: number, north: number];
|
|
763
|
-
type OfflineRegionDownloadOptions = {
|
|
764
|
-
/**
|
|
765
|
-
* Unique region name. Re-downloading an existing name returns the stored
|
|
766
|
-
* pack instead of creating a duplicate; a different name is required per
|
|
767
|
-
* style combination.
|
|
768
|
-
*/
|
|
769
|
-
name: string;
|
|
770
|
-
/** Region bounds as `[west, south, east, north]`. */
|
|
771
|
-
bounds: OfflineBounds;
|
|
772
|
-
/** Lowest zoom level to pack. Default `8`. */
|
|
773
|
-
minZoom?: number;
|
|
774
|
-
/** Highest zoom level to pack. Default `15`. */
|
|
775
|
-
maxZoom?: number;
|
|
776
|
-
/** Style the pack pins. Default `"default"`. Offline style swaps only
|
|
777
|
-
* work for styles that were packed. */
|
|
778
|
-
styleType?: YarrowStyleType;
|
|
779
|
-
/** Theme the pack pins. Default `"light"`. */
|
|
780
|
-
theme?: 'light' | 'dark';
|
|
781
|
-
/**
|
|
782
|
-
* Days after which `listRegions()` flags the region `isStale`. Unlike the
|
|
783
|
-
* web cache there is no native TTL — staleness is informational; refresh
|
|
784
|
-
* with `handle.invalidate()`. Default `null` (never stale).
|
|
785
|
-
*/
|
|
786
|
-
maxAgeDays?: number | null;
|
|
787
|
-
/** Delete and re-download an existing region with this name. Default `false`. */
|
|
788
|
-
force?: boolean;
|
|
789
|
-
/** Extra app-specific data stored alongside the region metadata, readable
|
|
790
|
-
* back via `listRegions()` → `userMetadata`. JSON-serializable only —
|
|
791
|
-
* native stores metadata as a JSON string. */
|
|
792
|
-
metadata?: Record<string, unknown>;
|
|
793
|
-
/** Progress while the region downloads. */
|
|
794
|
-
onProgress?: (progress: OfflineRegionProgress) => void;
|
|
795
|
-
/** Download failure. Fatal for the region — call `handle.resume()` to retry. */
|
|
796
|
-
onError?: (error: YarrowOfflineError) => void;
|
|
797
|
-
};
|
|
798
|
-
type OfflineRegionErrorCode =
|
|
799
|
-
/** The name exists with different parameters than the stored pack. */
|
|
800
|
-
'params-mismatch' |
|
|
801
|
-
/** The region is too large for the native offline system. */
|
|
802
|
-
'region-too-large' |
|
|
803
|
-
/** The native tile-count limit was hit (see `setTileCountLimit`). */
|
|
804
|
-
'tile-count-limit-exceeded' | 'network' | 'disk' |
|
|
805
|
-
/** A handle referenced a region that no longer exists. */
|
|
806
|
-
'not-found' | 'unknown';
|
|
807
|
-
type YarrowOfflineError = Error & {
|
|
808
|
-
code: OfflineRegionErrorCode;
|
|
809
|
-
/** Native pack id, when the error is tied to a region. */
|
|
810
|
-
regionId?: string;
|
|
811
|
-
};
|
|
812
|
-
type OfflineRegionSummary = {
|
|
813
|
-
id: string;
|
|
814
|
-
name: string;
|
|
815
|
-
styleType: YarrowStyleType;
|
|
816
|
-
theme: 'light' | 'dark';
|
|
817
|
-
bounds: OfflineBounds;
|
|
818
|
-
minZoom: number;
|
|
819
|
-
maxZoom: number;
|
|
820
|
-
status: OfflineRegionProgress['state'];
|
|
821
|
-
/** Download percentage, 0–100. */
|
|
822
|
-
percentage: number;
|
|
823
|
-
/** Bytes of tiles stored so far. */
|
|
824
|
-
completedTileSize: number;
|
|
825
|
-
/** True when `maxAgeDays` has elapsed since `createdAt`. */
|
|
826
|
-
isStale: boolean;
|
|
827
|
-
/** Epoch ms when the region was created. */
|
|
828
|
-
createdAt: number;
|
|
829
|
-
/** The `metadata` the app passed to `downloadRegion`, if any. */
|
|
830
|
-
userMetadata?: Record<string, unknown>;
|
|
831
|
-
};
|
|
832
|
-
type OfflineRegionHandle = {
|
|
833
|
-
/** Native pack id (UUID). */
|
|
834
|
-
id: string;
|
|
835
|
-
name: string;
|
|
836
|
-
/**
|
|
837
|
-
* Resolves with the final progress on completion, rejects with a
|
|
838
|
-
* `YarrowOfflineError` on the first download failure. It stays rejected
|
|
839
|
-
* after that — retry with `resume()` and track recovery through
|
|
840
|
-
* `onProgress` / `refreshStatus()` instead of awaiting `done` again.
|
|
841
|
-
*/
|
|
842
|
-
done: Promise<OfflineRegionProgress>;
|
|
843
|
-
/** Current status snapshot from the native layer. */
|
|
844
|
-
refreshStatus: () => Promise<OfflineRegionProgress>;
|
|
845
|
-
pause: () => Promise<void>;
|
|
846
|
-
resume: () => Promise<void>;
|
|
847
|
-
/** Revalidates stored tiles against the server and re-fetches changed
|
|
848
|
-
* ones — the cheap refresh path. */
|
|
849
|
-
invalidate: () => Promise<void>;
|
|
850
|
-
delete: () => Promise<void>;
|
|
851
|
-
};
|
|
852
|
-
type OfflineRegionEstimate = {
|
|
853
|
-
/** Unique `z/x/y` tiles across `[minZoom, maxZoom]`. Each style downloads
|
|
854
|
-
* one tile per source (≈12 vector sources, satellite adds a raster one),
|
|
855
|
-
* so network/storage cost scales with the style's source count too. */
|
|
856
|
-
tileCount: number;
|
|
857
|
-
/** Rough storage estimate: `tileCount × avgTileBytes`. */
|
|
858
|
-
estSizeBytes: number;
|
|
859
|
-
tilesPerLevel: Array<{
|
|
860
|
-
zoom: number;
|
|
861
|
-
tiles: number;
|
|
862
|
-
}>;
|
|
863
|
-
};
|
|
864
|
-
/** Default minimum zoom for offline regions. */
|
|
865
|
-
export declare const DEFAULT_OFFLINE_MIN_ZOOM = 8;
|
|
866
|
-
/** Default maximum zoom for offline regions. */
|
|
867
|
-
export declare const DEFAULT_OFFLINE_MAX_ZOOM = 15;
|
|
868
|
-
/** Schema version of the pack metadata this SDK writes. */
|
|
869
|
-
export declare const OFFLINE_METADATA_VERSION = 1;
|
|
870
|
-
/**
|
|
871
|
-
* Rough bytes per downloaded `z/x/y` tile, empirically measured from a
|
|
872
|
-
* Tashkent z14 tile: ≈64 KB × ~8 sources carrying data ≈ 0.5 MB. A region's
|
|
873
|
-
* true size depends on the style's source count and local data density —
|
|
874
|
-
* pass `avgTileBytes` for a tighter estimate.
|
|
875
|
-
*/
|
|
876
|
-
export declare const AVG_TILE_BYTES = 500000;
|
|
877
|
-
type EstimateRegionInput = {
|
|
878
|
-
bounds: OfflineBounds;
|
|
879
|
-
minZoom: number;
|
|
880
|
-
maxZoom: number;
|
|
881
|
-
/** Bytes per `z/x/y` tile used for the size estimate. Default `500_000`. */
|
|
882
|
-
avgTileBytes?: number;
|
|
883
|
-
};
|
|
884
|
-
/**
|
|
885
|
-
* Estimates the download/storage cost of an offline region — pure tile math,
|
|
886
|
-
* no native calls. Tile counts are exact for the XYZ scheme; byte estimates
|
|
887
|
-
* are rough (see `AVG_TILE_BYTES`).
|
|
888
|
-
*
|
|
889
|
-
* ```ts
|
|
890
|
-
* const { tileCount, estSizeBytes } = estimateRegion({
|
|
891
|
-
* bounds: [69.15, 41.2, 69.4, 41.4], // Tashkent
|
|
892
|
-
* minZoom: 8,
|
|
893
|
-
* maxZoom: 15,
|
|
894
|
-
* });
|
|
895
|
-
* ```
|
|
896
|
-
*/
|
|
897
|
-
export declare const estimateRegion: (input: EstimateRegionInput) => OfflineRegionEstimate;
|
|
898
|
-
type UseYarrowOfflineRegionsOptions = {
|
|
899
|
-
/** Yarrow API key from the dashboard. Required. */
|
|
900
|
-
apiKey: string;
|
|
901
|
-
/** Poll interval while any region is downloading, ms. Default `1000`. */
|
|
902
|
-
pollMs?: number;
|
|
903
|
-
};
|
|
904
|
-
type UseYarrowOfflineRegionsResult = {
|
|
905
|
-
/** All regions created through the SDK, newest first. */
|
|
906
|
-
regions: OfflineRegionSummary[];
|
|
907
|
-
/** True during the initial `listRegions()` load. */
|
|
908
|
-
isLoading: boolean;
|
|
909
|
-
error: Error | null;
|
|
910
|
-
/** Re-reads regions from the native layer. */
|
|
911
|
-
refresh: () => Promise<void>;
|
|
912
|
-
/** Starts a region download (idempotent by `name` — see
|
|
913
|
-
* `YarrowOfflineManager.downloadRegion`). */
|
|
914
|
-
download: (options: OfflineRegionDownloadOptions) => Promise<OfflineRegionHandle>;
|
|
915
|
-
pause: (name: string) => Promise<void>;
|
|
916
|
-
resume: (name: string) => Promise<void>;
|
|
917
|
-
/** Revalidates stored tiles against the server — the cheap refresh path. */
|
|
918
|
-
invalidate: (name: string) => Promise<void>;
|
|
919
|
-
remove: (name: string) => Promise<void>;
|
|
920
|
-
};
|
|
921
|
-
/**
|
|
922
|
-
* Offline region state for settings/offline screens — pairs with
|
|
923
|
-
* `YarrowOfflineManager`. Polls the native layer while downloads run, so
|
|
924
|
-
* `regions` (and progress bars) stay current.
|
|
925
|
-
*
|
|
926
|
-
* ```tsx
|
|
927
|
-
* const { regions, download, remove } = useYarrowOfflineRegions({ apiKey });
|
|
928
|
-
* await download({ name: 'tashkent', bounds: [69.15, 41.2, 69.4, 41.4] });
|
|
929
|
-
* ```
|
|
930
|
-
*/
|
|
931
|
-
export declare const useYarrowOfflineRegions: (options: UseYarrowOfflineRegionsOptions) => UseYarrowOfflineRegionsResult;
|
|
932
|
-
type YarrowOfflineManagerOptions = {
|
|
933
|
-
/** Yarrow API key from the dashboard. Required. */
|
|
934
|
-
apiKey: string;
|
|
935
|
-
};
|
|
936
|
-
/**
|
|
937
|
-
* Offline region manager for React Native — a Yarrow-flavoured wrapper around
|
|
938
|
-
* MapLibre React Native's `OfflineManager`.
|
|
939
|
-
*
|
|
940
|
-
* The web SDK's `yarrowcache` protocol cannot exist on native (no
|
|
941
|
-
* `addProtocol`), so offline support here is region packs: pick a bounding
|
|
942
|
-
* box and zoom range, download it once, and the map renders from the native
|
|
943
|
-
* offline database with no network.
|
|
944
|
-
*
|
|
945
|
-
* ```ts
|
|
946
|
-
* const offline = new YarrowOfflineManager({ apiKey: 'YOUR_API_KEY' });
|
|
947
|
-
* const { tileCount, estSizeBytes } = offline.estimateRegion({
|
|
948
|
-
* bounds: [69.15, 41.2, 69.4, 41.4], // Tashkent
|
|
949
|
-
* minZoom: 8,
|
|
950
|
-
* maxZoom: 15,
|
|
951
|
-
* });
|
|
952
|
-
* const region = await offline.downloadRegion({
|
|
953
|
-
* name: 'tashkent-city',
|
|
954
|
-
* bounds: [69.15, 41.2, 69.4, 41.4],
|
|
955
|
-
* maxAgeDays: 30,
|
|
956
|
-
* onProgress: (p) => console.log(`${p.percentage}%`),
|
|
957
|
-
* });
|
|
958
|
-
* await region.done;
|
|
959
|
-
* ```
|
|
960
|
-
*/
|
|
961
|
-
export declare class YarrowOfflineManager {
|
|
962
|
-
private readonly apiKey;
|
|
963
|
-
/**
|
|
964
|
-
* Downloads this session created, keyed by pack id. MLRN's listener maps
|
|
965
|
-
* are last-write-wins, so re-attaching listeners over a live download
|
|
966
|
-
* would strand the original handle — `reattachExisting` consults this map
|
|
967
|
-
* and reuses the original `done` instead.
|
|
968
|
-
*/
|
|
969
|
-
private readonly activeDownloads;
|
|
970
|
-
constructor(options: YarrowOfflineManagerOptions);
|
|
971
|
-
/**
|
|
972
|
-
* Pure tile-math estimate of a region's download/storage cost — no native
|
|
973
|
-
* calls. See `estimateRegion` for the math and caveats.
|
|
974
|
-
*/
|
|
975
|
-
estimateRegion(input: Parameters<typeof estimateRegion>[0]): OfflineRegionEstimate;
|
|
976
|
-
/**
|
|
977
|
-
* Starts (or resumes) a region download. Resolves with a handle once the
|
|
978
|
-
* pack is created and downloading — progress arrives via `options.onProgress`
|
|
979
|
-
* and `handle.done` settles with the outcome.
|
|
980
|
-
*
|
|
981
|
-
* Idempotent by `name`: an existing matching region is returned as-is
|
|
982
|
-
* (resumed when incomplete); a name reused with different parameters throws
|
|
983
|
-
* a `params-mismatch` error. Pass `force: true` to delete and re-download.
|
|
984
|
-
*/
|
|
985
|
-
downloadRegion(options: OfflineRegionDownloadOptions): Promise<OfflineRegionHandle>;
|
|
986
|
-
/** Lists regions created through this SDK (native packs created directly
|
|
987
|
-
* against `OfflineManager` are not included), newest first. */
|
|
988
|
-
listRegions(): Promise<OfflineRegionSummary[]>;
|
|
989
|
-
/** Returns the handle for a region by name, or `null`. */
|
|
990
|
-
getRegion(name: string): Promise<OfflineRegionHandle | null>;
|
|
991
|
-
/** Ambient cache (seen-tiles LRU) max size in bytes. May erase resources
|
|
992
|
-
* when shrinking — call once at app startup. `0` disables the cache. */
|
|
993
|
-
setAmbientCacheSize(size: number): Promise<void>;
|
|
994
|
-
/** Revalidates ambient-cache tiles against the server — the recommended
|
|
995
|
-
* way to refresh cached data. */
|
|
996
|
-
invalidateAmbientCache(): Promise<void>;
|
|
997
|
-
/** Erases ambient-cache resources. Computationally expensive. */
|
|
998
|
-
clearAmbientCache(): Promise<void>;
|
|
999
|
-
/** Maximum number of tiles offline packs may store. Raise it when large
|
|
1000
|
-
* regions fail with a `tile-count-limit-exceeded` error. */
|
|
1001
|
-
setTileCountLimit(limit: number): void;
|
|
1002
|
-
/** Download status event throttle in ms. Platform-defined default (300 ms
|
|
1003
|
-
* today on both iOS and Android). Note errors bypass the throttle. */
|
|
1004
|
-
setProgressEventThrottle(ms: number): void;
|
|
1005
|
-
/** Deletes the offline database (ambient cache + packs), then
|
|
1006
|
-
* reinitializes it. Destructive — and MLRN's JS pack cache only clears
|
|
1007
|
-
* on app restart, so subsequent reads may hit stale ids (guarded as
|
|
1008
|
-
* `not-found`). Prefer per-region `invalidate`/`delete`. */
|
|
1009
|
-
resetDatabase(): Promise<void>;
|
|
1010
|
-
private hydrate;
|
|
1011
|
-
private findRegionPacks;
|
|
1012
|
-
private findParamMismatches;
|
|
1013
|
-
/** Attaches listeners to a pack that may have outlived the JS layer
|
|
1014
|
-
* (created in a previous app session) and builds a fresh handle.
|
|
1015
|
-
*
|
|
1016
|
-
* Deliberately cautious: it never hijacks a download this session owns,
|
|
1017
|
-
* never attaches listeners to packs that don't need them, and — on
|
|
1018
|
-
* Android, where attaching an observer *activates* the region — never
|
|
1019
|
-
* wakes a paused pack unless the caller explicitly asked for a download. */
|
|
1020
|
-
private reattachExisting;
|
|
1021
|
-
private toHandle;
|
|
1022
|
-
private deletePack;
|
|
1023
|
-
}
|
|
1024
|
-
/** Coordinates the caller already holds (e.g. from a search result). */
|
|
1025
|
-
type PlaceLocation = {
|
|
1026
|
-
lat: number;
|
|
1027
|
-
lng: number;
|
|
1028
|
-
};
|
|
1029
|
-
/** Coordinates (+ optional icon URL and title) resolved before placing a marker. */
|
|
1030
|
-
type ResolvedPoiData = {
|
|
1031
|
-
lng: number;
|
|
1032
|
-
lat: number;
|
|
1033
|
-
iconUrl?: string;
|
|
1034
|
-
title?: string;
|
|
1035
|
-
};
|
|
1036
|
-
/** Payload passed to a highlight marker's press handler. */
|
|
1037
|
-
type PoiHighlightPressInfo = {
|
|
1038
|
-
/** The highlighted POI id. */
|
|
1039
|
-
id: number;
|
|
1040
|
-
lng: number;
|
|
1041
|
-
lat: number;
|
|
1042
|
-
/** Resolved title/icon of the marker, if any. */
|
|
1043
|
-
title?: string;
|
|
1044
|
-
iconUrl?: string;
|
|
1045
|
-
};
|
|
1046
|
-
/**
|
|
1047
|
-
* Per-id data the caller already holds. Anything provided here skips the
|
|
1048
|
-
* corresponding lookup (viewport query / place-detail API) — the cheapest
|
|
1049
|
-
* resolution wins, exactly like the web SDK's `HighlightPOIOptions`.
|
|
1050
|
-
*/
|
|
1051
|
-
type HighlightPoiData = {
|
|
1052
|
-
location?: PlaceLocation;
|
|
1053
|
-
icon?: string;
|
|
1054
|
-
title?: string;
|
|
1055
|
-
};
|
|
1056
|
-
type PoiHighlightLayerProps = {
|
|
1057
|
-
/** POI id(s) to highlight — the declarative selection state. */
|
|
1058
|
-
ids: number | number[];
|
|
1059
|
-
/**
|
|
1060
|
-
* Per-id data the caller already holds (location/icon/title). Anything
|
|
1061
|
-
* provided skips the corresponding lookup.
|
|
1062
|
-
*/
|
|
1063
|
-
dataById?: Record<number, HighlightPoiData>;
|
|
1064
|
-
/** Icon size in points: a number (square) or `[width, height]`. Default 56. */
|
|
1065
|
-
iconSize?: number | [number, number];
|
|
1066
|
-
/** Flies the camera to the highlighted POI(s) once resolved. Default `false`. */
|
|
1067
|
-
panTo?: boolean;
|
|
1068
|
-
/** Target zoom for `panTo` of a single POI. Default `13`. */
|
|
1069
|
-
zoom?: number;
|
|
1070
|
-
/** Clusters the highlight markers (`true` or a config object). */
|
|
1071
|
-
clustering?: ClusteringConfig;
|
|
1072
|
-
/** Called when a highlight marker is pressed. */
|
|
1073
|
-
onHighlightPress?: (info: PoiHighlightPressInfo) => void;
|
|
1074
|
-
/** Called when a POI could not be resolved (its highlight is rolled back). */
|
|
1075
|
-
onResolveError?: (id: number) => void;
|
|
1076
|
-
};
|
|
1077
|
-
/**
|
|
1078
|
-
* Declarative counterpart of the web SDK's `highlightPOI()`: renders an
|
|
1079
|
-
* animated icon+label marker for each highlighted POI id, resolving each id
|
|
1080
|
-
* cheapest-first (caller data → rendered tiles → place-detail API).
|
|
1081
|
-
* Highlight state is owned by the `ids` prop (or
|
|
1082
|
-
* `useYarrowPoiHighlight().highlightedIds`); removing an id plays the exit
|
|
1083
|
-
* animation and unmounts the marker.
|
|
1084
|
-
*
|
|
1085
|
-
* Known native limitation (documented in the README): the base style's own
|
|
1086
|
-
* POI icon is not hidden behind the highlight marker — native has no runtime
|
|
1087
|
-
* `setFilter`, so the marker simply draws on top of it.
|
|
1088
|
-
*
|
|
1089
|
-
* ```tsx
|
|
1090
|
-
* <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
|
|
1091
|
-
* <PoiHighlightLayer ids={[123]} dataById={{ 123: { location } }} panTo />
|
|
1092
|
-
* </YarrowMapView>
|
|
1093
|
-
* ```
|
|
1094
|
-
*/
|
|
1095
|
-
export declare function PoiHighlightLayer({ ids, dataById, iconSize, panTo, zoom, clustering, onHighlightPress, onResolveError }: PoiHighlightLayerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
1096
|
-
/** Camera state snapshot delivered to region-change subscribers. */
|
|
1097
|
-
type YarrowRegionState = {
|
|
1098
|
-
/** Map center as `[lng, lat]`. */
|
|
1099
|
-
center: [number, number];
|
|
1100
|
-
zoom: number;
|
|
1101
|
-
};
|
|
1102
|
-
/** A raw map press, delivered to press subscribers before `onPress` props. */
|
|
1103
|
-
type YarrowMapPress = {
|
|
1104
|
-
/** Press location as `[lng, lat]`. */
|
|
1105
|
-
lngLat: [number, number];
|
|
1106
|
-
/** Press location in viewport pixels `[x, y]` (for `queryRenderedFeatures`). */
|
|
1107
|
-
point: [number, number];
|
|
1108
|
-
};
|
|
1109
|
-
/**
|
|
1110
|
-
* Shared runtime state that `<YarrowMapView>` provides to the layers and hooks
|
|
1111
|
-
* rendered inside it. Everything is optional at the type level so hooks can
|
|
1112
|
-
* also run outside a map (they no-op with a console warning where relevant).
|
|
1113
|
-
*/
|
|
1114
|
-
type YarrowMapRuntime = {
|
|
1115
|
-
apiKey: string;
|
|
1116
|
-
/** Visual theme of the map, for theme-aware overlay styling. */
|
|
1117
|
-
theme: 'light' | 'dark';
|
|
1118
|
-
mapRef: RefObject<MapRef$1 | null>;
|
|
1119
|
-
cameraRef: RefObject<CameraRef$1 | null>;
|
|
1120
|
-
/** Icon registry: sprite name → image URL (empty until loaded / disabled). */
|
|
1121
|
-
iconsByName: Record<string, string>;
|
|
1122
|
-
/**
|
|
1123
|
-
* POI ids currently highlighted by `<PoiHighlightLayer>` — a mutable set
|
|
1124
|
-
* (no re-renders) so press handlers can report the web SDK's `selected`
|
|
1125
|
-
* flag. Updated by the layer; read by `useYarrowLayerPress`.
|
|
1126
|
-
*/
|
|
1127
|
-
highlightedPoiIds: RefObject<Set<number>>;
|
|
1128
|
-
/**
|
|
1129
|
-
* Subscribes to region changes (the `moveend` parity point). Returns an
|
|
1130
|
-
* unsubscribe function.
|
|
1131
|
-
*/
|
|
1132
|
-
subscribeRegionChange: (listener: (state: YarrowRegionState) => void) => () => void;
|
|
1133
|
-
/**
|
|
1134
|
-
* Subscribes to raw map presses. Returns an unsubscribe function.
|
|
1135
|
-
*/
|
|
1136
|
-
subscribePress: (listener: (press: YarrowMapPress) => void) => () => void;
|
|
1137
|
-
};
|
|
1138
|
-
export declare const YarrowMapContext: import("react").Context<YarrowMapRuntime | null>;
|
|
1139
|
-
/** Reads the enclosing `<YarrowMapView>` runtime, or `null` outside one. */
|
|
1140
|
-
export declare function useYarrowMapRuntime(): YarrowMapRuntime | null;
|
|
1141
|
-
/** The base style's POI symbol layer (`node_tile` source). */
|
|
1142
|
-
export declare const POI_BASE_LAYER = "pois_tile_layer";
|
|
1143
|
-
/**
|
|
1144
|
-
* Fetches a POI's coordinates and icon from the place-detail API — the
|
|
1145
|
-
* off-screen / below-zoom fallback of the resolution chain. Returns `null`
|
|
1146
|
-
* on any failure or missing coordinates (web parity).
|
|
1147
|
-
*
|
|
1148
|
-
* When the response carries no `icon_img`, the icon is derived from
|
|
1149
|
-
* `node_type` (falling back to `category.name`) — the web SDK resolves it
|
|
1150
|
-
* through its style `icon-image` expression; native approximates that with
|
|
1151
|
-
* an icon-registry lookup by the same name, since the detail endpoint
|
|
1152
|
-
* returns the node type rather than an icon URL.
|
|
1153
|
-
*/
|
|
1154
|
-
export declare function fetchPlaceLocation(id: number, iconsByName?: Record<string, string>): Promise<ResolvedPoiData | null>;
|
|
1155
|
-
/**
|
|
1156
|
-
* Reads a POI's point geometry from the style's POI layer within the current
|
|
1157
|
-
* viewport — the free, no-network resolution step. Native can only query
|
|
1158
|
-
* *rendered* features (no `querySourceFeatures` on undeclared sources), so
|
|
1159
|
-
* off-screen POIs fall through to the place-detail API. Icons are resolved
|
|
1160
|
-
* best-effort from the registry via the feature's `node_type`.
|
|
1161
|
-
*/
|
|
1162
|
-
export declare function lookupPoiInViewport(mapRef: MapRef$1, id: number, iconsByName?: Record<string, string>): Promise<ResolvedPoiData | null>;
|
|
1163
|
-
/**
|
|
1164
|
-
* Resolves a POI's coordinates, icon and title cheapest-first:
|
|
1165
|
-
* 1. caller-provided `location` / `icon` / `title`
|
|
1166
|
-
* 2. local lookup in the rendered POI layer (no network)
|
|
1167
|
-
* 3. the place-detail API (off-screen / below the POI zoom range, or when
|
|
1168
|
-
* anything is still missing — web parity: the API fills icon and title
|
|
1169
|
-
* too, not just coordinates)
|
|
1170
|
-
*
|
|
1171
|
-
* The web SDK additionally evaluates the style's `icon-image` expression for
|
|
1172
|
-
* both the tile and the place-detail steps; native approximates it with a
|
|
1173
|
-
* registry lookup by `node_type`. Coordinate resolution is the hard
|
|
1174
|
-
* requirement — if it fails, the highlight is rolled back by the caller.
|
|
1175
|
-
*/
|
|
1176
|
-
export declare function resolvePoiData(id: number, options: HighlightPoiData, runtime: YarrowMapRuntime): Promise<ResolvedPoiData | null>;
|
|
1177
|
-
/** Handle for one active highlight — mirrors the web SDK's `POIHighlight`. */
|
|
1178
|
-
type YarrowPoiHighlight = {
|
|
1179
|
-
readonly id: number;
|
|
1180
|
-
remove: () => void;
|
|
1181
|
-
};
|
|
1182
|
-
type UseYarrowPoiHighlightResult = {
|
|
1183
|
-
/** All currently highlighted ids — feed to `<PoiHighlightLayer ids={…}>`. */
|
|
1184
|
-
highlightedIds: number[];
|
|
1185
|
-
/**
|
|
1186
|
-
* Highlights one or more POIs. Additive by default (web parity); pass
|
|
1187
|
-
* `{ replace: true }` to reset the selection first. Returns one handle per
|
|
1188
|
-
* id whose `remove()` un-highlights it.
|
|
1189
|
-
*/
|
|
1190
|
-
highlight: (input: number | number[], options?: {
|
|
1191
|
-
replace?: boolean;
|
|
1192
|
-
}) => YarrowPoiHighlight[];
|
|
1193
|
-
/** Un-highlights all POIs, or the given id(s). */
|
|
1194
|
-
reset: (input?: number | number[]) => void;
|
|
1195
|
-
/** Whether a POI id is currently highlighted. */
|
|
1196
|
-
isHighlighted: (id: number) => boolean;
|
|
1197
|
-
};
|
|
1198
|
-
/**
|
|
1199
|
-
* Headless highlight state — the declarative counterpart of the web SDK's
|
|
1200
|
-
* `highlightPOI` / `resetPOIHighlight` / `isPOIHighlighted` /
|
|
1201
|
-
* `getHighlightedPOIs` quartet. Rendering is owned by `<PoiHighlightLayer>`:
|
|
1202
|
-
*
|
|
1203
|
-
* ```tsx
|
|
1204
|
-
* const { highlightedIds, highlight } = useYarrowPoiHighlight();
|
|
1205
|
-
* <YarrowMapView apiKey={KEY}>
|
|
1206
|
-
* <PoiHighlightLayer ids={highlightedIds} panTo />
|
|
1207
|
-
* </YarrowMapView>
|
|
1208
|
-
* ```
|
|
1209
|
-
*/
|
|
1210
|
-
export declare function useYarrowPoiHighlight(): UseYarrowPoiHighlightResult;
|
|
1211
|
-
type SearchResultsLayerProps = {
|
|
1212
|
-
/** Results from `useYarrowSearch` (or your own fetch). */
|
|
1213
|
-
results: SearchResult[];
|
|
1214
|
-
/** Icon size in points: a number (square) or `[width, height]`. Default 56. */
|
|
1215
|
-
iconSize?: number | [number, number];
|
|
1216
|
-
/**
|
|
1217
|
-
* Fits the camera to the results the first time a non-empty page renders
|
|
1218
|
-
* (default `true`). The fit runs once per session — pass a `fitKey` to
|
|
1219
|
-
* start a new session (web parity: the web fits once per
|
|
1220
|
-
* `highlightSearchResults()` call, so a new query re-fits).
|
|
1221
|
-
*/
|
|
1222
|
-
zoomToResults?: boolean;
|
|
1223
|
-
/**
|
|
1224
|
-
* Session identity for `zoomToResults`: changing it re-arms the initial
|
|
1225
|
-
* fit, e.g. `fitKey={query}` re-fits when the query changes (web parity).
|
|
1226
|
-
* Omitted (or unchanged) = fit once per mount.
|
|
1227
|
-
*/
|
|
1228
|
-
fitKey?: string | number;
|
|
1229
|
-
/** Clusters the result markers (`true` or a config object). */
|
|
1230
|
-
clustering?: ClusteringConfig;
|
|
1231
|
-
/** Called when a result marker is pressed. */
|
|
1232
|
-
onResultPress?: (lat: number, lng: number, result: SearchResult) => void;
|
|
1233
|
-
};
|
|
1234
|
-
/**
|
|
1235
|
-
* Renders search results on the map — the declarative counterpart of the web
|
|
1236
|
-
* SDK's `highlightSearchResults()`. Icon precedence per result:
|
|
1237
|
-
* `icon_img` → registry icon by `category.name` → blue-dot fallback.
|
|
1238
|
-
*
|
|
1239
|
-
* ```tsx
|
|
1240
|
-
* const { results, isLoading } = useYarrowSearch(query, { lat, lon });
|
|
1241
|
-
* <YarrowMapView apiKey={KEY}>
|
|
1242
|
-
* <SearchResultsLayer results={results} onResultPress={…} />
|
|
1243
|
-
* </YarrowMapView>
|
|
1244
|
-
* ```
|
|
1245
|
-
*/
|
|
1246
|
-
export declare function SearchResultsLayer({ results, iconSize, zoomToResults, fitKey, clustering, onResultPress }: SearchResultsLayerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
1247
|
-
/**
|
|
1248
|
-
* Minimal slice of `@react-native-async-storage/async-storage` the adapter
|
|
1249
|
-
* needs. Accepting a structural type (instead of importing the module) keeps
|
|
1250
|
-
* the async-storage peer dependency optional.
|
|
1251
|
-
*/
|
|
1252
|
-
type AsyncStorageLike = {
|
|
1253
|
-
getItem(key: string): Promise<string | null>;
|
|
1254
|
-
setItem(key: string, value: string): Promise<void>;
|
|
1255
|
-
};
|
|
1256
|
-
/**
|
|
1257
|
-
* Bridges the async AsyncStorage API onto core's synchronous TokenStorage
|
|
1258
|
-
* contract: the existing token hydrates into memory once, reads are served
|
|
1259
|
-
* synchronously from that cache, and writes mirror in-memory before flushing
|
|
1260
|
-
* to AsyncStorage (fire-and-forget).
|
|
1261
|
-
*
|
|
1262
|
-
* If the initial read throws, the override is left unset entirely: core then
|
|
1263
|
-
* degrades to ephemeral tokens *without persisting anything*, so a transient
|
|
1264
|
-
* read failure can never overwrite the stored identity with a fresh token.
|
|
1265
|
-
*
|
|
1266
|
-
* Await this once during app startup, before the first map or tracking call
|
|
1267
|
-
* (tokens generated before this resolves are ephemeral by design):
|
|
1268
|
-
*
|
|
1269
|
-
* ```ts
|
|
1270
|
-
* import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
1271
|
-
* import { setAsyncStorageTokenStorage } from '@yarrow-uz/rn-map-sdk';
|
|
1272
|
-
*
|
|
1273
|
-
* await setAsyncStorageTokenStorage(AsyncStorage);
|
|
1274
|
-
* ```
|
|
1275
|
-
*/
|
|
1276
|
-
export declare function setAsyncStorageTokenStorage(storage: AsyncStorageLike): Promise<void>;
|
|
1277
|
-
export { type AsyncStorageLike, type BoundingBox, type BuildRouteInput, type CacheConfig, type CachedArrayBufferResponse, type CameraRef, type ClickLayerTarget, type ClusterBadgeProps, type ClusterChild, type ClusterClickHandler, type ClusterPoint, type ClusteringConfig, type FetchRoutesInput, type FetchRoutesResult, type FitBoundsOptions, type HighlightMarkerViewProps, type HighlightPoiData, type LayerPressInfo, type MapRef, type NormalizedCacheConfig, type NormalizedClusteringConfig, type OfflineBounds, type OfflineRegionDownloadOptions, type OfflineRegionErrorCode, type OfflineRegionEstimate, type OfflineRegionHandle, type OfflineRegionProgress, type OfflineRegionSummary, type PixelCluster, type PlaceLocation, type PoiHighlightLayerProps, type PoiHighlightPressInfo, type ResolvedPoiData, type RouteDirection, type RouteDirectionModifier, type RouteFeature, type RouteLayerProps, type RoutesMeta, type SearchResult, type SearchResultsLayerProps, type TokenStorage, type UseYarrowLayerPressOptions, type UseYarrowMapSearchOptions, type UseYarrowMapSearchResult, type UseYarrowOfflineRegionsOptions, type UseYarrowOfflineRegionsResult, type UseYarrowPoiHighlightResult, type UseYarrowRoutingOptions, type UseYarrowRoutingResult, type UseYarrowSearchOptions, type UseYarrowSearchResult, YARROW_MAP_URL, YARROW_SEARCH_API_URL, type YarrowCamera, type YarrowIconsMap, type YarrowImagesProps, type YarrowMapConfigOptions, type YarrowMapPress, type YarrowMapRuntime, type YarrowMapViewProps, type YarrowMarkerProps, type YarrowOfflineError, type YarrowOfflineManagerOptions, type YarrowPoiHighlight, type YarrowRegionState, type YarrowStyleType, type ZoomToOptions };
|
|
1
|
+
import { $ as YarrowMapViewProps, $t as RouteDirection, A as useYarrowOfflineRegions, At as ClusteringConfig, B as OfflineRegionHandle, Bt as BoundingBox, C as PlaceLocation, Cn as transformRouteCoordinates, Ct as LayerPressInfo, D as YarrowOfflineManagerOptions, Dt as ClusterChild, E as YarrowOfflineManager, Et as useYarrowLayerPress, F as OFFLINE_METADATA_VERSION, Ft as PixelCluster, G as YarrowCamera, Gt as DEFAULT_CACHE_LIFESPAN_DAYS, H as OfflineRegionSummary, Ht as CACHE_PROTOCOL, I as OfflineBounds, It as groupByPixelRadius, J as YarrowMarker, Jt as ICONS_ENDPOINT, K as ZoomToOptions, Kt as FetchRoutesInput, L as OfflineRegionDownloadOptions, Lt as normalizeClusteringConfig, M as estimateRegion, Mt as DEFAULT_CLUSTER_MIN_POINTS, N as DEFAULT_OFFLINE_MAX_ZOOM, Nt as DEFAULT_CLUSTER_RADIUS_PX, O as UseYarrowOfflineRegionsOptions, Ot as ClusterClickHandler, P as DEFAULT_OFFLINE_MIN_ZOOM, Pt as NormalizedClusteringConfig, Q as YarrowMapView, Qt as ROUTE_API_URL, R as OfflineRegionErrorCode, Rt as ClusterBadge, S as HighlightPoiData, Sn as setYarrowApiKey, St as ClickLayerTarget, T as ResolvedPoiData, Tt as YARROW_CLICK_LAYER_IDS, U as YarrowOfflineError, Ut as CacheConfig, V as OfflineRegionProgress, Vt as CACHED_AT_HEADER, W as FitBoundsOptions, Wt as CachedArrayBufferResponse, X as HighlightMarkerView, Xt as MILLISECONDS_PER_DAY, Y as YarrowMarkerProps, Yt as ICON_CACHE_NAME, Z as HighlightMarkerViewProps, Zt as NormalizedCacheConfig, _ as YarrowMapRuntime, _n as getYarrowApiKey, _t as UseYarrowMapSearchResult, a as trackDau, an as TokenStorage, at as BrandBadgePosition, b as PoiHighlightLayer, bn as normalizeStyleType, bt as UseYarrowSearchResult, c as UseYarrowPoiHighlightResult, cn as YARROW_SEARCH_API_URL, ct as YarrowImagesProps, d as POI_BASE_LAYER, dn as buildStyleEndpoint, dt as resolveCategoryIcon, en as RouteDirectionModifier, et as buildStyleUrl, f as fetchPlaceLocation, fn as fetchArrayBufferWithCache, ft as BuildRouteInput, g as YarrowMapPress, gn as getOrCreateUserToken, gt as UseYarrowMapSearchOptions, h as YarrowMapContext, hn as getBoundingBox, ht as useYarrowRouting, i as setAsyncStorageTokenStorage, in as TILE_CACHE_NAME, it as YarrowMapConfigOptions, j as AVG_TILE_BYTES, jt as DEFAULT_CLUSTER_MAX_ZOOM, k as UseYarrowOfflineRegionsResult, kt as ClusterPoint, l as YarrowPoiHighlight, ln as YarrowStyleType, lt as YarrowIconsMap, m as resolvePoiData, mn as fetchSearchResults, mt as UseYarrowRoutingResult, n as MapRef, nn as RoutesMeta, nt as RouteLayerProps, o as SearchResultsLayer, on as USER_TOKEN_STORAGE_KEY, ot as DEFAULT_BRAND_BADGE_SCALE, p as lookupPoiInViewport, pn as fetchRoutes, pt as UseYarrowRoutingOptions, q as useYarrowCamera, qt as FetchRoutesResult, r as AsyncStorageLike, rn as SearchResult, rt as YarrowMapConfig, s as SearchResultsLayerProps, sn as YARROW_MAP_URL, st as YarrowImages, t as CameraRef, tn as RouteFeature, tt as RouteLayer, u as useYarrowPoiHighlight, un as addApiKeyToUrl, ut as fetchYarrowIcons, v as YarrowRegionState, vn as hasCacheStorage, vt as useYarrowMapSearch, w as PoiHighlightPressInfo, wt as UseYarrowLayerPressOptions, x as PoiHighlightLayerProps, xn as setTokenStorage, xt as useYarrowSearch, y as useYarrowMapRuntime, yn as haversineDistance, yt as UseYarrowSearchOptions, z as OfflineRegionEstimate, zt as ClusterBadgeProps } from "./surface-CvmTHryW.js";
|
|
2
|
+
export { AVG_TILE_BYTES, type AsyncStorageLike, type BoundingBox, type BrandBadgePosition, type BuildRouteInput, CACHED_AT_HEADER, CACHE_PROTOCOL, type CacheConfig, type CachedArrayBufferResponse, type CameraRef, type ClickLayerTarget, ClusterBadge, type ClusterBadgeProps, type ClusterChild, type ClusterClickHandler, type ClusterPoint, type ClusteringConfig, DEFAULT_BRAND_BADGE_SCALE, DEFAULT_CACHE_LIFESPAN_DAYS, DEFAULT_CLUSTER_MAX_ZOOM, DEFAULT_CLUSTER_MIN_POINTS, DEFAULT_CLUSTER_RADIUS_PX, DEFAULT_OFFLINE_MAX_ZOOM, DEFAULT_OFFLINE_MIN_ZOOM, type FetchRoutesInput, type FetchRoutesResult, type FitBoundsOptions, HighlightMarkerView, type HighlightMarkerViewProps, type HighlightPoiData, ICONS_ENDPOINT, ICON_CACHE_NAME, type LayerPressInfo, MILLISECONDS_PER_DAY, type MapRef, type NormalizedCacheConfig, type NormalizedClusteringConfig, OFFLINE_METADATA_VERSION, type OfflineBounds, type OfflineRegionDownloadOptions, type OfflineRegionErrorCode, type OfflineRegionEstimate, type OfflineRegionHandle, type OfflineRegionProgress, type OfflineRegionSummary, POI_BASE_LAYER, type PixelCluster, type PlaceLocation, PoiHighlightLayer, type PoiHighlightLayerProps, type PoiHighlightPressInfo, ROUTE_API_URL, type ResolvedPoiData, type RouteDirection, type RouteDirectionModifier, type RouteFeature, RouteLayer, type RouteLayerProps, type RoutesMeta, type SearchResult, SearchResultsLayer, type SearchResultsLayerProps, TILE_CACHE_NAME, type TokenStorage, USER_TOKEN_STORAGE_KEY, type UseYarrowLayerPressOptions, type UseYarrowMapSearchOptions, type UseYarrowMapSearchResult, type UseYarrowOfflineRegionsOptions, type UseYarrowOfflineRegionsResult, type UseYarrowPoiHighlightResult, type UseYarrowRoutingOptions, type UseYarrowRoutingResult, type UseYarrowSearchOptions, type UseYarrowSearchResult, YARROW_CLICK_LAYER_IDS, YARROW_MAP_URL, YARROW_SEARCH_API_URL, type YarrowCamera, type YarrowIconsMap, YarrowImages, type YarrowImagesProps, YarrowMapConfig, type YarrowMapConfigOptions, YarrowMapContext, type YarrowMapPress, type YarrowMapRuntime, YarrowMapView, type YarrowMapViewProps, YarrowMarker, type YarrowMarkerProps, type YarrowOfflineError, YarrowOfflineManager, type YarrowOfflineManagerOptions, type YarrowPoiHighlight, type YarrowRegionState, type YarrowStyleType, type ZoomToOptions, addApiKeyToUrl, buildStyleEndpoint, buildStyleUrl, estimateRegion, fetchArrayBufferWithCache, fetchPlaceLocation, fetchRoutes, fetchSearchResults, fetchYarrowIcons, getBoundingBox, getOrCreateUserToken, getYarrowApiKey, groupByPixelRadius, hasCacheStorage, haversineDistance, lookupPoiInViewport, normalizeClusteringConfig, normalizeStyleType, resolveCategoryIcon, resolvePoiData, setAsyncStorageTokenStorage, setTokenStorage, setYarrowApiKey, trackDau, transformRouteCoordinates, useYarrowCamera, useYarrowLayerPress, useYarrowMapRuntime, useYarrowMapSearch, useYarrowOfflineRegions, useYarrowPoiHighlight, useYarrowRouting, useYarrowSearch };
|