react-bkoi-gl 1.0.7 → 2.0.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/README.md +163 -18
- package/dist/components/attribution-control.d.ts +4 -6
- package/dist/components/attribution-control.js +6 -5
- package/dist/components/attribution-control.js.map +1 -1
- package/dist/components/fullscreen-control.d.ts +4 -6
- package/dist/components/fullscreen-control.js +4 -4
- package/dist/components/fullscreen-control.js.map +1 -1
- package/dist/components/geolocate-control.d.ts +10 -26
- package/dist/components/geolocate-control.js +11 -11
- package/dist/components/geolocate-control.js.map +1 -1
- package/dist/components/layer.d.ts +7 -6
- package/dist/components/layer.js +8 -9
- package/dist/components/layer.js.map +1 -1
- package/dist/components/logo-control.d.ts +9 -0
- package/dist/components/logo-control.js +28 -0
- package/dist/components/logo-control.js.map +1 -0
- package/dist/components/map.d.ts +20 -16
- package/dist/components/map.js +38 -32
- package/dist/components/map.js.map +1 -1
- package/dist/components/marker.d.ts +10 -33
- package/dist/components/marker.js +22 -15
- package/dist/components/marker.js.map +1 -1
- package/dist/components/navigation-control.d.ts +4 -6
- package/dist/components/navigation-control.js +4 -4
- package/dist/components/navigation-control.js.map +1 -1
- package/dist/components/popup.d.ts +7 -25
- package/dist/components/popup.js +17 -28
- package/dist/components/popup.js.map +1 -1
- package/dist/components/scale-control.d.ts +4 -6
- package/dist/components/scale-control.js +4 -4
- package/dist/components/scale-control.js.map +1 -1
- package/dist/components/source.d.ts +3 -4
- package/dist/components/source.js +20 -22
- package/dist/components/source.js.map +1 -1
- package/dist/components/terrain-control.d.ts +10 -0
- package/dist/components/terrain-control.js +19 -0
- package/dist/components/terrain-control.js.map +1 -0
- package/dist/components/use-control.d.ts +6 -6
- package/dist/components/use-control.js +4 -5
- package/dist/components/use-control.js.map +1 -1
- package/dist/components/use-map.d.ts +8 -9
- package/dist/components/use-map.js +5 -5
- package/dist/components/use-map.js.map +1 -1
- package/dist/exports-maplibre-gl.d.ts +33 -0
- package/dist/exports-maplibre-gl.js +21 -0
- package/dist/exports-maplibre-gl.js.map +1 -0
- package/dist/index.cjs +590 -681
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{mapbox → maplibre}/create-ref.d.ts +6 -6
- package/dist/maplibre/create-ref.js +30 -0
- package/dist/maplibre/create-ref.js.map +1 -0
- package/dist/maplibre/maplibre.d.ts +81 -0
- package/dist/maplibre/maplibre.js +387 -0
- package/dist/maplibre/maplibre.js.map +1 -0
- package/dist/styles/index.d.ts +4 -0
- package/dist/styles/react-bkoi-gl.css +1 -1
- package/dist/styles.d.js +2 -0
- package/dist/styles.d.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/common.d.ts +2 -60
- package/dist/types/common.js.map +1 -1
- package/dist/types/events.d.ts +64 -23
- package/dist/types/events.js.map +1 -1
- package/dist/types/internal.d.ts +14 -0
- package/dist/types/internal.js +2 -0
- package/dist/types/internal.js.map +1 -0
- package/dist/types/lib.d.ts +16 -200
- package/dist/types/lib.js.map +1 -1
- package/dist/types/style-spec.d.ts +1 -0
- package/dist/types/style-spec.js +2 -0
- package/dist/types/style-spec.js.map +1 -0
- package/dist/utils/apply-react-style.d.ts +1 -1
- package/dist/utils/apply-react-style.js.map +1 -1
- package/dist/utils/compare-class-names.d.ts +2 -0
- package/dist/utils/compare-class-names.js +23 -0
- package/dist/utils/compare-class-names.js.map +1 -0
- package/dist/utils/deep-equal.d.ts +1 -1
- package/dist/utils/deep-equal.js +1 -1
- package/dist/utils/deep-equal.js.map +1 -1
- package/dist/utils/set-globals.d.ts +6 -8
- package/dist/utils/set-globals.js +22 -10
- package/dist/utils/set-globals.js.map +1 -1
- package/dist/utils/style-utils.d.ts +3 -2
- package/dist/utils/style-utils.js +4 -4
- package/dist/utils/style-utils.js.map +1 -1
- package/dist/utils/transform.d.ts +11 -19
- package/dist/utils/transform.js +13 -36
- package/dist/utils/transform.js.map +1 -1
- package/dist/utils/use-isomorphic-layout-effect.d.ts +1 -1
- package/dist/utils/use-isomorphic-layout-effect.js +2 -2
- package/dist/utils/use-isomorphic-layout-effect.js.map +1 -1
- package/package.json +42 -26
- package/src/components/attribution-control.ts +40 -16
- package/src/components/fullscreen-control.ts +40 -0
- package/src/components/geolocate-control.ts +45 -39
- package/src/components/layer.ts +37 -29
- package/src/components/logo-control.ts +44 -0
- package/src/components/map.tsx +86 -75
- package/src/components/marker.ts +141 -123
- package/src/components/navigation-control.ts +11 -12
- package/src/components/popup.ts +94 -97
- package/src/components/scale-control.ts +12 -14
- package/src/components/source.ts +58 -57
- package/src/components/terrain-control.ts +29 -0
- package/src/components/use-control.ts +21 -17
- package/src/components/use-map.tsx +26 -24
- package/src/exports-maplibre-gl.ts +37 -0
- package/src/index.ts +3 -2
- package/src/maplibre/create-ref.ts +70 -0
- package/src/maplibre/maplibre.ts +624 -0
- package/src/styles.d.ts +4 -0
- package/src/types/common.ts +12 -72
- package/src/types/events.ts +102 -42
- package/src/types/internal.ts +26 -0
- package/src/types/lib.ts +65 -260
- package/src/types/style-spec.ts +34 -0
- package/src/utils/apply-react-style.ts +7 -3
- package/src/utils/compare-class-names.ts +29 -0
- package/src/utils/deep-equal.ts +2 -2
- package/src/utils/set-globals.ts +22 -28
- package/src/utils/style-utils.ts +18 -9
- package/src/utils/transform.ts +32 -60
- package/src/utils/use-isomorphic-layout-effect.ts +3 -2
- package/bkoi-gl/package.json +0 -6
- package/dist/exports-bkoi-gl.cjs +0 -1512
- package/dist/exports-bkoi-gl.d.ts +0 -89
- package/dist/exports-bkoi-gl.js +0 -36
- package/dist/exports-bkoi-gl.js.map +0 -1
- package/dist/exports-mapbox.d.ts +0 -139
- package/dist/exports-mapbox.js +0 -36
- package/dist/exports-mapbox.js.map +0 -1
- package/dist/mapbox/create-ref.js +0 -64
- package/dist/mapbox/create-ref.js.map +0 -1
- package/dist/mapbox/mapbox.d.ts +0 -81
- package/dist/mapbox/mapbox.js +0 -476
- package/dist/mapbox/mapbox.js.map +0 -1
- package/dist/types/events-bkoi-gl.d.ts +0 -49
- package/dist/types/events-bkoi-gl.js +0 -2
- package/dist/types/events-bkoi-gl.js.map +0 -1
- package/dist/types/events-mapbox.d.ts +0 -49
- package/dist/types/events-mapbox.js +0 -2
- package/dist/types/events-mapbox.js.map +0 -1
- package/dist/types/index.d.ts +0 -70
- package/dist/types/index.js +0 -5
- package/dist/types/index.js.map +0 -1
- package/dist/types/public.d.ts +0 -2
- package/dist/types/public.js +0 -2
- package/dist/types/public.js.map +0 -1
- package/dist/types/style-spec-bkoi-gl.d.ts +0 -9
- package/dist/types/style-spec-bkoi-gl.js +0 -2
- package/dist/types/style-spec-bkoi-gl.js.map +0 -1
- package/dist/types/style-spec-mapbox.d.ts +0 -7
- package/dist/types/style-spec-mapbox.js +0 -2
- package/dist/types/style-spec-mapbox.js.map +0 -1
- package/src/components/fullscreen-control.tsx +0 -37
- package/src/exports-bkoi-gl.ts +0 -156
- package/src/exports-mapbox.ts +0 -159
- package/src/mapbox/create-ref.ts +0 -118
- package/src/mapbox/mapbox.ts +0 -742
- package/src/types/events-bkoi-gl.ts +0 -78
- package/src/types/events-mapbox.ts +0 -76
- package/src/types/index.ts +0 -93
- package/src/types/public.ts +0 -9
- package/src/types/style-spec-bkoi-gl.ts +0 -81
- package/src/types/style-spec-mapbox.ts +0 -80
package/dist/types/lib.d.ts
CHANGED
|
@@ -1,224 +1,40 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export
|
|
3
|
-
onAdd(map: MapT): HTMLElement;
|
|
4
|
-
onRemove(map: MapT): void;
|
|
5
|
-
getDefaultPosition?: (() => string) | undefined;
|
|
6
|
-
}
|
|
7
|
-
type Listener = (event?: any) => any;
|
|
8
|
-
export interface Evented {
|
|
9
|
-
on(type: string, listener: Listener): any;
|
|
10
|
-
off(type?: string | any, listener?: Listener): any;
|
|
11
|
-
once(type: string, listener: Listener): any;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* A user-facing type that represents the minimal intersection between Mapbox.Map and Maplibre.Map
|
|
15
|
-
* User provided `mapLib.Map` is supposed to implement this interface
|
|
16
|
-
* Only losely typed for compatibility
|
|
17
|
-
*/
|
|
18
|
-
export interface MapInstance extends Evented {
|
|
19
|
-
fire(type: string, properties?: {
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
}): any;
|
|
22
|
-
addControl(control: IControl<this>, position?: ControlPosition): any;
|
|
23
|
-
removeControl(control: IControl<this>): any;
|
|
24
|
-
hasControl(control: IControl<this>): boolean;
|
|
25
|
-
resize(): this;
|
|
26
|
-
queryRenderedFeatures(geometry?: any, options?: any): any[];
|
|
27
|
-
setStyle(style: any, options?: any): any;
|
|
28
|
-
isMoving(): boolean;
|
|
29
|
-
getStyle(): any;
|
|
30
|
-
isStyleLoaded(): boolean | void;
|
|
31
|
-
addSource(id: string, source: any): any;
|
|
32
|
-
removeSource(id: string): this;
|
|
33
|
-
getSource(id: string): any;
|
|
34
|
-
addLayer(layer: any, before?: string): any;
|
|
35
|
-
moveLayer(id: string, beforeId?: string): any;
|
|
36
|
-
removeLayer(id: string): any;
|
|
37
|
-
getLayer(id: string): any;
|
|
38
|
-
setFilter(layer: string, filter?: any[] | boolean | null): any;
|
|
39
|
-
setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): any;
|
|
40
|
-
setPaintProperty(layer: string, name: string, value: any): any;
|
|
41
|
-
setLayoutProperty(layer: string, name: string, value: any): any;
|
|
42
|
-
project(lnglat: any): Point;
|
|
43
|
-
unproject(point: any): LngLat;
|
|
44
|
-
queryTerrainElevation?(lngLat: any, options?: any): number | null;
|
|
45
|
-
getContainer(): HTMLElement;
|
|
46
|
-
getCanvas(): HTMLCanvasElement;
|
|
47
|
-
remove(): void;
|
|
48
|
-
triggerRepaint(): void;
|
|
49
|
-
setPadding(padding: PaddingOptions): any;
|
|
50
|
-
fitBounds(bounds: any, options?: any): any;
|
|
51
|
-
setFog?(fog: any): any;
|
|
52
|
-
setLight?(options: any, lightOptions?: any): any;
|
|
53
|
-
setTerrain?(terrain?: any): any;
|
|
54
|
-
}
|
|
55
|
-
export interface MarkerInstance extends Evented {
|
|
56
|
-
addTo(map: MapInstance): this;
|
|
57
|
-
remove(): this;
|
|
58
|
-
getLngLat(): LngLat;
|
|
59
|
-
setLngLat(lngLat: LngLatLike): this;
|
|
60
|
-
getElement(): HTMLElement;
|
|
61
|
-
setPopup(popup?: any): this;
|
|
62
|
-
getPopup(): any;
|
|
63
|
-
getOffset(): PointLike;
|
|
64
|
-
setOffset(offset: PointLike): this;
|
|
65
|
-
setDraggable(value: boolean): this;
|
|
66
|
-
isDraggable(): boolean;
|
|
67
|
-
getRotation(): number;
|
|
68
|
-
setRotation(rotation: number): this;
|
|
69
|
-
getRotationAlignment(): any;
|
|
70
|
-
setRotationAlignment(alignment: any): this;
|
|
71
|
-
getPitchAlignment(): any;
|
|
72
|
-
setPitchAlignment(alignment: any): this;
|
|
73
|
-
}
|
|
74
|
-
export interface PopupInstance extends Evented {
|
|
75
|
-
options?: any;
|
|
76
|
-
addTo(map: MapInstance): this;
|
|
77
|
-
remove(): this;
|
|
78
|
-
isOpen(): boolean;
|
|
79
|
-
getLngLat(): LngLat;
|
|
80
|
-
setLngLat(lnglat: LngLatLike): this;
|
|
81
|
-
getElement(): HTMLElement;
|
|
82
|
-
setDOMContent(htmlNode: any): this;
|
|
83
|
-
getMaxWidth(): any;
|
|
84
|
-
setMaxWidth(maxWidth: any): this;
|
|
85
|
-
addClassName(className: string): void;
|
|
86
|
-
removeClassName(className: string): void;
|
|
87
|
-
setOffset(offset?: any): this;
|
|
88
|
-
}
|
|
89
|
-
export interface AttributionControlInstance extends IControl {
|
|
90
|
-
_container?: HTMLElement;
|
|
91
|
-
}
|
|
92
|
-
export interface FullscreenControlInstance extends IControl {
|
|
93
|
-
_controlContainer?: HTMLElement;
|
|
94
|
-
}
|
|
95
|
-
export interface GeolocateControlInstance extends IControl, Evented {
|
|
96
|
-
_container?: HTMLElement;
|
|
97
|
-
trigger(): any;
|
|
98
|
-
}
|
|
99
|
-
export interface NavigationControlInstance extends IControl {
|
|
100
|
-
_container?: HTMLElement;
|
|
101
|
-
}
|
|
102
|
-
export interface ScaleControlInstance extends IControl {
|
|
103
|
-
_container?: HTMLElement;
|
|
104
|
-
options?: any;
|
|
105
|
-
setUnit(unit: any): void;
|
|
106
|
-
}
|
|
1
|
+
import type { Map, MapOptions, Marker, MarkerOptions, Popup, PopupOptions, AttributionControl, AttributionControlOptions, FullscreenControl, FullscreenControlOptions, GeolocateControl, GeolocateControlOptions, NavigationControl, NavigationControlOptions, ScaleControl, ScaleControlOptions, TerrainControl, TerrainSpecification, LogoControl, LogoControlOptions } from "maplibre-gl";
|
|
2
|
+
export type { ControlPosition, IControl, Map, MapOptions, Marker, MarkerOptions, Popup, PopupOptions, AttributionControl, AttributionControlOptions, FullscreenControl, FullscreenControlOptions, GeolocateControl, GeolocateControlOptions, NavigationControl, NavigationControlOptions, ScaleControl, ScaleControlOptions, TerrainControl, LogoControl, LogoControlOptions, CustomLayerInterface, } from "maplibre-gl";
|
|
107
3
|
/**
|
|
108
4
|
* A user-facing type that represents the minimal intersection between Mapbox and Maplibre
|
|
109
5
|
* User provided `mapLib` is supposed to implement this interface
|
|
110
6
|
* Only losely typed for compatibility
|
|
111
7
|
*/
|
|
112
|
-
export interface MapLib
|
|
8
|
+
export interface MapLib {
|
|
113
9
|
supported?: (options: any) => boolean;
|
|
114
10
|
Map: {
|
|
115
|
-
new (options:
|
|
11
|
+
new (options: MapOptions): Map;
|
|
116
12
|
};
|
|
117
13
|
Marker: {
|
|
118
|
-
new (
|
|
14
|
+
new (options: MarkerOptions): Marker;
|
|
119
15
|
};
|
|
120
16
|
Popup: {
|
|
121
|
-
new (options:
|
|
17
|
+
new (options: PopupOptions): Popup;
|
|
122
18
|
};
|
|
123
19
|
AttributionControl: {
|
|
124
|
-
new (options:
|
|
20
|
+
new (options: AttributionControlOptions): AttributionControl;
|
|
125
21
|
};
|
|
126
22
|
FullscreenControl: {
|
|
127
|
-
new (options:
|
|
23
|
+
new (options: FullscreenControlOptions): FullscreenControl;
|
|
128
24
|
};
|
|
129
25
|
GeolocateControl: {
|
|
130
|
-
new (options:
|
|
26
|
+
new (options: GeolocateControlOptions): GeolocateControl;
|
|
131
27
|
};
|
|
132
28
|
NavigationControl: {
|
|
133
|
-
new (options:
|
|
29
|
+
new (options: NavigationControlOptions): NavigationControl;
|
|
134
30
|
};
|
|
135
31
|
ScaleControl: {
|
|
136
|
-
new (options:
|
|
32
|
+
new (options: ScaleControlOptions): ScaleControl;
|
|
137
33
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
export type Transform = {
|
|
144
|
-
width: number;
|
|
145
|
-
height: number;
|
|
146
|
-
center: LngLat;
|
|
147
|
-
zoom: number;
|
|
148
|
-
bearing: number;
|
|
149
|
-
pitch: number;
|
|
150
|
-
padding: PaddingOptions;
|
|
151
|
-
elevation: any;
|
|
152
|
-
pixelsToGLUnits: [number, number];
|
|
153
|
-
cameraElevationReference: 'ground' | 'sea';
|
|
154
|
-
clone: () => Transform;
|
|
155
|
-
resize: (width: number, height: number) => void;
|
|
156
|
-
isPaddingEqual: (value: PaddingOptions) => boolean;
|
|
157
|
-
getBounds: () => any;
|
|
158
|
-
locationPoint: (lngLat: LngLat) => Point;
|
|
159
|
-
pointLocation: (p: Point) => LngLat;
|
|
160
|
-
getProjection?: () => any;
|
|
161
|
-
setProjection?: (projection: any) => void;
|
|
162
|
-
};
|
|
163
|
-
export type MapInstanceInternal<MapT extends MapInstance> = MapT & {
|
|
164
|
-
transform: Transform;
|
|
165
|
-
_render: Function;
|
|
166
|
-
_renderTaskQueue: {
|
|
167
|
-
run: Function;
|
|
34
|
+
TerrainControl: {
|
|
35
|
+
new (options: TerrainSpecification): TerrainControl;
|
|
36
|
+
};
|
|
37
|
+
LogoControl: {
|
|
38
|
+
new (options: LogoControlOptions): LogoControl;
|
|
168
39
|
};
|
|
169
|
-
};
|
|
170
|
-
export interface CustomLayerInterface {
|
|
171
|
-
id: string;
|
|
172
|
-
type: 'custom';
|
|
173
|
-
renderingMode?: '2d' | '3d';
|
|
174
|
-
onRemove?(map: MapInstance, gl: WebGLRenderingContext): void;
|
|
175
|
-
onAdd?(map: MapInstance, gl: WebGLRenderingContext): void;
|
|
176
|
-
prerender?(gl: WebGLRenderingContext, matrix: number[]): void;
|
|
177
|
-
render(gl: WebGLRenderingContext, matrix: number[]): void;
|
|
178
|
-
}
|
|
179
|
-
export interface CustomSourceImplementation<TileDataT> {
|
|
180
|
-
id: string;
|
|
181
|
-
type: 'custom';
|
|
182
|
-
dataType: 'raster';
|
|
183
|
-
minzoom?: number;
|
|
184
|
-
maxzoom?: number;
|
|
185
|
-
scheme?: string;
|
|
186
|
-
tileSize?: number;
|
|
187
|
-
attribution?: string;
|
|
188
|
-
bounds?: [number, number, number, number];
|
|
189
|
-
hasTile?: (tileID: {
|
|
190
|
-
z: number;
|
|
191
|
-
x: number;
|
|
192
|
-
y: number;
|
|
193
|
-
}) => boolean;
|
|
194
|
-
loadTile: (tileID: {
|
|
195
|
-
z: number;
|
|
196
|
-
x: number;
|
|
197
|
-
y: number;
|
|
198
|
-
}, options: {
|
|
199
|
-
signal: AbortSignal;
|
|
200
|
-
}) => Promise<TileDataT>;
|
|
201
|
-
prepareTile?: (tileID: {
|
|
202
|
-
z: number;
|
|
203
|
-
x: number;
|
|
204
|
-
y: number;
|
|
205
|
-
}) => TileDataT | undefined;
|
|
206
|
-
unloadTile?: (tileID: {
|
|
207
|
-
z: number;
|
|
208
|
-
x: number;
|
|
209
|
-
y: number;
|
|
210
|
-
}) => void;
|
|
211
|
-
onAdd?: (map: MapInstance) => void;
|
|
212
|
-
onRemove?: (map: MapInstance) => void;
|
|
213
|
-
}
|
|
214
|
-
export interface CustomSource<TileDataT = unknown> {
|
|
215
|
-
id: string;
|
|
216
|
-
type: 'custom';
|
|
217
|
-
scheme: string;
|
|
218
|
-
minzoom: number;
|
|
219
|
-
maxzoom: number;
|
|
220
|
-
tileSize: number;
|
|
221
|
-
attribution: string;
|
|
222
|
-
_implementation: CustomSourceImplementation<TileDataT>;
|
|
223
40
|
}
|
|
224
|
-
export {};
|
package/dist/types/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","names":[],"sources":["../../src/types/lib.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"lib.js","names":[],"sources":["../../src/types/lib.ts"],"sourcesContent":["import type {\n Map,\n MapOptions,\n Marker,\n MarkerOptions,\n Popup,\n PopupOptions,\n AttributionControl,\n AttributionControlOptions,\n FullscreenControl,\n FullscreenControlOptions,\n GeolocateControl,\n GeolocateControlOptions,\n NavigationControl,\n NavigationControlOptions,\n ScaleControl,\n ScaleControlOptions,\n TerrainControl,\n TerrainSpecification,\n LogoControl,\n LogoControlOptions,\n} from \"maplibre-gl\";\n\nexport type {\n ControlPosition,\n IControl,\n Map,\n MapOptions,\n Marker,\n MarkerOptions,\n Popup,\n PopupOptions,\n AttributionControl,\n AttributionControlOptions,\n FullscreenControl,\n FullscreenControlOptions,\n GeolocateControl,\n GeolocateControlOptions,\n NavigationControl,\n NavigationControlOptions,\n ScaleControl,\n ScaleControlOptions,\n TerrainControl,\n LogoControl,\n LogoControlOptions,\n CustomLayerInterface,\n} from \"maplibre-gl\";\n\n/**\n * A user-facing type that represents the minimal intersection between Mapbox and Maplibre\n * User provided `mapLib` is supposed to implement this interface\n * Only losely typed for compatibility\n */\nexport interface MapLib {\n supported?: (options: any) => boolean;\n\n Map: { new (options: MapOptions): Map };\n\n Marker: { new (options: MarkerOptions): Marker };\n\n Popup: { new (options: PopupOptions): Popup };\n\n AttributionControl: {\n new (options: AttributionControlOptions): AttributionControl;\n };\n\n FullscreenControl: {\n new (options: FullscreenControlOptions): FullscreenControl;\n };\n\n GeolocateControl: {\n new (options: GeolocateControlOptions): GeolocateControl;\n };\n\n NavigationControl: {\n new (options: NavigationControlOptions): NavigationControl;\n };\n\n ScaleControl: { new (options: ScaleControlOptions): ScaleControl };\n\n TerrainControl: { new (options: TerrainSpecification): TerrainControl };\n\n LogoControl: { new (options: LogoControlOptions): LogoControl };\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { LayerSpecification, FillLayerSpecification, LineLayerSpecification, SymbolLayerSpecification, CircleLayerSpecification, HeatmapLayerSpecification, FillExtrusionLayerSpecification, RasterLayerSpecification, HillshadeLayerSpecification, BackgroundLayerSpecification, SourceSpecification, VectorSourceSpecification, RasterSourceSpecification, RasterDEMSourceSpecification, GeoJSONSourceSpecification, VideoSourceSpecification, ImageSourceSpecification, CanvasSourceSpecification, StyleSpecification, SkySpecification, LightSpecification, TerrainSpecification, ProjectionSpecification, } from "maplibre-gl";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-spec.js","names":[],"sources":["../../src/types/style-spec.ts"],"sourcesContent":["/*\n * Maplibre Style Specification types\n * Type names are aligned with mapbox\n */\nexport type {\n // Layers\n LayerSpecification,\n FillLayerSpecification,\n LineLayerSpecification,\n SymbolLayerSpecification,\n CircleLayerSpecification,\n HeatmapLayerSpecification,\n FillExtrusionLayerSpecification,\n RasterLayerSpecification,\n HillshadeLayerSpecification,\n BackgroundLayerSpecification,\n\n // Sources\n SourceSpecification,\n VectorSourceSpecification,\n RasterSourceSpecification,\n RasterDEMSourceSpecification,\n GeoJSONSourceSpecification,\n VideoSourceSpecification,\n ImageSourceSpecification,\n CanvasSourceSpecification,\n\n // Style\n StyleSpecification,\n SkySpecification,\n LightSpecification,\n TerrainSpecification,\n ProjectionSpecification,\n} from \"maplibre-gl\";\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import * as React from
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
export declare function applyReactStyle(element: HTMLElement, styles: React.CSSProperties): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-react-style.js","names":["unitlessNumber","applyReactStyle","element","styles","style","key","value","Number","isFinite","test"],"sources":["../../src/utils/apply-react-style.ts"],"sourcesContent":["import * as React from
|
|
1
|
+
{"version":3,"file":"apply-react-style.js","names":["unitlessNumber","applyReactStyle","element","styles","style","key","value","Number","isFinite","test"],"sources":["../../src/utils/apply-react-style.ts"],"sourcesContent":["import * as React from \"react\";\n// This is a simplified version of\n// https://github.com/facebook/react/blob/4131af3e4bf52f3a003537ec95a1655147c81270/src/renderers/dom/shared/CSSPropertyOperations.js#L62\nconst unitlessNumber =\n /box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;\n\nexport function applyReactStyle(\n element: HTMLElement,\n styles: React.CSSProperties,\n) {\n if (!element || !styles) {\n return;\n }\n const style = element.style;\n\n for (const key in styles) {\n const value = styles[key];\n if (Number.isFinite(value) && !unitlessNumber.test(key)) {\n style[key] = `${value}px`;\n } else {\n style[key] = value;\n }\n }\n}\n"],"mappings":"AAGA,MAAMA,cAAc,GAClB,yEAAyE;AAE3E,OAAO,SAASC,eAAeA,CAC7BC,OAAoB,EACpBC,MAA2B,EAC3B;EACA,IAAI,CAACD,OAAO,IAAI,CAACC,MAAM,EAAE;IACvB;EACF;EACA,MAAMC,KAAK,GAAGF,OAAO,CAACE,KAAK;EAE3B,KAAK,MAAMC,GAAG,IAAIF,MAAM,EAAE;IACxB,MAAMG,KAAK,GAAGH,MAAM,CAACE,GAAG,CAAC;IACzB,IAAIE,MAAM,CAACC,QAAQ,CAACF,KAAK,CAAC,IAAI,CAACN,cAAc,CAACS,IAAI,CAACJ,GAAG,CAAC,EAAE;MACvDD,KAAK,CAACC,GAAG,CAAC,GAAG,GAAGC,KAAK,IAAI;IAC3B,CAAC,MAAM;MACLF,KAAK,CAACC,GAAG,CAAC,GAAGC,KAAK;IACpB;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function compareClassNames(prevClassName, nextClassName) {
|
|
2
|
+
if (prevClassName === nextClassName) {
|
|
3
|
+
return null;
|
|
4
|
+
}
|
|
5
|
+
const prevClassList = getClassList(prevClassName);
|
|
6
|
+
const nextClassList = getClassList(nextClassName);
|
|
7
|
+
const diff = [];
|
|
8
|
+
for (const c of nextClassList) {
|
|
9
|
+
if (!prevClassList.has(c)) {
|
|
10
|
+
diff.push(c);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
for (const c of prevClassList) {
|
|
14
|
+
if (!nextClassList.has(c)) {
|
|
15
|
+
diff.push(c);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return diff.length === 0 ? null : diff;
|
|
19
|
+
}
|
|
20
|
+
function getClassList(className) {
|
|
21
|
+
return new Set(className ? className.trim().split(/\s+/) : []);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=compare-class-names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compare-class-names.js","names":["compareClassNames","prevClassName","nextClassName","prevClassList","getClassList","nextClassList","diff","c","has","push","length","className","Set","trim","split"],"sources":["../../src/utils/compare-class-names.ts"],"sourcesContent":["/** Compare two classNames string and return the difference */\nexport function compareClassNames(\n prevClassName: string | undefined,\n nextClassName: string | undefined,\n): string[] | null {\n if (prevClassName === nextClassName) {\n return null;\n }\n\n const prevClassList = getClassList(prevClassName);\n const nextClassList = getClassList(nextClassName);\n const diff: string[] = [];\n\n for (const c of nextClassList) {\n if (!prevClassList.has(c)) {\n diff.push(c);\n }\n }\n for (const c of prevClassList) {\n if (!nextClassList.has(c)) {\n diff.push(c);\n }\n }\n return diff.length === 0 ? null : diff;\n}\n\nfunction getClassList(className: string | undefined) {\n return new Set(className ? className.trim().split(/\\s+/) : []);\n}\n"],"mappings":"AACA,OAAO,SAASA,iBAAiBA,CAC/BC,aAAiC,EACjCC,aAAiC,EAChB;EACjB,IAAID,aAAa,KAAKC,aAAa,EAAE;IACnC,OAAO,IAAI;EACb;EAEA,MAAMC,aAAa,GAAGC,YAAY,CAACH,aAAa,CAAC;EACjD,MAAMI,aAAa,GAAGD,YAAY,CAACF,aAAa,CAAC;EACjD,MAAMI,IAAc,GAAG,EAAE;EAEzB,KAAK,MAAMC,CAAC,IAAIF,aAAa,EAAE;IAC7B,IAAI,CAACF,aAAa,CAACK,GAAG,CAACD,CAAC,CAAC,EAAE;MACzBD,IAAI,CAACG,IAAI,CAACF,CAAC,CAAC;IACd;EACF;EACA,KAAK,MAAMA,CAAC,IAAIJ,aAAa,EAAE;IAC7B,IAAI,CAACE,aAAa,CAACG,GAAG,CAACD,CAAC,CAAC,EAAE;MACzBD,IAAI,CAACG,IAAI,CAACF,CAAC,CAAC;IACd;EACF;EACA,OAAOD,IAAI,CAACI,MAAM,KAAK,CAAC,GAAG,IAAI,GAAGJ,IAAI;AACxC;AAEA,SAASF,YAAYA,CAACO,SAA6B,EAAE;EACnD,OAAO,IAAIC,GAAG,CAACD,SAAS,GAAGA,SAAS,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChE","ignoreList":[]}
|
package/dist/utils/deep-equal.js
CHANGED
|
@@ -25,7 +25,7 @@ export function deepEqual(a, b) {
|
|
|
25
25
|
} else if (Array.isArray(b)) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
|
-
if (typeof a ===
|
|
28
|
+
if (typeof a === "object" && typeof b === "object") {
|
|
29
29
|
const aKeys = Object.keys(a);
|
|
30
30
|
const bKeys = Object.keys(b);
|
|
31
31
|
if (aKeys.length !== bKeys.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-equal.js","names":["arePointsEqual","a","b","ax","Array","isArray","x","ay","y","bx","by","deepEqual","length","i","aKeys","Object","keys","bKeys","key","hasOwnProperty"],"sources":["../../src/utils/deep-equal.ts"],"sourcesContent":["import type {PointLike} from
|
|
1
|
+
{"version":3,"file":"deep-equal.js","names":["arePointsEqual","a","b","ax","Array","isArray","x","ay","y","bx","by","deepEqual","length","i","aKeys","Object","keys","bKeys","key","hasOwnProperty"],"sources":["../../src/utils/deep-equal.ts"],"sourcesContent":["import type { PointLike } from \"../types/common\";\n\n/**\n * Compare two points\n * @param a\n * @param b\n * @returns true if the points are equal\n */\nexport function arePointsEqual(a?: PointLike, b?: PointLike): boolean {\n const ax = Array.isArray(a) ? a[0] : a ? a.x : 0;\n const ay = Array.isArray(a) ? a[1] : a ? a.y : 0;\n const bx = Array.isArray(b) ? b[0] : b ? b.x : 0;\n const by = Array.isArray(b) ? b[1] : b ? b.y : 0;\n return ax === bx && ay === by;\n}\n\n/* eslint-disable complexity */\n/**\n * Compare any two objects\n * @param a\n * @param b\n * @returns true if the objects are deep equal\n */\nexport function deepEqual(a: any, b: any): boolean {\n if (a === b) {\n return true;\n }\n if (!a || !b) {\n return false;\n }\n if (Array.isArray(a)) {\n if (!Array.isArray(b) || a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) {\n return false;\n }\n }\n return true;\n } else if (Array.isArray(b)) {\n return false;\n }\n if (typeof a === \"object\" && typeof b === \"object\") {\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n for (const key of aKeys) {\n if (!b.hasOwnProperty(key)) {\n return false;\n }\n if (!deepEqual(a[key], b[key])) {\n return false;\n }\n }\n return true;\n }\n return false;\n}\n"],"mappings":"AAQA,OAAO,SAASA,cAAcA,CAACC,CAAa,EAAEC,CAAa,EAAW;EACpE,MAAMC,EAAE,GAAGC,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACK,CAAC,GAAG,CAAC;EAChD,MAAMC,EAAE,GAAGH,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACO,CAAC,GAAG,CAAC;EAChD,MAAMC,EAAE,GAAGL,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACI,CAAC,GAAG,CAAC;EAChD,MAAMI,EAAE,GAAGN,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,GAAGA,CAAC,CAAC,CAAC,CAAC,GAAGA,CAAC,GAAGA,CAAC,CAACM,CAAC,GAAG,CAAC;EAChD,OAAOL,EAAE,KAAKM,EAAE,IAAIF,EAAE,KAAKG,EAAE;AAC/B;AASA,OAAO,SAASC,SAASA,CAACV,CAAM,EAAEC,CAAM,EAAW;EACjD,IAAID,CAAC,KAAKC,CAAC,EAAE;IACX,OAAO,IAAI;EACb;EACA,IAAI,CAACD,CAAC,IAAI,CAACC,CAAC,EAAE;IACZ,OAAO,KAAK;EACd;EACA,IAAIE,KAAK,CAACC,OAAO,CAACJ,CAAC,CAAC,EAAE;IACpB,IAAI,CAACG,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,IAAID,CAAC,CAACW,MAAM,KAAKV,CAAC,CAACU,MAAM,EAAE;MAC9C,OAAO,KAAK;IACd;IACA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGZ,CAAC,CAACW,MAAM,EAAEC,CAAC,EAAE,EAAE;MACjC,IAAI,CAACF,SAAS,CAACV,CAAC,CAACY,CAAC,CAAC,EAAEX,CAAC,CAACW,CAAC,CAAC,CAAC,EAAE;QAC1B,OAAO,KAAK;MACd;IACF;IACA,OAAO,IAAI;EACb,CAAC,MAAM,IAAIT,KAAK,CAACC,OAAO,CAACH,CAAC,CAAC,EAAE;IAC3B,OAAO,KAAK;EACd;EACA,IAAI,OAAOD,CAAC,KAAK,QAAQ,IAAI,OAAOC,CAAC,KAAK,QAAQ,EAAE;IAClD,MAAMY,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACf,CAAC,CAAC;IAC5B,MAAMgB,KAAK,GAAGF,MAAM,CAACC,IAAI,CAACd,CAAC,CAAC;IAC5B,IAAIY,KAAK,CAACF,MAAM,KAAKK,KAAK,CAACL,MAAM,EAAE;MACjC,OAAO,KAAK;IACd;IACA,KAAK,MAAMM,GAAG,IAAIJ,KAAK,EAAE;MACvB,IAAI,CAACZ,CAAC,CAACiB,cAAc,CAACD,GAAG,CAAC,EAAE;QAC1B,OAAO,KAAK;MACd;MACA,IAAI,CAACP,SAAS,CAACV,CAAC,CAACiB,GAAG,CAAC,EAAEhB,CAAC,CAACgB,GAAG,CAAC,CAAC,EAAE;QAC9B,OAAO,KAAK;MACd;IACF;IACA,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd","ignoreList":[]}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
export type GlobalSettings = {
|
|
2
|
-
/** The map's default API URL for requesting tiles, styles, sprites, and glyphs. */
|
|
3
|
-
baseApiUrl?: string;
|
|
4
2
|
/** The maximum number of images (raster tiles, sprites, icons) to load in parallel.
|
|
5
3
|
* @default 16
|
|
6
4
|
*/
|
|
7
5
|
maxParallelImageRequests?: number;
|
|
8
6
|
/** The map's RTL text plugin. Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. */
|
|
9
|
-
RTLTextPlugin?: string |
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** The number of web workers instantiated on a page with
|
|
7
|
+
RTLTextPlugin?: string | {
|
|
8
|
+
pluginUrl: string;
|
|
9
|
+
lazy?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** The number of web workers instantiated on a page with maplibre-gl maps.
|
|
14
12
|
* @default 2
|
|
15
13
|
*/
|
|
16
14
|
workerCount?: number;
|
|
17
|
-
/** Provides an interface for loading
|
|
15
|
+
/** Provides an interface for loading maplibre-gl's WebWorker bundle from a self-hosted URL.
|
|
18
16
|
* This is useful if your site needs to operate in a strict CSP (Content Security Policy) environment
|
|
19
17
|
* wherein you are not allowed to load JavaScript code from a Blob URL, which is default behavior. */
|
|
20
18
|
workerUrl?: string;
|
|
@@ -1,19 +1,31 @@
|
|
|
1
|
-
const globalSettings = ['baseApiUrl', 'maxParallelImageRequests', 'workerClass', 'workerCount', 'workerUrl'];
|
|
2
1
|
export default function setGlobals(mapLib, props) {
|
|
3
|
-
for (const key of globalSettings) {
|
|
4
|
-
if (key in props) {
|
|
5
|
-
mapLib[key] = props[key];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
2
|
const {
|
|
9
|
-
RTLTextPlugin
|
|
3
|
+
RTLTextPlugin,
|
|
4
|
+
maxParallelImageRequests,
|
|
5
|
+
workerCount,
|
|
6
|
+
workerUrl
|
|
10
7
|
} = props;
|
|
11
|
-
if (RTLTextPlugin && mapLib.getRTLTextPluginStatus && mapLib.getRTLTextPluginStatus() ===
|
|
12
|
-
|
|
8
|
+
if (RTLTextPlugin && mapLib.getRTLTextPluginStatus && mapLib.getRTLTextPluginStatus() === "unavailable") {
|
|
9
|
+
const {
|
|
10
|
+
pluginUrl,
|
|
11
|
+
lazy = true
|
|
12
|
+
} = typeof RTLTextPlugin === "string" ? {
|
|
13
|
+
pluginUrl: RTLTextPlugin
|
|
14
|
+
} : RTLTextPlugin;
|
|
15
|
+
mapLib.setRTLTextPlugin(pluginUrl, error => {
|
|
13
16
|
if (error) {
|
|
14
17
|
console.error(error);
|
|
15
18
|
}
|
|
16
|
-
},
|
|
19
|
+
}, lazy);
|
|
20
|
+
}
|
|
21
|
+
if (maxParallelImageRequests !== undefined) {
|
|
22
|
+
mapLib.setMaxParallelImageRequests(maxParallelImageRequests);
|
|
23
|
+
}
|
|
24
|
+
if (workerCount !== undefined) {
|
|
25
|
+
mapLib.setWorkerCount(workerCount);
|
|
26
|
+
}
|
|
27
|
+
if (workerUrl !== undefined) {
|
|
28
|
+
mapLib.setWorkerUrl(workerUrl);
|
|
17
29
|
}
|
|
18
30
|
}
|
|
19
31
|
//# sourceMappingURL=set-globals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-globals.js","names":["
|
|
1
|
+
{"version":3,"file":"set-globals.js","names":["setGlobals","mapLib","props","RTLTextPlugin","maxParallelImageRequests","workerCount","workerUrl","getRTLTextPluginStatus","pluginUrl","lazy","setRTLTextPlugin","error","console","undefined","setMaxParallelImageRequests","setWorkerCount","setWorkerUrl"],"sources":["../../src/utils/set-globals.ts"],"sourcesContent":["export type GlobalSettings = {\n /** The maximum number of images (raster tiles, sprites, icons) to load in parallel.\n * @default 16\n */\n maxParallelImageRequests?: number;\n /** The map's RTL text plugin. Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. */\n RTLTextPlugin?: string | { pluginUrl: string; lazy?: boolean };\n /** The number of web workers instantiated on a page with maplibre-gl maps.\n * @default 2\n */\n workerCount?: number;\n /** Provides an interface for loading maplibre-gl's WebWorker bundle from a self-hosted URL.\n * This is useful if your site needs to operate in a strict CSP (Content Security Policy) environment\n * wherein you are not allowed to load JavaScript code from a Blob URL, which is default behavior. */\n workerUrl?: string;\n};\n\nexport default function setGlobals(mapLib: any, props: GlobalSettings) {\n const { RTLTextPlugin, maxParallelImageRequests, workerCount, workerUrl } =\n props;\n if (\n RTLTextPlugin &&\n mapLib.getRTLTextPluginStatus &&\n mapLib.getRTLTextPluginStatus() === \"unavailable\"\n ) {\n const { pluginUrl, lazy = true } =\n typeof RTLTextPlugin === \"string\"\n ? { pluginUrl: RTLTextPlugin }\n : RTLTextPlugin;\n\n mapLib.setRTLTextPlugin(\n pluginUrl,\n (error?: Error) => {\n if (error) {\n // eslint-disable-next-line\n console.error(error);\n }\n },\n lazy,\n );\n }\n if (maxParallelImageRequests !== undefined) {\n mapLib.setMaxParallelImageRequests(maxParallelImageRequests);\n }\n if (workerCount !== undefined) {\n mapLib.setWorkerCount(workerCount);\n }\n if (workerUrl !== undefined) {\n mapLib.setWorkerUrl(workerUrl);\n }\n}\n"],"mappings":"AAiBA,eAAe,SAASA,UAAUA,CAACC,MAAW,EAAEC,KAAqB,EAAE;EACrE,MAAM;IAAEC,aAAa;IAAEC,wBAAwB;IAAEC,WAAW;IAAEC;EAAU,CAAC,GACvEJ,KAAK;EACP,IACEC,aAAa,IACbF,MAAM,CAACM,sBAAsB,IAC7BN,MAAM,CAACM,sBAAsB,CAAC,CAAC,KAAK,aAAa,EACjD;IACA,MAAM;MAAEC,SAAS;MAAEC,IAAI,GAAG;IAAK,CAAC,GAC9B,OAAON,aAAa,KAAK,QAAQ,GAC7B;MAAEK,SAAS,EAAEL;IAAc,CAAC,GAC5BA,aAAa;IAEnBF,MAAM,CAACS,gBAAgB,CACrBF,SAAS,EACRG,KAAa,IAAK;MACjB,IAAIA,KAAK,EAAE;QAETC,OAAO,CAACD,KAAK,CAACA,KAAK,CAAC;MACtB;IACF,CAAC,EACDF,IACF,CAAC;EACH;EACA,IAAIL,wBAAwB,KAAKS,SAAS,EAAE;IAC1CZ,MAAM,CAACa,2BAA2B,CAACV,wBAAwB,CAAC;EAC9D;EACA,IAAIC,WAAW,KAAKQ,SAAS,EAAE;IAC7BZ,MAAM,CAACc,cAAc,CAACV,WAAW,CAAC;EACpC;EACA,IAAIC,SAAS,KAAKO,SAAS,EAAE;IAC3BZ,MAAM,CAACe,YAAY,CAACV,SAAS,CAAC;EAChC;AACF","ignoreList":[]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { StyleSpecification } from "../types/style-spec";
|
|
2
|
+
import type { ImmutableLike } from "../types/common";
|
|
3
|
+
export declare function normalizeStyle(style: string | StyleSpecification | ImmutableLike<StyleSpecification>): string | StyleSpecification;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const refProps = [
|
|
1
|
+
const refProps = ["type", "source", "source-layer", "minzoom", "maxzoom", "filter", "layout"];
|
|
2
2
|
export function normalizeStyle(style) {
|
|
3
3
|
if (!style) {
|
|
4
4
|
return null;
|
|
5
5
|
}
|
|
6
|
-
if (typeof style ===
|
|
6
|
+
if (typeof style === "string") {
|
|
7
7
|
return style;
|
|
8
8
|
}
|
|
9
|
-
if (
|
|
9
|
+
if ("toJS" in style) {
|
|
10
10
|
style = style.toJS();
|
|
11
11
|
}
|
|
12
12
|
if (!style.layers) {
|
|
@@ -18,7 +18,7 @@ export function normalizeStyle(style) {
|
|
|
18
18
|
}
|
|
19
19
|
const layers = style.layers.map(layer => {
|
|
20
20
|
let normalizedLayer = null;
|
|
21
|
-
if (
|
|
21
|
+
if ("interactive" in layer) {
|
|
22
22
|
normalizedLayer = Object.assign({}, layer);
|
|
23
23
|
delete normalizedLayer.interactive;
|
|
24
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-utils.js","names":["refProps","normalizeStyle","style","toJS","layers","layerIndex","layer","id","map","normalizedLayer","Object","assign","interactive","layerRef","ref","propName"],"sources":["../../src/utils/style-utils.ts"],"sourcesContent":["import {ImmutableLike
|
|
1
|
+
{"version":3,"file":"style-utils.js","names":["refProps","normalizeStyle","style","toJS","layers","layerIndex","layer","id","map","normalizedLayer","Object","assign","interactive","layerRef","ref","propName"],"sources":["../../src/utils/style-utils.ts"],"sourcesContent":["import type { StyleSpecification } from \"../types/style-spec\";\nimport type { ImmutableLike } from \"../types/common\";\n\nconst refProps = [\n \"type\",\n \"source\",\n \"source-layer\",\n \"minzoom\",\n \"maxzoom\",\n \"filter\",\n \"layout\",\n];\n\n// Prepare a map style object for diffing\n// If immutable - convert to plain object\n// Work around some issues in older styles that would fail Mapbox's diffing\nexport function normalizeStyle(\n style: string | StyleSpecification | ImmutableLike<StyleSpecification>,\n): string | StyleSpecification {\n if (!style) {\n return null;\n }\n if (typeof style === \"string\") {\n return style;\n }\n if (\"toJS\" in style) {\n style = style.toJS();\n }\n if (!style.layers) {\n return style;\n }\n const layerIndex = {};\n\n for (const layer of style.layers) {\n layerIndex[layer.id] = layer;\n }\n\n const layers = style.layers.map((layer) => {\n let normalizedLayer: typeof layer = null;\n\n if (\"interactive\" in layer) {\n normalizedLayer = Object.assign({}, layer);\n // Breaks style diffing :(\n // @ts-ignore legacy field not typed\n delete normalizedLayer.interactive;\n }\n\n // Style diffing doesn't work with refs so expand them out manually before diffing.\n // @ts-ignore legacy field not typed\n const layerRef = layerIndex[layer.ref];\n if (layerRef) {\n normalizedLayer = normalizedLayer || Object.assign({}, layer);\n // @ts-ignore\n delete normalizedLayer.ref;\n // https://github.com/mapbox/mapbox-gl-js/blob/master/src/style-spec/deref.js\n for (const propName of refProps) {\n if (propName in layerRef) {\n normalizedLayer[propName] = layerRef[propName];\n }\n }\n }\n\n return normalizedLayer || layer;\n });\n\n // Do not mutate the style object provided by the user\n return { ...style, layers };\n}\n"],"mappings":"AAGA,MAAMA,QAAQ,GAAG,CACf,MAAM,EACN,QAAQ,EACR,cAAc,EACd,SAAS,EACT,SAAS,EACT,QAAQ,EACR,QAAQ,CACT;AAKD,OAAO,SAASC,cAAcA,CAC5BC,KAAsE,EACzC;EAC7B,IAAI,CAACA,KAAK,EAAE;IACV,OAAO,IAAI;EACb;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOA,KAAK;EACd;EACA,IAAI,MAAM,IAAIA,KAAK,EAAE;IACnBA,KAAK,GAAGA,KAAK,CAACC,IAAI,CAAC,CAAC;EACtB;EACA,IAAI,CAACD,KAAK,CAACE,MAAM,EAAE;IACjB,OAAOF,KAAK;EACd;EACA,MAAMG,UAAU,GAAG,CAAC,CAAC;EAErB,KAAK,MAAMC,KAAK,IAAIJ,KAAK,CAACE,MAAM,EAAE;IAChCC,UAAU,CAACC,KAAK,CAACC,EAAE,CAAC,GAAGD,KAAK;EAC9B;EAEA,MAAMF,MAAM,GAAGF,KAAK,CAACE,MAAM,CAACI,GAAG,CAAEF,KAAK,IAAK;IACzC,IAAIG,eAA6B,GAAG,IAAI;IAExC,IAAI,aAAa,IAAIH,KAAK,EAAE;MAC1BG,eAAe,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEL,KAAK,CAAC;MAG1C,OAAOG,eAAe,CAACG,WAAW;IACpC;IAIA,MAAMC,QAAQ,GAAGR,UAAU,CAACC,KAAK,CAACQ,GAAG,CAAC;IACtC,IAAID,QAAQ,EAAE;MACZJ,eAAe,GAAGA,eAAe,IAAIC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEL,KAAK,CAAC;MAE7D,OAAOG,eAAe,CAACK,GAAG;MAE1B,KAAK,MAAMC,QAAQ,IAAIf,QAAQ,EAAE;QAC/B,IAAIe,QAAQ,IAAIF,QAAQ,EAAE;UACxBJ,eAAe,CAACM,QAAQ,CAAC,GAAGF,QAAQ,CAACE,QAAQ,CAAC;QAChD;MACF;IACF;IAEA,OAAON,eAAe,IAAIH,KAAK;EACjC,CAAC,CAAC;EAGF,OAAO;IAAE,GAAGJ,KAAK;IAAEE;EAAO,CAAC;AAC7B","ignoreList":[]}
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
* Make a copy of a transform
|
|
5
|
-
* @param tr
|
|
6
|
-
*/
|
|
7
|
-
export declare function cloneTransform(tr: Transform): Transform;
|
|
8
|
-
/**
|
|
9
|
-
* Copy projection from one transform to another. This only applies to mapbox-gl transforms
|
|
10
|
-
* @param src the transform to copy projection settings from
|
|
11
|
-
* @param dest to transform to copy projection settings to
|
|
12
|
-
*/
|
|
13
|
-
export declare function syncProjection(src: Transform, dest: Transform): void;
|
|
1
|
+
import type { MaplibreProps } from "../maplibre/maplibre";
|
|
2
|
+
import type { ViewState } from "../types/common";
|
|
3
|
+
import type { TransformLike } from "../types/internal";
|
|
14
4
|
/**
|
|
15
5
|
* Capture a transform's current state
|
|
16
6
|
* @param transform
|
|
17
7
|
* @returns descriptor of the view state
|
|
18
8
|
*/
|
|
19
|
-
export declare function transformToViewState(tr:
|
|
9
|
+
export declare function transformToViewState(tr: TransformLike): ViewState;
|
|
20
10
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
23
|
-
* @param viewState
|
|
24
|
-
* @returns true if the transform has changed
|
|
11
|
+
* Applies requested view state to a transform
|
|
12
|
+
* @returns an object containing detected changes
|
|
25
13
|
*/
|
|
26
|
-
export declare function applyViewStateToTransform(
|
|
14
|
+
export declare function applyViewStateToTransform(
|
|
15
|
+
/** An object that describes Maplibre's camera state */
|
|
16
|
+
tr: TransformLike,
|
|
17
|
+
/** Props from Map component */
|
|
18
|
+
props: MaplibreProps): Partial<TransformLike>;
|
package/dist/utils/transform.js
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { deepEqual } from "./deep-equal.js";
|
|
2
|
-
export function cloneTransform(tr) {
|
|
3
|
-
const newTransform = tr.clone();
|
|
4
|
-
newTransform.pixelsToGLUnits = tr.pixelsToGLUnits;
|
|
5
|
-
return newTransform;
|
|
6
|
-
}
|
|
7
|
-
export function syncProjection(src, dest) {
|
|
8
|
-
if (!src.getProjection) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const srcProjection = src.getProjection();
|
|
12
|
-
const destProjection = dest.getProjection();
|
|
13
|
-
if (!deepEqual(srcProjection, destProjection)) {
|
|
14
|
-
dest.setProjection(srcProjection);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
2
|
export function transformToViewState(tr) {
|
|
18
3
|
return {
|
|
19
4
|
longitude: tr.center.lng,
|
|
@@ -26,31 +11,23 @@ export function transformToViewState(tr) {
|
|
|
26
11
|
}
|
|
27
12
|
export function applyViewStateToTransform(tr, props) {
|
|
28
13
|
const v = props.viewState || props;
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
changed = changed || zoom !== tr.zoom;
|
|
14
|
+
const changes = {};
|
|
15
|
+
if ("longitude" in v && "latitude" in v && (v.longitude !== tr.center.lng || v.latitude !== tr.center.lat)) {
|
|
16
|
+
const LngLat = tr.center.constructor;
|
|
17
|
+
changes.center = new LngLat(v.longitude, v.latitude);
|
|
34
18
|
}
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
tr.bearing = v.bearing;
|
|
38
|
-
changed = changed || bearing !== tr.bearing;
|
|
19
|
+
if ("zoom" in v && v.zoom !== tr.zoom) {
|
|
20
|
+
changes.zoom = v.zoom;
|
|
39
21
|
}
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
tr.pitch = v.pitch;
|
|
43
|
-
changed = changed || pitch !== tr.pitch;
|
|
22
|
+
if ("bearing" in v && v.bearing !== tr.bearing) {
|
|
23
|
+
changes.bearing = v.bearing;
|
|
44
24
|
}
|
|
45
|
-
if (v
|
|
46
|
-
|
|
47
|
-
tr.padding = v.padding;
|
|
25
|
+
if ("pitch" in v && v.pitch !== tr.pitch) {
|
|
26
|
+
changes.pitch = v.pitch;
|
|
48
27
|
}
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
tr.center = new center.constructor(v.longitude, v.latitude);
|
|
52
|
-
changed = changed || center !== tr.center;
|
|
28
|
+
if (v.padding && tr.padding && !deepEqual(v.padding, tr.padding)) {
|
|
29
|
+
changes.padding = v.padding;
|
|
53
30
|
}
|
|
54
|
-
return
|
|
31
|
+
return changes;
|
|
55
32
|
}
|
|
56
33
|
//# sourceMappingURL=transform.js.map
|