@yarrow-uz/yarrow-map-web-sdk 1.0.46 → 1.0.47
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 +16 -0
- package/README.md +28 -1015
- package/dist/main.js +3 -3
- package/dist/maps/cache.d.ts +17 -0
- package/dist/maps/config.d.ts +18 -0
- package/dist/maps/events.d.ts +13 -0
- package/dist/maps/layers.d.ts +21 -0
- package/dist/maps/markers.d.ts +12 -0
- package/dist/maps/navigation.d.ts +15 -0
- package/dist/maps/routing/builder.d.ts +34 -0
- package/dist/maps/routing/helpers.d.ts +15 -0
- package/dist/maps/routing/renderer.d.ts +8 -0
- package/dist/maps/routing/types.d.ts +41 -0
- package/dist/maps/search.d.ts +23 -0
- package/dist/maps/styles.d.ts +29 -0
- package/dist/maps/types.d.ts +111 -0
- package/dist/maps/yarrow.d.ts +46 -127
- package/dist/maps/yarrowControls.d.ts +0 -1
- package/dist/module.js +3 -3
- package/dist/react/index.js +1 -1
- package/dist/react/useYarrowMap.d.ts +1 -0
- package/package.json +8 -7
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type RequestParameters, ResourceType } from 'maplibre-gl';
|
|
2
|
+
import { TILE_CACHE_NAME, ICON_CACHE_NAME, CACHE_PROTOCOL, type NormalizedCacheConfig, type CachedArrayBufferResponse } from './types';
|
|
3
|
+
export declare const hasCacheStorage: () => boolean;
|
|
4
|
+
export declare const normalizeCacheConfig: (cache?: {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
lifespanDays?: number;
|
|
7
|
+
}) => NormalizedCacheConfig;
|
|
8
|
+
export declare const resolveRequestUrl: (url: string, baseUrl?: string) => string;
|
|
9
|
+
export declare const buildProtocolUrl: (url: string, lifespanMs: number) => string;
|
|
10
|
+
export declare const extractCachedAt: (response: Response) => number | null;
|
|
11
|
+
export declare const toCachedArrayBufferResponse: (response: Response) => Promise<CachedArrayBufferResponse>;
|
|
12
|
+
export declare const fetchFromNetwork: (url: string, abortController: AbortController, requestParameters?: RequestParameters) => Promise<CachedArrayBufferResponse>;
|
|
13
|
+
export declare const fetchArrayBufferWithCache: (url: string, cacheName: string, lifespanMs: number, abortController: AbortController, requestParameters?: RequestParameters) => Promise<CachedArrayBufferResponse>;
|
|
14
|
+
export declare const getDefaultLifespanMs: () => number;
|
|
15
|
+
export declare const isCacheableResourceType: (resourceType?: ResourceType) => boolean;
|
|
16
|
+
export { TILE_CACHE_NAME, ICON_CACHE_NAME, CACHE_PROTOCOL };
|
|
17
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BrandBadgePosition } from './brandBadge';
|
|
2
|
+
import { normalizeYarrowControlsConfig } from './yarrowControls';
|
|
3
|
+
import type { YarrowMapConfigOptions, NormalizedCacheConfig } from './types';
|
|
4
|
+
export declare class YarrowMapConfig {
|
|
5
|
+
readonly container: HTMLElement | string;
|
|
6
|
+
readonly center: [number, number];
|
|
7
|
+
readonly zoom: number;
|
|
8
|
+
readonly minZoom: number;
|
|
9
|
+
readonly maxZoom: number;
|
|
10
|
+
theme: 'light' | 'dark';
|
|
11
|
+
cache: NormalizedCacheConfig;
|
|
12
|
+
brandBadgePosition: BrandBadgePosition;
|
|
13
|
+
controls: ReturnType<typeof normalizeYarrowControlsConfig>;
|
|
14
|
+
excludePoiLayer: boolean;
|
|
15
|
+
apiKey: string;
|
|
16
|
+
constructor(config: YarrowMapConfigOptions);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Map as MaplibreMap } from 'maplibre-gl';
|
|
2
|
+
import type { LayerDescriptor } from './types';
|
|
3
|
+
export declare class YarrowEventManager {
|
|
4
|
+
private getMap;
|
|
5
|
+
private getLayers;
|
|
6
|
+
constructor(getMap: () => MaplibreMap | undefined, getLayers: () => LayerDescriptor[]);
|
|
7
|
+
onMoveEnd(callback: (lat: number, lng: number, zoom: number) => void): void;
|
|
8
|
+
onMapClick(callback: (lat: number, lng: number) => void): void;
|
|
9
|
+
onIconClick(layerGroup: 'pois' | 'buildings', callback: (lat: number, lng: number, properties: Record<string, unknown>) => void): void;
|
|
10
|
+
onLayerClick(layerName: 'buildings' | 'pois', callback: (lat: number, lng: number, properties: Record<string, unknown>) => void): void;
|
|
11
|
+
changeBackgroundColor(color: string): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Map as MaplibreMap } from 'maplibre-gl';
|
|
2
|
+
import type { GeoJSONSourceSpecification, LayerSpecification, FeatureIdentifier, MapGeoJSONFeature, QueryRenderedFeaturesOptions, PointLike } from 'maplibre-gl';
|
|
3
|
+
import type { LayerDescriptor, AddLayerOptions } from './types';
|
|
4
|
+
export declare class YarrowLayerManager {
|
|
5
|
+
private getMap;
|
|
6
|
+
private setLayers?;
|
|
7
|
+
private layers;
|
|
8
|
+
constructor(getMap: () => MaplibreMap | undefined, setLayers?: ((layers: LayerDescriptor[]) => void) | undefined);
|
|
9
|
+
getLayers(): LayerDescriptor[];
|
|
10
|
+
setLayersArray(layers: LayerDescriptor[]): void;
|
|
11
|
+
addSource(sourceId: string, data: GeoJSONSourceSpecification['data']): void;
|
|
12
|
+
updateSourceData(sourceId: string, data: GeoJSONSourceSpecification['data']): void;
|
|
13
|
+
addLayer(layerName: string, layerType: LayerSpecification['type'], featureCollection: GeoJSONSourceSpecification['data'], paint?: LayerSpecification['paint'], layout?: LayerSpecification['layout'], iconSettings?: {
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
}, options?: AddLayerOptions): void;
|
|
17
|
+
removeLayer(layerName: string): void;
|
|
18
|
+
setFeatureState(feature: FeatureIdentifier, state: Record<string, unknown>): void;
|
|
19
|
+
queryRenderedFeatures(geometryOrOptions?: PointLike | [PointLike, PointLike] | QueryRenderedFeaturesOptions, options?: QueryRenderedFeaturesOptions): MapGeoJSONFeature[];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=layers.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Marker, type Map as MaplibreMap, type MarkerOptions } from 'maplibre-gl';
|
|
2
|
+
interface YarrowMarkerOptions extends MarkerOptions {
|
|
3
|
+
onClick?: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare class YarrowMarkerManager {
|
|
6
|
+
private getMap;
|
|
7
|
+
constructor(getMap: () => MaplibreMap | undefined);
|
|
8
|
+
addMarker(coordinates: [number, number], options?: YarrowMarkerOptions): Marker | null;
|
|
9
|
+
removeMarker(marker: Marker | null): void;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=markers.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Map as MaplibreMap } from 'maplibre-gl';
|
|
2
|
+
import type { BoundsInput } from './types';
|
|
3
|
+
export declare class YarrowNavigationManager {
|
|
4
|
+
private getMap;
|
|
5
|
+
constructor(getMap: () => MaplibreMap | undefined);
|
|
6
|
+
zoomTo(lat: number, lng: number, zoom: number): void;
|
|
7
|
+
fitBounds(data: BoundsInput): void;
|
|
8
|
+
getBoundingBox(data: BoundsInput): {
|
|
9
|
+
xMin: number;
|
|
10
|
+
xMax: number;
|
|
11
|
+
yMin: number;
|
|
12
|
+
yMax: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RouteFeature } from '../types';
|
|
2
|
+
import type { YarrowLayerManager } from '../layers';
|
|
3
|
+
import type { BuildRouteOptions, BuildRouteResult } from './types';
|
|
4
|
+
export declare class YarrowRoutingRenderer {
|
|
5
|
+
private addLayer;
|
|
6
|
+
constructor(addLayer: YarrowLayerManager['addLayer']);
|
|
7
|
+
renderRoutes(routes: RouteFeature[], baseLayerName?: string): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class YarrowRoutingBuilder {
|
|
10
|
+
private getMap;
|
|
11
|
+
private addLayer;
|
|
12
|
+
private removeLayer;
|
|
13
|
+
private fitBounds;
|
|
14
|
+
constructor(getMap: () => maplibregl.Map | undefined, addLayer: YarrowLayerManager['addLayer'], removeLayer: YarrowLayerManager['removeLayer'], fitBounds: (data: {
|
|
15
|
+
type?: string;
|
|
16
|
+
features: Array<{
|
|
17
|
+
geometry?: {
|
|
18
|
+
type?: string;
|
|
19
|
+
coordinates?: unknown;
|
|
20
|
+
};
|
|
21
|
+
}>;
|
|
22
|
+
}) => void);
|
|
23
|
+
buildRoute(options: BuildRouteOptions): Promise<BuildRouteResult>;
|
|
24
|
+
buildRouteWithLabels(startCoordinates: [number, number], endCoordinates: [number, number], profile: string): Promise<{
|
|
25
|
+
features: RouteFeature[];
|
|
26
|
+
directions: unknown[];
|
|
27
|
+
}>;
|
|
28
|
+
buildMultiSegmentRouteWithLabels(coordinates: [number, number][], profile: string, language?: string): Promise<{
|
|
29
|
+
features: RouteFeature[];
|
|
30
|
+
directions: unknown[][];
|
|
31
|
+
}>;
|
|
32
|
+
clearAllRoutes(): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { RouteFeature } from '../types';
|
|
2
|
+
export declare const POPUP_CSS = "position: absolute; padding: 6px 12px; background: #fff; border: 1px solid #ccc; border-radius: 6px; font-size: 13px; font-weight: 500; box-shadow: 0 2px 6px rgba(0,0,0,0.15); pointer-events: none; z-index: 9999;";
|
|
3
|
+
export declare const createPopupElement: (labelText: string, x: number, y: number) => HTMLDivElement;
|
|
4
|
+
export declare const removeAllRoutePopups: () => void;
|
|
5
|
+
export declare const formatDuration: (minutes: number) => string;
|
|
6
|
+
export declare const formatDistance: (meters: number) => string;
|
|
7
|
+
export declare const formatRouteLabel: (duration: number, distance: number, isBest: boolean, bestDuration?: number) => string;
|
|
8
|
+
export declare const getMidpointCoordinates: (coordinates: [number, number][]) => [number, number];
|
|
9
|
+
export declare const createRouteLabelFeature: (coordinates: [number, number], labelText: string) => GeoJSON.Feature;
|
|
10
|
+
export declare const createHoverPopup: (map: maplibregl.Map, e: maplibregl.MapMouseEvent, labelText: string) => HTMLDivElement | null;
|
|
11
|
+
export declare const createClickPopup: (map: maplibregl.Map, coordinates: [number, number], labelText: string) => HTMLDivElement | null;
|
|
12
|
+
export declare const setupMoveListenerForPopup: (map: maplibregl.Map, coordinates: [number, number]) => void;
|
|
13
|
+
export declare const clearOldRouteLayers: (removeLayer: (layerId: string) => void) => void;
|
|
14
|
+
export declare const transformRouteCoordinates: (features: RouteFeature[]) => RouteFeature[];
|
|
15
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { YarrowLayerManager } from '../layers';
|
|
2
|
+
import type { RouteFeature } from '../types';
|
|
3
|
+
export declare class YarrowRoutingRenderer {
|
|
4
|
+
private addLayer;
|
|
5
|
+
constructor(addLayer: YarrowLayerManager['addLayer']);
|
|
6
|
+
renderRoutes(routes: RouteFeature[], baseLayerName?: string): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RouteFeature } from '../types';
|
|
2
|
+
export declare const ROUTE_LAYER_COLORS: string[];
|
|
3
|
+
export declare const MAX_ROUTE_INDEX = 5;
|
|
4
|
+
export declare const ROUTE_API_URL = "https://api.yarrow.uz/api/routing/route";
|
|
5
|
+
export interface BuildRouteOptions {
|
|
6
|
+
profile: string;
|
|
7
|
+
coordinates: [number, number][];
|
|
8
|
+
routeColor?: string;
|
|
9
|
+
routeWidth?: number;
|
|
10
|
+
routeOpacity?: number;
|
|
11
|
+
alternativeColor?: string;
|
|
12
|
+
alternativeWidth?: number;
|
|
13
|
+
alternativeOpacity?: number;
|
|
14
|
+
showLabels?: boolean;
|
|
15
|
+
labelFont?: string[];
|
|
16
|
+
labelSize?: number;
|
|
17
|
+
labelOffset?: [number, number];
|
|
18
|
+
labelAnchor?: 'top' | 'bottom' | 'left' | 'right' | 'center';
|
|
19
|
+
fitBounds?: boolean;
|
|
20
|
+
clearOldRoutes?: boolean;
|
|
21
|
+
language?: string;
|
|
22
|
+
layerPrefix?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface BuildRouteResult {
|
|
25
|
+
features: RouteFeature[];
|
|
26
|
+
directions: RouteDirection[][];
|
|
27
|
+
meta: {
|
|
28
|
+
profile: string;
|
|
29
|
+
totalRoutes: number;
|
|
30
|
+
bestRouteIndex: number;
|
|
31
|
+
duration: number;
|
|
32
|
+
distance: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export type RouteDirection = {
|
|
36
|
+
distance: number;
|
|
37
|
+
duration: number;
|
|
38
|
+
instruction: string;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Map as MaplibreMap } from 'maplibre-gl';
|
|
2
|
+
import type { SearchResult, BoundsInput } from './types';
|
|
3
|
+
import type { YarrowLayerManager } from './layers';
|
|
4
|
+
type SearchOptions = {
|
|
5
|
+
layerName?: string;
|
|
6
|
+
iconImage?: string;
|
|
7
|
+
highlightColor?: string;
|
|
8
|
+
pulseAnimation?: boolean;
|
|
9
|
+
zoomToResults?: boolean;
|
|
10
|
+
onIconClick?: (lat: number, lng: number, properties: Record<string, unknown>) => void;
|
|
11
|
+
onResultsUpdate?: (results: SearchResult[]) => void;
|
|
12
|
+
onLoadingStateChange?: (state: 'firstRender' | 'rerender' | false) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare class YarrowSearchManager {
|
|
15
|
+
private getMap;
|
|
16
|
+
private fitBounds;
|
|
17
|
+
private addLayer;
|
|
18
|
+
private removeLayer;
|
|
19
|
+
constructor(getMap: () => MaplibreMap | undefined, fitBounds: (data: BoundsInput) => void, addLayer: YarrowLayerManager['addLayer'], removeLayer: YarrowLayerManager['removeLayer']);
|
|
20
|
+
highlightSearchResults(query: string, highlightOptions?: SearchOptions): () => void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=search.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { StyleSpecification } from 'maplibre-gl';
|
|
2
|
+
import { type BrandBadgeController } from './brandBadge';
|
|
3
|
+
import type { YarrowMapConfig } from './config';
|
|
4
|
+
import type { BrandBadgePosition, LayerDescriptor } from './types';
|
|
5
|
+
import type { YarrowControlsController } from './yarrowControls';
|
|
6
|
+
export declare class YarrowStylesManager {
|
|
7
|
+
private getMap;
|
|
8
|
+
private config;
|
|
9
|
+
private fetchJson;
|
|
10
|
+
private fixStyle;
|
|
11
|
+
private getIconsMap;
|
|
12
|
+
private addIconsToMap;
|
|
13
|
+
private badgeController;
|
|
14
|
+
private controlsController;
|
|
15
|
+
private syncCollision;
|
|
16
|
+
private updateLayersArray;
|
|
17
|
+
private setLayers?;
|
|
18
|
+
private layers;
|
|
19
|
+
constructor(getMap: () => maplibregl.Map | undefined, config: YarrowMapConfig, fetchJson: <T>(url: string, cacheName: string) => Promise<T>, fixStyle: (style: StyleSpecification) => void, getIconsMap: () => Promise<Record<string, string>>, addIconsToMap: (icons: Record<string, string>) => Promise<void>, badgeController: BrandBadgeController, controlsController: YarrowControlsController, syncCollision: () => void, updateLayersArray: (style: StyleSpecification) => void, setLayers?: ((layers: LayerDescriptor[]) => void) | undefined);
|
|
20
|
+
setLayersArray(layers: LayerDescriptor[]): void;
|
|
21
|
+
changeStyles(styleType?: string): Promise<StyleSpecification>;
|
|
22
|
+
changeTheme(theme: 'light' | 'dark'): Promise<StyleSpecification>;
|
|
23
|
+
changeBrandBadgePosition(position: BrandBadgePosition): BrandBadgePosition;
|
|
24
|
+
getControlsInsetForCollision(controlsPosition: 'left-top' | 'left-bottom' | 'right-top' | 'right-bottom', badgePosition: BrandBadgePosition, badgeHeight: number): {
|
|
25
|
+
top?: number;
|
|
26
|
+
bottom?: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { GeoJSONSourceSpecification, LayerSpecification, MapGeoJSONFeature, FeatureIdentifier, PointLike, QueryRenderedFeaturesOptions, RequestParameters, StyleSpecification } from 'maplibre-gl';
|
|
2
|
+
import type { FilterSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
3
|
+
import type { BrandBadgePosition } from './brandBadge';
|
|
4
|
+
import type { YarrowControlsConfig, YarrowControlsPosition } from './yarrowControls';
|
|
5
|
+
export type { BrandBadgePosition };
|
|
6
|
+
export type { YarrowControlsConfig, YarrowControlsPosition };
|
|
7
|
+
export type CacheConfig = {
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
lifespanDays?: number;
|
|
10
|
+
};
|
|
11
|
+
export type NormalizedCacheConfig = {
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
lifespanDays: number;
|
|
14
|
+
};
|
|
15
|
+
export type CachedArrayBufferResponse = {
|
|
16
|
+
data: ArrayBuffer;
|
|
17
|
+
cacheControl: string | null;
|
|
18
|
+
expires: string | null;
|
|
19
|
+
contentType: string | null;
|
|
20
|
+
};
|
|
21
|
+
export type LayerDescriptor = {
|
|
22
|
+
type: string;
|
|
23
|
+
name: string;
|
|
24
|
+
};
|
|
25
|
+
export type AddLayerOptions = {
|
|
26
|
+
sourceId?: string;
|
|
27
|
+
filter?: FilterSpecification;
|
|
28
|
+
};
|
|
29
|
+
export type StyleLayerLike = {
|
|
30
|
+
id: string;
|
|
31
|
+
type?: string;
|
|
32
|
+
source?: string;
|
|
33
|
+
'source-layer'?: string;
|
|
34
|
+
layout?: Record<string, unknown>;
|
|
35
|
+
};
|
|
36
|
+
export type BoundsInput = {
|
|
37
|
+
type?: string;
|
|
38
|
+
features: Array<{
|
|
39
|
+
geometry?: {
|
|
40
|
+
type?: string;
|
|
41
|
+
coordinates?: unknown;
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
export type GeoJsonDataObject = Exclude<GeoJSONSourceSpecification['data'], string>;
|
|
46
|
+
export type RouteFeature = {
|
|
47
|
+
type: 'Feature';
|
|
48
|
+
geometry: {
|
|
49
|
+
type: 'LineString';
|
|
50
|
+
coordinates: [number, number][];
|
|
51
|
+
};
|
|
52
|
+
properties: {
|
|
53
|
+
duration: number;
|
|
54
|
+
distance: number;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export type RouteBuildResult = {
|
|
59
|
+
features: RouteFeature[];
|
|
60
|
+
directions: unknown[];
|
|
61
|
+
};
|
|
62
|
+
export type MultiRouteBuildResult = {
|
|
63
|
+
features: RouteFeature[];
|
|
64
|
+
directions: unknown[][];
|
|
65
|
+
};
|
|
66
|
+
export type IconListItem = {
|
|
67
|
+
icon_image_name: string;
|
|
68
|
+
icon_image_url: string;
|
|
69
|
+
};
|
|
70
|
+
export type SearchResult = {
|
|
71
|
+
id?: string | number;
|
|
72
|
+
latitude?: number;
|
|
73
|
+
longitude?: number;
|
|
74
|
+
icon_img?: string;
|
|
75
|
+
name?: string;
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
};
|
|
78
|
+
export type YarrowMapConfigOptions = {
|
|
79
|
+
container: HTMLElement | string;
|
|
80
|
+
center: [number, number];
|
|
81
|
+
zoom?: number;
|
|
82
|
+
minZoom?: number;
|
|
83
|
+
maxZoom?: number;
|
|
84
|
+
theme?: 'light' | 'dark';
|
|
85
|
+
cache?: CacheConfig;
|
|
86
|
+
brandBadgePosition?: BrandBadgePosition;
|
|
87
|
+
controls?: YarrowControlsConfig;
|
|
88
|
+
excludePoiLayer?: boolean;
|
|
89
|
+
apiKey: string;
|
|
90
|
+
};
|
|
91
|
+
export type SearchOptions = {
|
|
92
|
+
layerName?: string;
|
|
93
|
+
iconImage?: string;
|
|
94
|
+
highlightColor?: string;
|
|
95
|
+
pulseAnimation?: boolean;
|
|
96
|
+
zoomToResults?: boolean;
|
|
97
|
+
onIconClick?: (lat: number, lng: number, properties: Record<string, unknown>) => void;
|
|
98
|
+
onResultsUpdate?: (results: SearchResult[]) => void;
|
|
99
|
+
onLoadingStateChange?: (state: 'firstRender' | 'rerender' | false) => void;
|
|
100
|
+
};
|
|
101
|
+
export declare const OVERLAY_COLLISION_GAP_PX = 8;
|
|
102
|
+
export declare const ROUTE_COLORS: string[];
|
|
103
|
+
export declare const DEFAULT_CACHE_ENABLED = false;
|
|
104
|
+
export declare const DEFAULT_CACHE_LIFESPAN_DAYS = 30;
|
|
105
|
+
export declare const MILLISECONDS_PER_DAY: number;
|
|
106
|
+
export declare const TILE_CACHE_NAME = "yarrow-cache-v1-tile";
|
|
107
|
+
export declare const ICON_CACHE_NAME = "yarrow-cache-v1-icon";
|
|
108
|
+
export declare const CACHE_PROTOCOL = "yarrowcache";
|
|
109
|
+
export declare const CACHED_AT_HEADER = "x-yarrow-cached-at";
|
|
110
|
+
export type { GeoJSONSourceSpecification, LayerSpecification, MapGeoJSONFeature, FeatureIdentifier, PointLike, QueryRenderedFeaturesOptions, RequestParameters, StyleSpecification, };
|
|
111
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/maps/yarrow.d.ts
CHANGED
|
@@ -1,99 +1,33 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
type
|
|
6
|
-
|
|
7
|
-
lifespanDays?: number;
|
|
8
|
-
};
|
|
9
|
-
type YarrowMapConfigOptions = {
|
|
10
|
-
container: HTMLElement | string;
|
|
11
|
-
center: [number, number];
|
|
12
|
-
zoom?: number;
|
|
13
|
-
minZoom?: number;
|
|
14
|
-
maxZoom?: number;
|
|
15
|
-
theme?: 'light' | 'dark';
|
|
16
|
-
cache?: CacheConfig;
|
|
17
|
-
brandBadgePosition?: BrandBadgePosition;
|
|
18
|
-
controls?: YarrowControlsConfig;
|
|
19
|
-
apiKey: string;
|
|
20
|
-
};
|
|
21
|
-
type NormalizedCacheConfig = {
|
|
22
|
-
enabled: boolean;
|
|
23
|
-
lifespanDays: number;
|
|
24
|
-
};
|
|
25
|
-
type LayerDescriptor = {
|
|
26
|
-
type: string;
|
|
27
|
-
name: string;
|
|
28
|
-
};
|
|
29
|
-
type AddLayerOptions = {
|
|
30
|
-
sourceId?: string;
|
|
31
|
-
filter?: FilterSpecification;
|
|
32
|
-
};
|
|
33
|
-
type BoundsInput = {
|
|
34
|
-
type?: string;
|
|
35
|
-
features: Array<{
|
|
36
|
-
geometry?: {
|
|
37
|
-
type?: string;
|
|
38
|
-
coordinates?: unknown;
|
|
39
|
-
};
|
|
40
|
-
}>;
|
|
41
|
-
};
|
|
42
|
-
type RouteFeature = {
|
|
43
|
-
type: 'Feature';
|
|
44
|
-
geometry: {
|
|
45
|
-
type: 'LineString';
|
|
46
|
-
coordinates: [number, number][];
|
|
47
|
-
};
|
|
48
|
-
properties: {
|
|
49
|
-
duration: number;
|
|
50
|
-
distance: number;
|
|
51
|
-
[key: string]: unknown;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
type RouteBuildResult = {
|
|
55
|
-
features: RouteFeature[];
|
|
56
|
-
directions: unknown[];
|
|
57
|
-
};
|
|
58
|
-
type MultiRouteBuildResult = {
|
|
59
|
-
features: RouteFeature[];
|
|
60
|
-
directions: unknown[][];
|
|
61
|
-
};
|
|
62
|
-
type SearchResult = {
|
|
63
|
-
id?: string | number;
|
|
64
|
-
latitude?: number;
|
|
65
|
-
longitude?: number;
|
|
66
|
-
icon_img?: string;
|
|
67
|
-
name?: string;
|
|
68
|
-
[key: string]: unknown;
|
|
69
|
-
};
|
|
70
|
-
declare class YarrowMapConfig {
|
|
71
|
-
container: HTMLElement | string;
|
|
72
|
-
center: [number, number];
|
|
73
|
-
zoom: number;
|
|
74
|
-
minZoom: number;
|
|
75
|
-
maxZoom: number;
|
|
76
|
-
theme: 'light' | 'dark';
|
|
77
|
-
cache: NormalizedCacheConfig;
|
|
78
|
-
brandBadgePosition: BrandBadgePosition;
|
|
79
|
-
controls: NormalizedYarrowControlsConfig;
|
|
80
|
-
apiKey: string;
|
|
81
|
-
constructor(config: YarrowMapConfigOptions);
|
|
82
|
-
}
|
|
83
|
-
declare class YarrowMap {
|
|
1
|
+
import { type FeatureIdentifier, type GeoJSONSourceSpecification, type LayerSpecification, Map as MaplibreMap, type Marker, type MarkerOptions, type PointLike, type QueryRenderedFeaturesOptions, type StyleSpecification } from 'maplibre-gl';
|
|
2
|
+
import { YarrowMapConfig } from './config';
|
|
3
|
+
import type { BuildRouteOptions, BuildRouteResult } from './routing/types';
|
|
4
|
+
import type { BoundsInput, LayerDescriptor, RouteFeature, SearchOptions } from './types';
|
|
5
|
+
import { type AddLayerOptions } from './types';
|
|
6
|
+
export declare class YarrowMap {
|
|
84
7
|
private static isCacheProtocolRegistered;
|
|
85
8
|
config: YarrowMapConfig;
|
|
86
9
|
map?: MaplibreMap;
|
|
87
10
|
layers: LayerDescriptor[];
|
|
88
|
-
private
|
|
89
|
-
private
|
|
11
|
+
private layerManager;
|
|
12
|
+
private markerManager;
|
|
13
|
+
private routingBuilder;
|
|
14
|
+
private routingRenderer;
|
|
15
|
+
private searchManager;
|
|
16
|
+
private stylesManager;
|
|
17
|
+
private navigationManager;
|
|
18
|
+
private eventManager;
|
|
19
|
+
private badgeController;
|
|
20
|
+
private controlsController;
|
|
90
21
|
private badgeResizeObserver?;
|
|
22
|
+
private poiLayerConfig?;
|
|
23
|
+
private poiSourceConfig?;
|
|
91
24
|
constructor(config: YarrowMapConfig);
|
|
92
25
|
private ensureCacheProtocol;
|
|
93
26
|
private get cacheLifespanMs();
|
|
94
27
|
private isCacheEnabled;
|
|
95
28
|
private transformRequestForCache;
|
|
96
29
|
private fetchJson;
|
|
30
|
+
private addApiKeyToUrl;
|
|
97
31
|
private loadImageFromSrc;
|
|
98
32
|
private loadIconImage;
|
|
99
33
|
private getIconsMap;
|
|
@@ -103,18 +37,23 @@ declare class YarrowMap {
|
|
|
103
37
|
private syncOverlayCollisionInset;
|
|
104
38
|
private stopBadgeCollisionObserver;
|
|
105
39
|
private startBadgeCollisionObserver;
|
|
106
|
-
clearCache(): Promise<void>;
|
|
107
40
|
fixStyle(style: StyleSpecification | null | undefined): void;
|
|
41
|
+
private updateLayersArray;
|
|
42
|
+
private storePoiLayerConfig;
|
|
43
|
+
private removePoiLayerFromStyle;
|
|
108
44
|
init(): Promise<void>;
|
|
109
|
-
|
|
45
|
+
clearCache(): Promise<void>;
|
|
46
|
+
changeStyles(styleType?: string): Promise<StyleSpecification>;
|
|
110
47
|
changeTheme(theme: 'light' | 'dark'): Promise<StyleSpecification>;
|
|
111
|
-
changeBrandBadgePosition(position:
|
|
48
|
+
changeBrandBadgePosition(position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'): import("./brandBadge").BrandBadgePosition;
|
|
49
|
+
enablePoiLayer(): void;
|
|
50
|
+
disablePoiLayer(): void;
|
|
112
51
|
zoomTo(lat: number, lng: number, zoom: number): void;
|
|
113
52
|
fitBounds(data: BoundsInput): void;
|
|
114
53
|
getBoundingBox(data: BoundsInput): {
|
|
115
54
|
xMin: number;
|
|
116
|
-
yMin: number;
|
|
117
55
|
xMax: number;
|
|
56
|
+
yMin: number;
|
|
118
57
|
yMax: number;
|
|
119
58
|
};
|
|
120
59
|
onMoveEnd(callback: (lat: number, lng: number, zoom: number) => void): void;
|
|
@@ -128,46 +67,26 @@ declare class YarrowMap {
|
|
|
128
67
|
width?: number;
|
|
129
68
|
height?: number;
|
|
130
69
|
}, options?: AddLayerOptions): void;
|
|
131
|
-
setFeatureState(feature: FeatureIdentifier, state: Record<string, unknown>): void;
|
|
132
|
-
queryRenderedFeatures(geometryOrOptions?: PointLike | [PointLike, PointLike] | QueryRenderedFeaturesOptions, options?: QueryRenderedFeaturesOptions): MapGeoJSONFeature[];
|
|
133
|
-
addMarker(coordinates: [number, number], options?: {
|
|
134
|
-
element?: HTMLElement;
|
|
135
|
-
color?: string;
|
|
136
|
-
draggable?: boolean;
|
|
137
|
-
anchor?: 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
138
|
-
onClick?: () => void;
|
|
139
|
-
}): maplibregl.Marker | null;
|
|
140
|
-
removeMarker(marker: maplibregl.Marker | null): void;
|
|
141
70
|
removeLayer(layerName: string): void;
|
|
71
|
+
setFeatureState(feature: FeatureIdentifier, state: Record<string, unknown>): void;
|
|
72
|
+
queryRenderedFeatures(geometryOrOptions?: PointLike | [PointLike, PointLike] | QueryRenderedFeaturesOptions, options?: QueryRenderedFeaturesOptions): import("maplibre-gl").MapGeoJSONFeature[];
|
|
73
|
+
addMarker(coordinates: [number, number], options?: MarkerOptions): Marker | null;
|
|
74
|
+
removeMarker(marker: Marker | null): void;
|
|
142
75
|
renderRoutes(routes: RouteFeature[], baseLayerName?: string): void;
|
|
143
|
-
|
|
144
|
-
|
|
76
|
+
buildRoute(options: BuildRouteOptions): Promise<BuildRouteResult>;
|
|
77
|
+
buildRouteWithLabels(startCoordinates: [number, number], endCoordinates: [number, number], profile: string): Promise<{
|
|
78
|
+
features: RouteFeature[];
|
|
79
|
+
directions: unknown[];
|
|
80
|
+
}>;
|
|
81
|
+
buildMultiSegmentRouteWithLabels(coordinates: [number, number][], profile: string, language?: string): Promise<{
|
|
82
|
+
features: RouteFeature[];
|
|
83
|
+
directions: unknown[][];
|
|
84
|
+
}>;
|
|
145
85
|
clearAllRoutes(): void;
|
|
146
|
-
highlightSearchResults(query: string,
|
|
147
|
-
layerName?: string;
|
|
148
|
-
iconImage?: string;
|
|
149
|
-
highlightColor?: string;
|
|
150
|
-
pulseAnimation?: boolean;
|
|
151
|
-
zoomToResults?: boolean;
|
|
152
|
-
onIconClick?: (lat: number, lng: number, properties: Record<string, unknown>) => void;
|
|
153
|
-
onResultsUpdate?: (results: SearchResult[]) => void;
|
|
154
|
-
onLoadingStateChange?: (state: 'firstRender' | 'rerender' | false) => void;
|
|
155
|
-
}): () => void;
|
|
156
|
-
private currentBusRouteInterval?;
|
|
157
|
-
private currentBusMarkers;
|
|
158
|
-
private currentRouteLayers;
|
|
159
|
-
private readonly MAX_BUSES;
|
|
160
|
-
private svgCache;
|
|
161
|
-
private mapMoveTimeout?;
|
|
162
|
-
private busPositions;
|
|
163
|
-
private animationFrameId?;
|
|
164
|
-
private animateBusMarkers;
|
|
165
|
-
private startBusAnimation;
|
|
166
|
-
private stopBusAnimation;
|
|
167
|
-
showBusRoute(route_id?: string): Promise<() => void>;
|
|
86
|
+
highlightSearchResults(query: string, options?: SearchOptions): () => void;
|
|
168
87
|
}
|
|
169
|
-
export {
|
|
170
|
-
export type { BrandBadgePosition };
|
|
171
|
-
export type { YarrowControlsConfig, YarrowControlsPosition };
|
|
172
|
-
export type { YarrowMapConfigOptions };
|
|
88
|
+
export { YarrowMapConfig };
|
|
89
|
+
export type { BrandBadgePosition } from './brandBadge';
|
|
90
|
+
export type { YarrowControlsConfig, YarrowControlsPosition, } from './yarrowControls';
|
|
91
|
+
export type { YarrowMapConfigOptions } from './types';
|
|
173
92
|
//# sourceMappingURL=yarrow.d.ts.map
|