@yarrow-uz/rn-map-sdk 0.0.1 → 0.2.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 +14 -0
- package/README.md +192 -5
- package/dist/index.d.ts +730 -173
- package/dist/index.js +1552 -253
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CameraRef, CameraRef as CameraRef$1, MapProps, MapRef, MapRef as MapRef$1, OfflinePackStatus, PressEventWithFeatures } from "@maplibre/maplibre-react-native";
|
|
2
|
-
import { ReactNode, Ref } from "react";
|
|
1
|
+
import { CameraRef, CameraRef as CameraRef$1, MapProps, MapRef, MapRef as MapRef$1, MarkerProps, OfflinePackStatus, PressEventWithFeatures } from "@maplibre/maplibre-react-native";
|
|
2
|
+
import { ReactElement, ReactNode, Ref, RefObject } from "react";
|
|
3
3
|
import { NativeSyntheticEvent, ViewProps } from "react-native";
|
|
4
4
|
declare const YARROW_MAP_URL: string;
|
|
5
5
|
declare const YARROW_SEARCH_API_URL: string;
|
|
@@ -10,24 +10,6 @@ export declare function getYarrowApiKey(): string;
|
|
|
10
10
|
* url unchanged when no key is configured yet or the url cannot be parsed.
|
|
11
11
|
*/
|
|
12
12
|
export declare function addApiKeyToUrl(url: string): string;
|
|
13
|
-
export declare function trackDau(apiKey: string, sdkType?: string): void;
|
|
14
|
-
/**
|
|
15
|
-
* Public alias of `STORAGE_KEY` so platform SDKs can build storage adapters
|
|
16
|
-
* (e.g. React Native AsyncStorage bridges) without hard-coding the key.
|
|
17
|
-
*/
|
|
18
|
-
export declare const USER_TOKEN_STORAGE_KEY = "yarrow:user_token";
|
|
19
|
-
/**
|
|
20
|
-
* Minimal persistence contract for the anonymous user token. The default
|
|
21
|
-
* resolution uses `localStorage` when available (guarded — this is the only
|
|
22
|
-
* file in core allowed to touch it); shells without a DOM (e.g. React Native)
|
|
23
|
-
* can inject their own storage via `setTokenStorage`.
|
|
24
|
-
*/
|
|
25
|
-
interface TokenStorage {
|
|
26
|
-
getItem(key: string): string | null;
|
|
27
|
-
setItem(key: string, value: string): void;
|
|
28
|
-
}
|
|
29
|
-
export declare function setTokenStorage(storage: TokenStorage): void;
|
|
30
|
-
export declare function getOrCreateUserToken(): string;
|
|
31
13
|
type CacheConfig = {
|
|
32
14
|
enabled?: boolean;
|
|
33
15
|
lifespanDays?: number;
|
|
@@ -42,6 +24,15 @@ type CachedArrayBufferResponse = {
|
|
|
42
24
|
expires: string | null;
|
|
43
25
|
contentType: string | null;
|
|
44
26
|
};
|
|
27
|
+
type BoundsInput = {
|
|
28
|
+
type?: string;
|
|
29
|
+
features: Array<{
|
|
30
|
+
geometry?: {
|
|
31
|
+
type?: string;
|
|
32
|
+
coordinates?: unknown;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
45
36
|
type RouteFeature = {
|
|
46
37
|
type: 'Feature';
|
|
47
38
|
geometry: {
|
|
@@ -54,6 +45,8 @@ type RouteFeature = {
|
|
|
54
45
|
[key: string]: unknown;
|
|
55
46
|
};
|
|
56
47
|
};
|
|
48
|
+
/** Style-API endpoint returning the icon registry (`IconListItem[]`). */
|
|
49
|
+
export declare const ICONS_ENDPOINT = "/icons-image";
|
|
57
50
|
type SearchResult = {
|
|
58
51
|
id?: string | number;
|
|
59
52
|
latitude?: number;
|
|
@@ -75,6 +68,19 @@ export declare const TILE_CACHE_NAME = "yarrow-cache-v1-tile";
|
|
|
75
68
|
export declare const ICON_CACHE_NAME = "yarrow-cache-v1-icon";
|
|
76
69
|
export declare const CACHE_PROTOCOL = "yarrowcache";
|
|
77
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;
|
|
78
84
|
/**
|
|
79
85
|
* Structural subset of maplibre-gl's `RequestParameters` covering the fields
|
|
80
86
|
* used for the network fetch. Any real maplibre `RequestParameters` object is
|
|
@@ -122,7 +128,6 @@ type FetchRoutesInput = {
|
|
|
122
128
|
/** Cancels the routing request. */
|
|
123
129
|
signal?: AbortSignal;
|
|
124
130
|
};
|
|
125
|
-
export declare const transformRouteCoordinates: (features: RouteFeature[]) => RouteFeature[];
|
|
126
131
|
interface RoutesMeta {
|
|
127
132
|
profile: string;
|
|
128
133
|
totalRoutes: number;
|
|
@@ -145,6 +150,7 @@ interface FetchRoutesResult {
|
|
|
145
150
|
* like the web SDK's historic `buildRoute()` behavior.
|
|
146
151
|
*/
|
|
147
152
|
export declare function fetchRoutes(input: FetchRoutesInput): Promise<FetchRoutesResult>;
|
|
153
|
+
export declare const transformRouteCoordinates: (features: RouteFeature[]) => RouteFeature[];
|
|
148
154
|
export declare const haversineDistance: (lat1: number, lon1: number, lat2: number, lon2: number) => number;
|
|
149
155
|
interface FetchSearchResultsInput {
|
|
150
156
|
lat: number;
|
|
@@ -171,6 +177,312 @@ export declare function normalizeStyleType(styleType?: string): YarrowStyleType;
|
|
|
171
177
|
* `YarrowStylesManager.buildStyleEndpoint()`.
|
|
172
178
|
*/
|
|
173
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>;
|
|
174
486
|
/**
|
|
175
487
|
* Configuration for the React Native map — the `container`-free counterpart
|
|
176
488
|
* of the web SDK's `YarrowMapConfigOptions`. The native view is sized by the
|
|
@@ -192,6 +504,71 @@ type YarrowMapConfigOptions = {
|
|
|
192
504
|
/** Base style. Default `"default"` (street map). */
|
|
193
505
|
styleType?: YarrowStyleType;
|
|
194
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. Defaults to the shared palette by index. */
|
|
543
|
+
alternativeColor?: string;
|
|
544
|
+
/** Alternative-route line width. Default `2.5`. */
|
|
545
|
+
alternativeWidth?: number;
|
|
546
|
+
/** Alternative-route opacity. Default `0.5`. */
|
|
547
|
+
alternativeOpacity?: number;
|
|
548
|
+
/** Prefix for source/layer ids. Default `"yarrow-route"`. */
|
|
549
|
+
layerPrefix?: string;
|
|
550
|
+
/** Called when a rendered route line is pressed. */
|
|
551
|
+
onPressRoute?: RoutePressHandler;
|
|
552
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* Declarative route rendering: one GeoJSON source + line layer per route.
|
|
555
|
+
* Compose inside `<YarrowMapView>` and drive it with `useYarrowRouting()`:
|
|
556
|
+
*
|
|
557
|
+
* ```tsx
|
|
558
|
+
* const { routes } = useYarrowRouting();
|
|
559
|
+
* <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
|
|
560
|
+
* <RouteLayer routes={routes} onPressRoute={…} />
|
|
561
|
+
* </YarrowMapView>
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
export declare const RouteLayer: import("react").MemoExoticComponent<({ routes, bestIndex, routeColor, routeWidth, routeOpacity, alternativeColor, alternativeWidth, alternativeOpacity, layerPrefix, onPressRoute }: RouteLayerProps) => import("react/jsx-runtime").JSX.Element[]>;
|
|
565
|
+
/**
|
|
566
|
+
* Full style URL for MapLibre React Native's `mapStyle` prop, built from the
|
|
567
|
+
* platform-agnostic style endpoint plus the configured API key. The key comes
|
|
568
|
+
* from core's module state (`setYarrowApiKey`) — `YarrowMapView` calls it for
|
|
569
|
+
* you; standalone callers must set it first.
|
|
570
|
+
*/
|
|
571
|
+
export declare function buildStyleUrl(styleType?: string, theme?: 'light' | 'dark'): string;
|
|
195
572
|
type YarrowMapViewProps = YarrowMapConfigOptions & {
|
|
196
573
|
/** Called once the native map finished loading its style. */
|
|
197
574
|
onReady?: (map: MapRef$1) => void;
|
|
@@ -200,6 +577,11 @@ type YarrowMapViewProps = YarrowMapConfigOptions & {
|
|
|
200
577
|
/** Called when the user presses the map (bubbles up from pressable
|
|
201
578
|
* sources unless they call `event.stopPropagation()`). */
|
|
202
579
|
onPress?: MapProps['onPress'];
|
|
580
|
+
/**
|
|
581
|
+
* Called when the camera finishes moving — web `onMoveEnd` parity:
|
|
582
|
+
* `(lat, lng, zoom)`.
|
|
583
|
+
*/
|
|
584
|
+
onMoveEnd?: (lat: number, lng: number, zoom: number) => void;
|
|
203
585
|
/** Forwarded to the inner camera — use it for `flyTo`/`fitBounds`/`zoomTo`.
|
|
204
586
|
* The outer component ref is the `MapRef` (getCenter, queryRenderedFeatures…). */
|
|
205
587
|
cameraRef?: Ref<CameraRef$1>;
|
|
@@ -211,6 +593,12 @@ type YarrowMapViewProps = YarrowMapConfigOptions & {
|
|
|
211
593
|
compass?: boolean;
|
|
212
594
|
/** Fire-and-forget DAU ping when the style first loads. Default `true`. */
|
|
213
595
|
dauTracking?: boolean;
|
|
596
|
+
/**
|
|
597
|
+
* Fetch the Yarrow icon registry and add it to the style so POI symbols and
|
|
598
|
+
* category-icon fallbacks work (web icon-pipeline parity). Disable only if
|
|
599
|
+
* your style/labels don't need the Yarrow icons. Default `true`.
|
|
600
|
+
*/
|
|
601
|
+
icons?: boolean;
|
|
214
602
|
/** Style for the wrapping native view. Default `{ flex: 1 }`. */
|
|
215
603
|
style?: ViewProps['style'];
|
|
216
604
|
/** Sources/layers/markers rendered inside the map. */
|
|
@@ -218,7 +606,9 @@ type YarrowMapViewProps = YarrowMapConfigOptions & {
|
|
|
218
606
|
};
|
|
219
607
|
/**
|
|
220
608
|
* React Native Yarrow map. Renders MapLibre Native with a Yarrow style URL
|
|
221
|
-
* (theme + styleType aware, API key attached) and a default camera
|
|
609
|
+
* (theme + styleType aware, API key attached) and a default camera, and
|
|
610
|
+
* provides the runtime (refs, icon registry, camera/event subscriptions) to
|
|
611
|
+
* the SDK layers rendered inside it.
|
|
222
612
|
*
|
|
223
613
|
* ```tsx
|
|
224
614
|
* const mapRef = useRef<MapRef>(null);
|
|
@@ -243,6 +633,11 @@ export declare const YarrowMapView: import("react").ForwardRefExoticComponent<Ya
|
|
|
243
633
|
/** Called when the user presses the map (bubbles up from pressable
|
|
244
634
|
* sources unless they call `event.stopPropagation()`). */
|
|
245
635
|
onPress?: MapProps['onPress'];
|
|
636
|
+
/**
|
|
637
|
+
* Called when the camera finishes moving — web `onMoveEnd` parity:
|
|
638
|
+
* `(lat, lng, zoom)`.
|
|
639
|
+
*/
|
|
640
|
+
onMoveEnd?: (lat: number, lng: number, zoom: number) => void;
|
|
246
641
|
/** Forwarded to the inner camera — use it for `flyTo`/`fitBounds`/`zoomTo`.
|
|
247
642
|
* The outer component ref is the `MapRef` (getCenter, queryRenderedFeatures…). */
|
|
248
643
|
cameraRef?: Ref<CameraRef$1>;
|
|
@@ -254,153 +649,98 @@ export declare const YarrowMapView: import("react").ForwardRefExoticComponent<Ya
|
|
|
254
649
|
compass?: boolean;
|
|
255
650
|
/** Fire-and-forget DAU ping when the style first loads. Default `true`. */
|
|
256
651
|
dauTracking?: boolean;
|
|
652
|
+
/**
|
|
653
|
+
* Fetch the Yarrow icon registry and add it to the style so POI symbols and
|
|
654
|
+
* category-icon fallbacks work (web icon-pipeline parity). Disable only if
|
|
655
|
+
* your style/labels don't need the Yarrow icons. Default `true`.
|
|
656
|
+
*/
|
|
657
|
+
icons?: boolean;
|
|
257
658
|
/** Style for the wrapping native view. Default `{ flex: 1 }`. */
|
|
258
659
|
style?: ViewProps['style'];
|
|
259
660
|
/** Sources/layers/markers rendered inside the map. */
|
|
260
661
|
children?: ReactNode;
|
|
261
662
|
} & import("react").RefAttributes<MapRef$1>>;
|
|
262
|
-
type
|
|
663
|
+
type HighlightMarkerViewProps = {
|
|
664
|
+
/** Coordinates as `[longitude, latitude]`. */
|
|
665
|
+
lngLat: [number, number];
|
|
666
|
+
/** Icon URL; when absent a blue dot is rendered (web parity). */
|
|
667
|
+
iconUrl?: string;
|
|
668
|
+
/** Label rendered under the icon. */
|
|
669
|
+
title?: string;
|
|
670
|
+
/** Icon size in points: a number (square) or `[width, height]`. Default 56. */
|
|
671
|
+
iconSize?: number | [number, number];
|
|
672
|
+
/** Plays the exit animation instead of the enter one. */
|
|
673
|
+
leaving?: boolean;
|
|
674
|
+
onPress?: () => void;
|
|
675
|
+
};
|
|
263
676
|
/**
|
|
264
|
-
*
|
|
265
|
-
*
|
|
677
|
+
* The animated icon+label marker shared by `<PoiHighlightLayer>` and
|
|
678
|
+
* `<SearchResultsLayer>` — the native counterpart of the web SDK's
|
|
679
|
+
* `createMarkerElement` + enter/exit CSS transitions. The scale/fade runs on
|
|
680
|
+
* an inner view (never on the `Marker` itself, which the map repositions
|
|
681
|
+
* every frame).
|
|
266
682
|
*/
|
|
267
|
-
|
|
268
|
-
type
|
|
269
|
-
/**
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
|
|
279
|
-
/** Best-route opacity. Default `1`. */
|
|
280
|
-
routeOpacity?: number;
|
|
281
|
-
/** Alternative-route color. Defaults to the shared palette by index. */
|
|
282
|
-
alternativeColor?: string;
|
|
283
|
-
/** Alternative-route line width. Default `2.5`. */
|
|
284
|
-
alternativeWidth?: number;
|
|
285
|
-
/** Alternative-route opacity. Default `0.5`. */
|
|
286
|
-
alternativeOpacity?: number;
|
|
287
|
-
/** Prefix for source/layer ids. Default `"yarrow-route"`. */
|
|
288
|
-
layerPrefix?: string;
|
|
289
|
-
/** Called when a rendered route line is pressed. */
|
|
290
|
-
onPressRoute?: RoutePressHandler;
|
|
683
|
+
export declare const HighlightMarkerView: import("react").MemoExoticComponent<({ lngLat, iconUrl, title, iconSize, leaving, onPress }: HighlightMarkerViewProps) => import("react/jsx-runtime").JSX.Element>;
|
|
684
|
+
type YarrowMarkerProps = {
|
|
685
|
+
/** Coordinates as `[longitude, latitude]`. */
|
|
686
|
+
lngLat: [number, number];
|
|
687
|
+
/** Which part of the marker sits on the coordinate. Default `'bottom'`. */
|
|
688
|
+
anchor?: MarkerProps['anchor'];
|
|
689
|
+
/** Pixel offset `[x, y]` applied relative to the anchor. */
|
|
690
|
+
offset?: [number, number];
|
|
691
|
+
/** Called when the marker is pressed. */
|
|
692
|
+
onPress?: () => void;
|
|
693
|
+
/** Marker content — a single view (icon, label, bubble, …). */
|
|
694
|
+
children: ReactElement;
|
|
291
695
|
};
|
|
292
696
|
/**
|
|
293
|
-
* Declarative
|
|
294
|
-
*
|
|
697
|
+
* Declarative counterpart of the web SDK's `addMarker()` / `removeMarker()`.
|
|
698
|
+
* Mounting places the marker, unmounting removes it; the React lifecycle
|
|
699
|
+
* replaces the imperative manager pair.
|
|
295
700
|
*
|
|
296
701
|
* ```tsx
|
|
297
|
-
* const { routes } = useYarrowRouting();
|
|
298
702
|
* <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
|
|
299
|
-
* <
|
|
703
|
+
* <YarrowMarker lngLat={[69.2401, 41.2995]} onPress={() => …}>
|
|
704
|
+
* <PinIcon />
|
|
705
|
+
* </YarrowMarker>
|
|
300
706
|
* </YarrowMapView>
|
|
301
707
|
* ```
|
|
302
708
|
*/
|
|
303
|
-
export declare const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
* consuming app's layout) and minus web-only rendering options (hover,
|
|
308
|
-
* clustering, controls, tile cache — none of which exist on native).
|
|
309
|
-
*/
|
|
310
|
-
export declare class YarrowMapConfig {
|
|
311
|
-
readonly center: [number, number];
|
|
312
|
-
readonly zoom: number;
|
|
313
|
-
readonly minZoom: number;
|
|
314
|
-
readonly maxZoom: number;
|
|
315
|
-
theme: 'light' | 'dark';
|
|
316
|
-
styleType: YarrowStyleType;
|
|
317
|
-
apiKey: string;
|
|
318
|
-
constructor(config: YarrowMapConfigOptions);
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Full style URL for MapLibre React Native's `mapStyle` prop, built from the
|
|
322
|
-
* platform-agnostic style endpoint plus the configured API key. The key comes
|
|
323
|
-
* from core's module state (`setYarrowApiKey`) — `YarrowMapView` calls it for
|
|
324
|
-
* you; standalone callers must set it first.
|
|
325
|
-
*/
|
|
326
|
-
export declare function buildStyleUrl(styleType?: string, theme?: 'light' | 'dark'): string;
|
|
327
|
-
type UseYarrowSearchOptions = {
|
|
328
|
-
/** Latitude the search ranks results around. */
|
|
329
|
-
lat: number;
|
|
330
|
-
/** Longitude the search ranks results around. */
|
|
331
|
-
lon: number;
|
|
332
|
-
/** Result page. Default `1`. */
|
|
333
|
-
page?: number;
|
|
334
|
-
/** Results per page. Default `15`. */
|
|
335
|
-
pageSize?: number;
|
|
336
|
-
/** Debounce before querying, ms. Default `300`. */
|
|
337
|
-
debounceMs?: number;
|
|
338
|
-
/** Set `false` to pause querying — pending results clear while paused.
|
|
339
|
-
* Default `true`. */
|
|
340
|
-
enabled?: boolean;
|
|
341
|
-
};
|
|
342
|
-
type UseYarrowSearchResult = {
|
|
343
|
-
results: SearchResult[];
|
|
344
|
-
isLoading: boolean;
|
|
345
|
-
error: Error | null;
|
|
346
|
-
};
|
|
347
|
-
/**
|
|
348
|
-
* Debounced, abortable search against the Yarrow search API.
|
|
349
|
-
*
|
|
350
|
-
* Requires the API key to be configured (`YarrowMapView` does this on mount;
|
|
351
|
-
* otherwise call `setYarrowApiKey()` first).
|
|
352
|
-
*
|
|
353
|
-
* ```tsx
|
|
354
|
-
* const { results, isLoading } = useYarrowSearch(query, {
|
|
355
|
-
* lat: position?.lat ?? 41.2995,
|
|
356
|
-
* lon: position?.lng ?? 69.2401,
|
|
357
|
-
* });
|
|
358
|
-
* ```
|
|
359
|
-
*/
|
|
360
|
-
export declare const useYarrowSearch: (query: string, options: UseYarrowSearchOptions) => UseYarrowSearchResult;
|
|
361
|
-
type UseYarrowRoutingOptions = {
|
|
362
|
-
/** Routing profile, e.g. `"driving"`, `"walking"`. Default `"driving"`. */
|
|
363
|
-
profile?: string;
|
|
364
|
-
/** Language for turn-by-turn directions. */
|
|
365
|
-
language?: string;
|
|
709
|
+
export declare const YarrowMarker: import("react").MemoExoticComponent<({ lngLat, anchor, offset, onPress, children }: YarrowMarkerProps) => import("react/jsx-runtime").JSX.Element>;
|
|
710
|
+
type ZoomToOptions = {
|
|
711
|
+
/** Animation duration in ms. Web's `speed` option has no native equivalent. */
|
|
712
|
+
duration?: number;
|
|
366
713
|
};
|
|
367
|
-
type
|
|
368
|
-
/**
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
|
|
372
|
-
/** Overrides the hook-level language for this request. */
|
|
373
|
-
language?: string;
|
|
374
|
-
/** Cancels the request. */
|
|
375
|
-
signal?: AbortSignal;
|
|
714
|
+
type FitBoundsOptions = {
|
|
715
|
+
/** Padding in points around the fitted bounds. Default `50`. */
|
|
716
|
+
padding?: number;
|
|
717
|
+
/** Animation duration in ms. Default `1000`. */
|
|
718
|
+
duration?: number;
|
|
376
719
|
};
|
|
377
|
-
type
|
|
378
|
-
/**
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
|
|
388
|
-
buildRoute: (input: BuildRouteInput) => Promise<FetchRoutesResult>;
|
|
389
|
-
/** Clears routes/directions/meta and any error. */
|
|
390
|
-
clearRoutes: () => void;
|
|
720
|
+
type YarrowCamera = {
|
|
721
|
+
/** Flies the camera to a coordinate at `zoom`. */
|
|
722
|
+
zoomTo(lat: number, lng: number, zoom: number, options?: ZoomToOptions): void;
|
|
723
|
+
/**
|
|
724
|
+
* Fits the camera to the bounds of a GeoJSON FeatureCollection. Applies the
|
|
725
|
+
* web SDK's minimum-dimension expansion (0.003°) so single points don't
|
|
726
|
+
* over-zoom. Web's `maxZoom` cap is not supported natively.
|
|
727
|
+
*/
|
|
728
|
+
fitBounds(data: BoundsInput, options?: FitBoundsOptions): void;
|
|
729
|
+
/** Computes the geographic bounding box of a FeatureCollection. */
|
|
730
|
+
getBoundingBox(data: BoundsInput): BoundingBox;
|
|
391
731
|
};
|
|
392
732
|
/**
|
|
393
|
-
*
|
|
394
|
-
* `<
|
|
733
|
+
* Web-parity camera helpers on top of a `CameraRef`. Reads the enclosing
|
|
734
|
+
* `<YarrowMapView>` camera when called inside the map; otherwise pass a ref:
|
|
395
735
|
*
|
|
396
736
|
* ```tsx
|
|
397
|
-
* const
|
|
398
|
-
* <YarrowMapView apiKey={KEY}
|
|
399
|
-
*
|
|
400
|
-
*
|
|
737
|
+
* const cameraRef = useRef<CameraRef>(null);
|
|
738
|
+
* <YarrowMapView apiKey={KEY} cameraRef={cameraRef}>…</YarrowMapView>
|
|
739
|
+
* const camera = useYarrowCamera(cameraRef);
|
|
740
|
+
* camera.zoomTo(41.2995, 69.2401, 14);
|
|
401
741
|
* ```
|
|
402
742
|
*/
|
|
403
|
-
export declare
|
|
743
|
+
export declare function useYarrowCamera(cameraRefInput?: RefObject<CameraRef$1 | null>): YarrowCamera;
|
|
404
744
|
/** Download progress of an offline region (normalized native pack status). */
|
|
405
745
|
type OfflineRegionProgress = Omit<OfflinePackStatus, 'id'>;
|
|
406
746
|
/**
|
|
@@ -543,6 +883,40 @@ type EstimateRegionInput = {
|
|
|
543
883
|
* ```
|
|
544
884
|
*/
|
|
545
885
|
export declare const estimateRegion: (input: EstimateRegionInput) => OfflineRegionEstimate;
|
|
886
|
+
type UseYarrowOfflineRegionsOptions = {
|
|
887
|
+
/** Yarrow API key from the dashboard. Required. */
|
|
888
|
+
apiKey: string;
|
|
889
|
+
/** Poll interval while any region is downloading, ms. Default `1000`. */
|
|
890
|
+
pollMs?: number;
|
|
891
|
+
};
|
|
892
|
+
type UseYarrowOfflineRegionsResult = {
|
|
893
|
+
/** All regions created through the SDK, newest first. */
|
|
894
|
+
regions: OfflineRegionSummary[];
|
|
895
|
+
/** True during the initial `listRegions()` load. */
|
|
896
|
+
isLoading: boolean;
|
|
897
|
+
error: Error | null;
|
|
898
|
+
/** Re-reads regions from the native layer. */
|
|
899
|
+
refresh: () => Promise<void>;
|
|
900
|
+
/** Starts a region download (idempotent by `name` — see
|
|
901
|
+
* `YarrowOfflineManager.downloadRegion`). */
|
|
902
|
+
download: (options: OfflineRegionDownloadOptions) => Promise<OfflineRegionHandle>;
|
|
903
|
+
pause: (name: string) => Promise<void>;
|
|
904
|
+
resume: (name: string) => Promise<void>;
|
|
905
|
+
/** Revalidates stored tiles against the server — the cheap refresh path. */
|
|
906
|
+
invalidate: (name: string) => Promise<void>;
|
|
907
|
+
remove: (name: string) => Promise<void>;
|
|
908
|
+
};
|
|
909
|
+
/**
|
|
910
|
+
* Offline region state for settings/offline screens — pairs with
|
|
911
|
+
* `YarrowOfflineManager`. Polls the native layer while downloads run, so
|
|
912
|
+
* `regions` (and progress bars) stay current.
|
|
913
|
+
*
|
|
914
|
+
* ```tsx
|
|
915
|
+
* const { regions, download, remove } = useYarrowOfflineRegions({ apiKey });
|
|
916
|
+
* await download({ name: 'tashkent', bounds: [69.15, 41.2, 69.4, 41.4] });
|
|
917
|
+
* ```
|
|
918
|
+
*/
|
|
919
|
+
export declare const useYarrowOfflineRegions: (options: UseYarrowOfflineRegionsOptions) => UseYarrowOfflineRegionsResult;
|
|
546
920
|
type YarrowOfflineManagerOptions = {
|
|
547
921
|
/** Yarrow API key from the dashboard. Required. */
|
|
548
922
|
apiKey: string;
|
|
@@ -635,40 +1009,223 @@ export declare class YarrowOfflineManager {
|
|
|
635
1009
|
private toHandle;
|
|
636
1010
|
private deletePack;
|
|
637
1011
|
}
|
|
638
|
-
|
|
639
|
-
|
|
1012
|
+
/** Coordinates the caller already holds (e.g. from a search result). */
|
|
1013
|
+
type PlaceLocation = {
|
|
1014
|
+
lat: number;
|
|
1015
|
+
lng: number;
|
|
1016
|
+
};
|
|
1017
|
+
/** Coordinates (+ optional icon URL and title) resolved before placing a marker. */
|
|
1018
|
+
type ResolvedPoiData = {
|
|
1019
|
+
lng: number;
|
|
1020
|
+
lat: number;
|
|
1021
|
+
iconUrl?: string;
|
|
1022
|
+
title?: string;
|
|
1023
|
+
};
|
|
1024
|
+
/** Payload passed to a highlight marker's press handler. */
|
|
1025
|
+
type PoiHighlightPressInfo = {
|
|
1026
|
+
/** The highlighted POI id. */
|
|
1027
|
+
id: number;
|
|
1028
|
+
lng: number;
|
|
1029
|
+
lat: number;
|
|
1030
|
+
/** Resolved title/icon of the marker, if any. */
|
|
1031
|
+
title?: string;
|
|
1032
|
+
iconUrl?: string;
|
|
1033
|
+
};
|
|
1034
|
+
/**
|
|
1035
|
+
* Per-id data the caller already holds. Anything provided here skips the
|
|
1036
|
+
* corresponding lookup (viewport query / place-detail API) — the cheapest
|
|
1037
|
+
* resolution wins, exactly like the web SDK's `HighlightPOIOptions`.
|
|
1038
|
+
*/
|
|
1039
|
+
type HighlightPoiData = {
|
|
1040
|
+
location?: PlaceLocation;
|
|
1041
|
+
icon?: string;
|
|
1042
|
+
title?: string;
|
|
1043
|
+
};
|
|
1044
|
+
type PoiHighlightLayerProps = {
|
|
1045
|
+
/** POI id(s) to highlight — the declarative selection state. */
|
|
1046
|
+
ids: number | number[];
|
|
1047
|
+
/**
|
|
1048
|
+
* Per-id data the caller already holds (location/icon/title). Anything
|
|
1049
|
+
* provided skips the corresponding lookup.
|
|
1050
|
+
*/
|
|
1051
|
+
dataById?: Record<number, HighlightPoiData>;
|
|
1052
|
+
/** Icon size in points: a number (square) or `[width, height]`. Default 56. */
|
|
1053
|
+
iconSize?: number | [number, number];
|
|
1054
|
+
/** Flies the camera to the highlighted POI(s) once resolved. Default `false`. */
|
|
1055
|
+
panTo?: boolean;
|
|
1056
|
+
/** Target zoom for `panTo` of a single POI. Default `13`. */
|
|
1057
|
+
zoom?: number;
|
|
1058
|
+
/** Clusters the highlight markers (`true` or a config object). */
|
|
1059
|
+
clustering?: ClusteringConfig;
|
|
1060
|
+
/** Called when a highlight marker is pressed. */
|
|
1061
|
+
onHighlightPress?: (info: PoiHighlightPressInfo) => void;
|
|
1062
|
+
/** Called when a POI could not be resolved (its highlight is rolled back). */
|
|
1063
|
+
onResolveError?: (id: number) => void;
|
|
1064
|
+
};
|
|
1065
|
+
/**
|
|
1066
|
+
* Declarative counterpart of the web SDK's `highlightPOI()`: renders an
|
|
1067
|
+
* animated icon+label marker for each highlighted POI id, resolving each id
|
|
1068
|
+
* cheapest-first (caller data → rendered tiles → place-detail API).
|
|
1069
|
+
* Highlight state is owned by the `ids` prop (or
|
|
1070
|
+
* `useYarrowPoiHighlight().highlightedIds`); removing an id plays the exit
|
|
1071
|
+
* animation and unmounts the marker.
|
|
1072
|
+
*
|
|
1073
|
+
* Known native limitation (documented in the README): the base style's own
|
|
1074
|
+
* POI icon is not hidden behind the highlight marker — native has no runtime
|
|
1075
|
+
* `setFilter`, so the marker simply draws on top of it.
|
|
1076
|
+
*
|
|
1077
|
+
* ```tsx
|
|
1078
|
+
* <YarrowMapView apiKey={KEY} center={[69.2401, 41.2995]}>
|
|
1079
|
+
* <PoiHighlightLayer ids={[123]} dataById={{ 123: { location } }} panTo />
|
|
1080
|
+
* </YarrowMapView>
|
|
1081
|
+
* ```
|
|
1082
|
+
*/
|
|
1083
|
+
export declare function PoiHighlightLayer({ ids, dataById, iconSize, panTo, zoom, clustering, onHighlightPress, onResolveError }: PoiHighlightLayerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
1084
|
+
/** Camera state snapshot delivered to region-change subscribers. */
|
|
1085
|
+
type YarrowRegionState = {
|
|
1086
|
+
/** Map center as `[lng, lat]`. */
|
|
1087
|
+
center: [number, number];
|
|
1088
|
+
zoom: number;
|
|
1089
|
+
};
|
|
1090
|
+
/** A raw map press, delivered to press subscribers before `onPress` props. */
|
|
1091
|
+
type YarrowMapPress = {
|
|
1092
|
+
/** Press location as `[lng, lat]`. */
|
|
1093
|
+
lngLat: [number, number];
|
|
1094
|
+
/** Press location in viewport pixels `[x, y]` (for `queryRenderedFeatures`). */
|
|
1095
|
+
point: [number, number];
|
|
1096
|
+
};
|
|
1097
|
+
/**
|
|
1098
|
+
* Shared runtime state that `<YarrowMapView>` provides to the layers and hooks
|
|
1099
|
+
* rendered inside it. Everything is optional at the type level so hooks can
|
|
1100
|
+
* also run outside a map (they no-op with a console warning where relevant).
|
|
1101
|
+
*/
|
|
1102
|
+
type YarrowMapRuntime = {
|
|
640
1103
|
apiKey: string;
|
|
641
|
-
/**
|
|
642
|
-
|
|
1104
|
+
/** Visual theme of the map, for theme-aware overlay styling. */
|
|
1105
|
+
theme: 'light' | 'dark';
|
|
1106
|
+
mapRef: RefObject<MapRef$1 | null>;
|
|
1107
|
+
cameraRef: RefObject<CameraRef$1 | null>;
|
|
1108
|
+
/** Icon registry: sprite name → image URL (empty until loaded / disabled). */
|
|
1109
|
+
iconsByName: Record<string, string>;
|
|
1110
|
+
/**
|
|
1111
|
+
* POI ids currently highlighted by `<PoiHighlightLayer>` — a mutable set
|
|
1112
|
+
* (no re-renders) so press handlers can report the web SDK's `selected`
|
|
1113
|
+
* flag. Updated by the layer; read by `useYarrowLayerPress`.
|
|
1114
|
+
*/
|
|
1115
|
+
highlightedPoiIds: RefObject<Set<number>>;
|
|
1116
|
+
/**
|
|
1117
|
+
* Subscribes to region changes (the `moveend` parity point). Returns an
|
|
1118
|
+
* unsubscribe function.
|
|
1119
|
+
*/
|
|
1120
|
+
subscribeRegionChange: (listener: (state: YarrowRegionState) => void) => () => void;
|
|
1121
|
+
/**
|
|
1122
|
+
* Subscribes to raw map presses. Returns an unsubscribe function.
|
|
1123
|
+
*/
|
|
1124
|
+
subscribePress: (listener: (press: YarrowMapPress) => void) => () => void;
|
|
643
1125
|
};
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
1126
|
+
export declare const YarrowMapContext: import("react").Context<YarrowMapRuntime | null>;
|
|
1127
|
+
/** Reads the enclosing `<YarrowMapView>` runtime, or `null` outside one. */
|
|
1128
|
+
export declare function useYarrowMapRuntime(): YarrowMapRuntime | null;
|
|
1129
|
+
/** The base style's POI symbol layer (`node_tile` source). */
|
|
1130
|
+
export declare const POI_BASE_LAYER = "pois_tile_layer";
|
|
1131
|
+
/**
|
|
1132
|
+
* Fetches a POI's coordinates and icon from the place-detail API — the
|
|
1133
|
+
* off-screen / below-zoom fallback of the resolution chain. Returns `null`
|
|
1134
|
+
* on any failure or missing coordinates (web parity).
|
|
1135
|
+
*/
|
|
1136
|
+
export declare function fetchPlaceLocation(id: number): Promise<ResolvedPoiData | null>;
|
|
1137
|
+
/**
|
|
1138
|
+
* Reads a POI's point geometry from the style's POI layer within the current
|
|
1139
|
+
* viewport — the free, no-network resolution step. Native can only query
|
|
1140
|
+
* *rendered* features (no `querySourceFeatures` on undeclared sources), so
|
|
1141
|
+
* off-screen POIs fall through to the place-detail API. Icons are resolved
|
|
1142
|
+
* best-effort from the registry via the feature's `node_type`.
|
|
1143
|
+
*/
|
|
1144
|
+
export declare function lookupPoiInViewport(mapRef: MapRef$1, id: number, iconsByName?: Record<string, string>): Promise<ResolvedPoiData | null>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Resolves a POI's coordinates, icon and title cheapest-first:
|
|
1147
|
+
* 1. caller-provided `location` / `icon` / `title`
|
|
1148
|
+
* 2. local lookup in the rendered POI layer (no network)
|
|
1149
|
+
* 3. the place-detail API (off-screen / below the POI zoom range, or when
|
|
1150
|
+
* anything is still missing — web parity: the API fills icon and title
|
|
1151
|
+
* too, not just coordinates)
|
|
1152
|
+
*
|
|
1153
|
+
* The web SDK additionally evaluates the style's `icon-image` expression for
|
|
1154
|
+
* the tile step; native approximates it with a registry lookup by
|
|
1155
|
+
* `node_type`. Coordinate resolution is the hard requirement — if it fails,
|
|
1156
|
+
* the highlight is rolled back by the caller.
|
|
1157
|
+
*/
|
|
1158
|
+
export declare function resolvePoiData(id: number, options: HighlightPoiData, runtime: YarrowMapRuntime): Promise<ResolvedPoiData | null>;
|
|
1159
|
+
/** Handle for one active highlight — mirrors the web SDK's `POIHighlight`. */
|
|
1160
|
+
type YarrowPoiHighlight = {
|
|
1161
|
+
readonly id: number;
|
|
1162
|
+
remove: () => void;
|
|
1163
|
+
};
|
|
1164
|
+
type UseYarrowPoiHighlightResult = {
|
|
1165
|
+
/** All currently highlighted ids — feed to `<PoiHighlightLayer ids={…}>`. */
|
|
1166
|
+
highlightedIds: number[];
|
|
1167
|
+
/**
|
|
1168
|
+
* Highlights one or more POIs. Additive by default (web parity); pass
|
|
1169
|
+
* `{ replace: true }` to reset the selection first. Returns one handle per
|
|
1170
|
+
* id whose `remove()` un-highlights it.
|
|
1171
|
+
*/
|
|
1172
|
+
highlight: (input: number | number[], options?: {
|
|
1173
|
+
replace?: boolean;
|
|
1174
|
+
}) => YarrowPoiHighlight[];
|
|
1175
|
+
/** Un-highlights all POIs, or the given id(s). */
|
|
1176
|
+
reset: (input?: number | number[]) => void;
|
|
1177
|
+
/** Whether a POI id is currently highlighted. */
|
|
1178
|
+
isHighlighted: (id: number) => boolean;
|
|
660
1179
|
};
|
|
661
1180
|
/**
|
|
662
|
-
*
|
|
663
|
-
* `
|
|
664
|
-
* `
|
|
1181
|
+
* Headless highlight state — the declarative counterpart of the web SDK's
|
|
1182
|
+
* `highlightPOI` / `resetPOIHighlight` / `isPOIHighlighted` /
|
|
1183
|
+
* `getHighlightedPOIs` quartet. Rendering is owned by `<PoiHighlightLayer>`:
|
|
665
1184
|
*
|
|
666
1185
|
* ```tsx
|
|
667
|
-
* const {
|
|
668
|
-
*
|
|
1186
|
+
* const { highlightedIds, highlight } = useYarrowPoiHighlight();
|
|
1187
|
+
* <YarrowMapView apiKey={KEY}>
|
|
1188
|
+
* <PoiHighlightLayer ids={highlightedIds} panTo />
|
|
1189
|
+
* </YarrowMapView>
|
|
669
1190
|
* ```
|
|
670
1191
|
*/
|
|
671
|
-
export declare
|
|
1192
|
+
export declare function useYarrowPoiHighlight(): UseYarrowPoiHighlightResult;
|
|
1193
|
+
type SearchResultsLayerProps = {
|
|
1194
|
+
/** Results from `useYarrowSearch` (or your own fetch). */
|
|
1195
|
+
results: SearchResult[];
|
|
1196
|
+
/** Icon size in points: a number (square) or `[width, height]`. Default 56. */
|
|
1197
|
+
iconSize?: number | [number, number];
|
|
1198
|
+
/**
|
|
1199
|
+
* Fits the camera to the results the first time a non-empty page renders
|
|
1200
|
+
* (default `true`). The fit runs once per session — pass a `fitKey` to
|
|
1201
|
+
* start a new session (web parity: the web fits once per
|
|
1202
|
+
* `highlightSearchResults()` call, so a new query re-fits).
|
|
1203
|
+
*/
|
|
1204
|
+
zoomToResults?: boolean;
|
|
1205
|
+
/**
|
|
1206
|
+
* Session identity for `zoomToResults`: changing it re-arms the initial
|
|
1207
|
+
* fit, e.g. `fitKey={query}` re-fits when the query changes (web parity).
|
|
1208
|
+
* Omitted (or unchanged) = fit once per mount.
|
|
1209
|
+
*/
|
|
1210
|
+
fitKey?: string | number;
|
|
1211
|
+
/** Clusters the result markers (`true` or a config object). */
|
|
1212
|
+
clustering?: ClusteringConfig;
|
|
1213
|
+
/** Called when a result marker is pressed. */
|
|
1214
|
+
onResultPress?: (lat: number, lng: number, result: SearchResult) => void;
|
|
1215
|
+
};
|
|
1216
|
+
/**
|
|
1217
|
+
* Renders search results on the map — the declarative counterpart of the web
|
|
1218
|
+
* SDK's `highlightSearchResults()`. Icon precedence per result:
|
|
1219
|
+
* `icon_img` → registry icon by `category.name` → blue-dot fallback.
|
|
1220
|
+
*
|
|
1221
|
+
* ```tsx
|
|
1222
|
+
* const { results, isLoading } = useYarrowSearch(query, { lat, lon });
|
|
1223
|
+
* <YarrowMapView apiKey={KEY}>
|
|
1224
|
+
* <SearchResultsLayer results={results} onResultPress={…} />
|
|
1225
|
+
* </YarrowMapView>
|
|
1226
|
+
* ```
|
|
1227
|
+
*/
|
|
1228
|
+
export declare function SearchResultsLayer({ results, iconSize, zoomToResults, fitKey, clustering, onResultPress }: SearchResultsLayerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
672
1229
|
/**
|
|
673
1230
|
* Minimal slice of `@react-native-async-storage/async-storage` the adapter
|
|
674
1231
|
* needs. Accepting a structural type (instead of importing the module) keeps
|
|
@@ -699,4 +1256,4 @@ type AsyncStorageLike = {
|
|
|
699
1256
|
* ```
|
|
700
1257
|
*/
|
|
701
1258
|
export declare function setAsyncStorageTokenStorage(storage: AsyncStorageLike): Promise<void>;
|
|
702
|
-
export { type AsyncStorageLike, type BuildRouteInput, type CacheConfig, type CachedArrayBufferResponse, type CameraRef, type FetchRoutesInput, type FetchRoutesResult, type MapRef, type NormalizedCacheConfig, type OfflineBounds, type OfflineRegionDownloadOptions, type OfflineRegionErrorCode, type OfflineRegionEstimate, type OfflineRegionHandle, type OfflineRegionProgress, type OfflineRegionSummary, type RouteDirection, type RouteDirectionModifier, type RouteFeature, type RouteLayerProps, type RoutesMeta, type SearchResult, type TokenStorage, type UseYarrowOfflineRegionsOptions, type UseYarrowOfflineRegionsResult, type UseYarrowRoutingOptions, type UseYarrowRoutingResult, type UseYarrowSearchOptions, type UseYarrowSearchResult, YARROW_MAP_URL, YARROW_SEARCH_API_URL, type YarrowMapConfigOptions, type YarrowMapViewProps, type YarrowOfflineError, type YarrowOfflineManagerOptions, type YarrowStyleType };
|
|
1259
|
+
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 };
|