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/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export { default as default } from
|
|
1
|
+
export * from "./exports-maplibre-gl.js";
|
|
2
|
+
export { default as default } from "./exports-maplibre-gl.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./exports-
|
|
2
|
-
export { default } from "./exports-
|
|
1
|
+
export * from "./exports-maplibre-gl.js";
|
|
2
|
+
export { default } from "./exports-maplibre-gl.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default"],"sources":["../src/index.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["default"],"sources":["../src/index.ts"],"sourcesContent":["/* eslint-disable import/no-unresolved */\nexport * from \"./exports-maplibre-gl.js\";\nexport { default as default } from \"./exports-maplibre-gl.js\";\n"],"mappings":"AACA,cAAc,0BAA0B;AACxC,SAASA,OAAkB,QAAQ,0BAA0B","ignoreList":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
1
|
+
import type { Map as MapInstance } from "../types/lib";
|
|
2
|
+
import type Maplibre from "./maplibre";
|
|
3
3
|
/** These methods may break the react binding if called directly */
|
|
4
4
|
declare const skipMethods: readonly ["setMaxBounds", "setMinZoom", "setMaxZoom", "setMinPitch", "setMaxPitch", "setRenderWorldCopies", "setProjection", "setStyle", "addSource", "removeSource", "addLayer", "removeLayer", "setLayerZoomRange", "setFilter", "setPaintProperty", "setLayoutProperty", "setLight", "setTerrain", "setFog", "remove"];
|
|
5
|
-
export type MapRef
|
|
6
|
-
getMap():
|
|
7
|
-
} & Omit<
|
|
8
|
-
export default function createRef
|
|
5
|
+
export type MapRef = {
|
|
6
|
+
getMap(): MapInstance;
|
|
7
|
+
} & Omit<MapInstance, (typeof skipMethods)[number]>;
|
|
8
|
+
export default function createRef(mapInstance: Maplibre): MapRef | null;
|
|
9
9
|
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const skipMethods = ["setMaxBounds", "setMinZoom", "setMaxZoom", "setMinPitch", "setMaxPitch", "setRenderWorldCopies", "setProjection", "setStyle", "addSource", "removeSource", "addLayer", "removeLayer", "setLayerZoomRange", "setFilter", "setPaintProperty", "setLayoutProperty", "setLight", "setTerrain", "setFog", "remove"];
|
|
2
|
+
export default function createRef(mapInstance) {
|
|
3
|
+
if (!mapInstance) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
const map = mapInstance.map;
|
|
7
|
+
const result = {
|
|
8
|
+
getMap: () => map
|
|
9
|
+
};
|
|
10
|
+
for (const key of getMethodNames(map)) {
|
|
11
|
+
if (!(key in result) && !skipMethods.includes(key)) {
|
|
12
|
+
result[key] = map[key].bind(map);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
function getMethodNames(obj) {
|
|
18
|
+
const result = new Set();
|
|
19
|
+
let proto = obj;
|
|
20
|
+
while (proto) {
|
|
21
|
+
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
22
|
+
if (key[0] !== "_" && typeof obj[key] === "function" && key !== "fire" && key !== "setEventedParent") {
|
|
23
|
+
result.add(key);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
proto = Object.getPrototypeOf(proto);
|
|
27
|
+
}
|
|
28
|
+
return Array.from(result);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=create-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-ref.js","names":["skipMethods","createRef","mapInstance","map","result","getMap","key","getMethodNames","includes","bind","obj","Set","proto","Object","getOwnPropertyNames","add","getPrototypeOf","Array","from"],"sources":["../../src/maplibre/create-ref.ts"],"sourcesContent":["import type { Map as MapInstance } from \"../types/lib\";\nimport type Maplibre from \"./maplibre\";\n\n/** These methods may break the react binding if called directly */\nconst skipMethods = [\n \"setMaxBounds\",\n \"setMinZoom\",\n \"setMaxZoom\",\n \"setMinPitch\",\n \"setMaxPitch\",\n \"setRenderWorldCopies\",\n \"setProjection\",\n \"setStyle\",\n \"addSource\",\n \"removeSource\",\n \"addLayer\",\n \"removeLayer\",\n \"setLayerZoomRange\",\n \"setFilter\",\n \"setPaintProperty\",\n \"setLayoutProperty\",\n \"setLight\",\n \"setTerrain\",\n \"setFog\",\n \"remove\",\n] as const;\n\nexport type MapRef = {\n getMap(): MapInstance;\n} & Omit<MapInstance, (typeof skipMethods)[number]>;\n\nexport default function createRef(mapInstance: Maplibre): MapRef | null {\n if (!mapInstance) {\n return null;\n }\n\n const map = mapInstance.map;\n const result: any = {\n getMap: () => map,\n };\n\n for (const key of getMethodNames(map)) {\n // @ts-expect-error\n if (!(key in result) && !skipMethods.includes(key)) {\n result[key] = map[key].bind(map);\n }\n }\n\n return result;\n}\n\nfunction getMethodNames(obj: Object) {\n const result = new Set<string>();\n\n let proto = obj;\n while (proto) {\n for (const key of Object.getOwnPropertyNames(proto)) {\n if (\n key[0] !== \"_\" &&\n typeof obj[key] === \"function\" &&\n key !== \"fire\" &&\n key !== \"setEventedParent\"\n ) {\n result.add(key);\n }\n }\n proto = Object.getPrototypeOf(proto);\n }\n return Array.from(result);\n}\n"],"mappings":"AAIA,MAAMA,WAAW,GAAG,CAClB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,UAAU,EACV,WAAW,EACX,cAAc,EACd,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,QAAQ,CACA;AAMV,eAAe,SAASC,SAASA,CAACC,WAAqB,EAAiB;EACtE,IAAI,CAACA,WAAW,EAAE;IAChB,OAAO,IAAI;EACb;EAEA,MAAMC,GAAG,GAAGD,WAAW,CAACC,GAAG;EAC3B,MAAMC,MAAW,GAAG;IAClBC,MAAM,EAAEA,CAAA,KAAMF;EAChB,CAAC;EAED,KAAK,MAAMG,GAAG,IAAIC,cAAc,CAACJ,GAAG,CAAC,EAAE;IAErC,IAAI,EAAEG,GAAG,IAAIF,MAAM,CAAC,IAAI,CAACJ,WAAW,CAACQ,QAAQ,CAACF,GAAG,CAAC,EAAE;MAClDF,MAAM,CAACE,GAAG,CAAC,GAAGH,GAAG,CAACG,GAAG,CAAC,CAACG,IAAI,CAACN,GAAG,CAAC;IAClC;EACF;EAEA,OAAOC,MAAM;AACf;AAEA,SAASG,cAAcA,CAACG,GAAW,EAAE;EACnC,MAAMN,MAAM,GAAG,IAAIO,GAAG,CAAS,CAAC;EAEhC,IAAIC,KAAK,GAAGF,GAAG;EACf,OAAOE,KAAK,EAAE;IACZ,KAAK,MAAMN,GAAG,IAAIO,MAAM,CAACC,mBAAmB,CAACF,KAAK,CAAC,EAAE;MACnD,IACEN,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IACd,OAAOI,GAAG,CAACJ,GAAG,CAAC,KAAK,UAAU,IAC9BA,GAAG,KAAK,MAAM,IACdA,GAAG,KAAK,kBAAkB,EAC1B;QACAF,MAAM,CAACW,GAAG,CAACT,GAAG,CAAC;MACjB;IACF;IACAM,KAAK,GAAGC,MAAM,CAACG,cAAc,CAACJ,KAAK,CAAC;EACtC;EACA,OAAOK,KAAK,CAACC,IAAI,CAACd,MAAM,CAAC;AAC3B","ignoreList":[]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ViewState, PointLike, PaddingOptions, ImmutableLike, LngLatBoundsLike } from "../types/common";
|
|
2
|
+
import type { StyleSpecification, SkySpecification, LightSpecification, TerrainSpecification, ProjectionSpecification } from "../types/style-spec";
|
|
3
|
+
import type { Map as MapInstance } from "../types/lib";
|
|
4
|
+
import type { MapCallbacks } from "../types/events";
|
|
5
|
+
export type MaplibreProps = Partial<ViewState> & MapCallbacks & {
|
|
6
|
+
/** Camera options used when constructing the Map instance */
|
|
7
|
+
initialViewState?: Partial<ViewState> & {
|
|
8
|
+
/** The initial bounds of the map. If bounds is specified, it overrides longitude, latitude and zoom options. */
|
|
9
|
+
bounds?: LngLatBoundsLike;
|
|
10
|
+
/** A fitBounds options object to use only when setting the bounds option. */
|
|
11
|
+
fitBoundsOptions?: {
|
|
12
|
+
offset?: PointLike;
|
|
13
|
+
minZoom?: number;
|
|
14
|
+
maxZoom?: number;
|
|
15
|
+
padding?: number | PaddingOptions;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/** If provided, render into an external WebGL context */
|
|
19
|
+
gl?: WebGLRenderingContext;
|
|
20
|
+
/** For external controller to override the camera state */
|
|
21
|
+
viewState?: ViewState & {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
/** Mapbox style */
|
|
26
|
+
mapStyle?: string | StyleSpecification | ImmutableLike<StyleSpecification>;
|
|
27
|
+
/** Enable diffing when the map style changes
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
styleDiffing?: boolean;
|
|
31
|
+
/** The projection property of the style. Must conform to the Projection Style Specification.
|
|
32
|
+
* @default 'mercator'
|
|
33
|
+
*/
|
|
34
|
+
projection?: ProjectionSpecification | "mercator" | "globe";
|
|
35
|
+
/** Light properties of the map. */
|
|
36
|
+
light?: LightSpecification;
|
|
37
|
+
/** Terrain property of the style. Must conform to the Terrain Style Specification.
|
|
38
|
+
* If `undefined` is provided, removes terrain from the map. */
|
|
39
|
+
terrain?: TerrainSpecification;
|
|
40
|
+
/** Sky properties of the map. Must conform to the Sky Style Specification. */
|
|
41
|
+
sky?: SkySpecification;
|
|
42
|
+
/** Default layers to query on pointer events */
|
|
43
|
+
interactiveLayerIds?: string[];
|
|
44
|
+
/** CSS cursor */
|
|
45
|
+
cursor?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A wrapper for mapbox-gl's Map class
|
|
49
|
+
*/
|
|
50
|
+
export default class Maplibre {
|
|
51
|
+
private _MapClass;
|
|
52
|
+
private _map;
|
|
53
|
+
props: MaplibreProps;
|
|
54
|
+
private _internalUpdate;
|
|
55
|
+
private _hoveredFeatures;
|
|
56
|
+
private _propsedCameraUpdate;
|
|
57
|
+
private _styleComponents;
|
|
58
|
+
static savedMaps: Maplibre[];
|
|
59
|
+
constructor(MapClass: {
|
|
60
|
+
new (options: any): MapInstance;
|
|
61
|
+
}, props: MaplibreProps, container: HTMLDivElement);
|
|
62
|
+
get map(): MapInstance;
|
|
63
|
+
setProps(props: MaplibreProps): void;
|
|
64
|
+
static reuse(props: MaplibreProps, container: HTMLDivElement): Maplibre;
|
|
65
|
+
private _initialize;
|
|
66
|
+
recycle(): void;
|
|
67
|
+
destroy(): void;
|
|
68
|
+
redraw(): void;
|
|
69
|
+
private _updateSize;
|
|
70
|
+
private _updateViewState;
|
|
71
|
+
private _updateSettings;
|
|
72
|
+
private _updateStyle;
|
|
73
|
+
private _updateStyleComponents;
|
|
74
|
+
private _updateHandlers;
|
|
75
|
+
private _onEvent;
|
|
76
|
+
private _onCameraEvent;
|
|
77
|
+
private _onCameraUpdate;
|
|
78
|
+
private _queryRenderedFeatures;
|
|
79
|
+
private _updateHover;
|
|
80
|
+
private _onPointerEvent;
|
|
81
|
+
}
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { transformToViewState, applyViewStateToTransform } from "../utils/transform.js";
|
|
2
|
+
import { normalizeStyle } from "../utils/style-utils.js";
|
|
3
|
+
import { deepEqual } from "../utils/deep-equal.js";
|
|
4
|
+
const DEFAULT_STYLE = {
|
|
5
|
+
version: 8,
|
|
6
|
+
sources: {},
|
|
7
|
+
layers: []
|
|
8
|
+
};
|
|
9
|
+
const pointerEvents = {
|
|
10
|
+
mousedown: "onMouseDown",
|
|
11
|
+
mouseup: "onMouseUp",
|
|
12
|
+
mouseover: "onMouseOver",
|
|
13
|
+
mousemove: "onMouseMove",
|
|
14
|
+
click: "onClick",
|
|
15
|
+
dblclick: "onDblClick",
|
|
16
|
+
mouseenter: "onMouseEnter",
|
|
17
|
+
mouseleave: "onMouseLeave",
|
|
18
|
+
mouseout: "onMouseOut",
|
|
19
|
+
contextmenu: "onContextMenu",
|
|
20
|
+
touchstart: "onTouchStart",
|
|
21
|
+
touchend: "onTouchEnd",
|
|
22
|
+
touchmove: "onTouchMove",
|
|
23
|
+
touchcancel: "onTouchCancel"
|
|
24
|
+
};
|
|
25
|
+
const cameraEvents = {
|
|
26
|
+
movestart: "onMoveStart",
|
|
27
|
+
move: "onMove",
|
|
28
|
+
moveend: "onMoveEnd",
|
|
29
|
+
dragstart: "onDragStart",
|
|
30
|
+
drag: "onDrag",
|
|
31
|
+
dragend: "onDragEnd",
|
|
32
|
+
zoomstart: "onZoomStart",
|
|
33
|
+
zoom: "onZoom",
|
|
34
|
+
zoomend: "onZoomEnd",
|
|
35
|
+
rotatestart: "onRotateStart",
|
|
36
|
+
rotate: "onRotate",
|
|
37
|
+
rotateend: "onRotateEnd",
|
|
38
|
+
pitchstart: "onPitchStart",
|
|
39
|
+
pitch: "onPitch",
|
|
40
|
+
pitchend: "onPitchEnd"
|
|
41
|
+
};
|
|
42
|
+
const otherEvents = {
|
|
43
|
+
wheel: "onWheel",
|
|
44
|
+
boxzoomstart: "onBoxZoomStart",
|
|
45
|
+
boxzoomend: "onBoxZoomEnd",
|
|
46
|
+
boxzoomcancel: "onBoxZoomCancel",
|
|
47
|
+
resize: "onResize",
|
|
48
|
+
load: "onLoad",
|
|
49
|
+
render: "onRender",
|
|
50
|
+
idle: "onIdle",
|
|
51
|
+
remove: "onRemove",
|
|
52
|
+
data: "onData",
|
|
53
|
+
styledata: "onStyleData",
|
|
54
|
+
sourcedata: "onSourceData",
|
|
55
|
+
error: "onError"
|
|
56
|
+
};
|
|
57
|
+
const settingNames = ["minZoom", "maxZoom", "minPitch", "maxPitch", "maxBounds", "projection", "renderWorldCopies"];
|
|
58
|
+
const handlerNames = ["scrollZoom", "boxZoom", "dragRotate", "dragPan", "keyboard", "doubleClickZoom", "touchZoomRotate", "touchPitch"];
|
|
59
|
+
export default class Maplibre {
|
|
60
|
+
_map = null;
|
|
61
|
+
_internalUpdate = false;
|
|
62
|
+
_hoveredFeatures = null;
|
|
63
|
+
_propsedCameraUpdate = null;
|
|
64
|
+
_styleComponents = {};
|
|
65
|
+
static savedMaps = [];
|
|
66
|
+
constructor(MapClass, props, container) {
|
|
67
|
+
this._MapClass = MapClass;
|
|
68
|
+
this.props = props;
|
|
69
|
+
this._initialize(container);
|
|
70
|
+
}
|
|
71
|
+
get map() {
|
|
72
|
+
return this._map;
|
|
73
|
+
}
|
|
74
|
+
setProps(props) {
|
|
75
|
+
const oldProps = this.props;
|
|
76
|
+
this.props = props;
|
|
77
|
+
const settingsChanged = this._updateSettings(props, oldProps);
|
|
78
|
+
const sizeChanged = this._updateSize(props);
|
|
79
|
+
const viewStateChanged = this._updateViewState(props);
|
|
80
|
+
this._updateStyle(props, oldProps);
|
|
81
|
+
this._updateStyleComponents(props);
|
|
82
|
+
this._updateHandlers(props, oldProps);
|
|
83
|
+
if (settingsChanged || sizeChanged || viewStateChanged && !this._map.isMoving()) {
|
|
84
|
+
this.redraw();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
static reuse(props, container) {
|
|
88
|
+
const that = Maplibre.savedMaps.pop();
|
|
89
|
+
if (!that) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const map = that.map;
|
|
93
|
+
const oldContainer = map.getContainer();
|
|
94
|
+
container.className = oldContainer.className;
|
|
95
|
+
while (oldContainer.childNodes.length > 0) {
|
|
96
|
+
container.appendChild(oldContainer.childNodes[0]);
|
|
97
|
+
}
|
|
98
|
+
map._container = container;
|
|
99
|
+
const resizeObserver = map._resizeObserver;
|
|
100
|
+
if (resizeObserver) {
|
|
101
|
+
resizeObserver.disconnect();
|
|
102
|
+
resizeObserver.observe(container);
|
|
103
|
+
}
|
|
104
|
+
that.setProps({
|
|
105
|
+
...props,
|
|
106
|
+
styleDiffing: false
|
|
107
|
+
});
|
|
108
|
+
map.resize();
|
|
109
|
+
const {
|
|
110
|
+
initialViewState
|
|
111
|
+
} = props;
|
|
112
|
+
if (initialViewState) {
|
|
113
|
+
if (initialViewState.bounds) {
|
|
114
|
+
map.fitBounds(initialViewState.bounds, {
|
|
115
|
+
...initialViewState.fitBoundsOptions,
|
|
116
|
+
duration: 0
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
that._updateViewState(initialViewState);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (map.isStyleLoaded()) {
|
|
123
|
+
map.fire("load");
|
|
124
|
+
} else {
|
|
125
|
+
map.once("style.load", () => map.fire("load"));
|
|
126
|
+
}
|
|
127
|
+
map._update();
|
|
128
|
+
return that;
|
|
129
|
+
}
|
|
130
|
+
_initialize(container) {
|
|
131
|
+
const {
|
|
132
|
+
props
|
|
133
|
+
} = this;
|
|
134
|
+
const {
|
|
135
|
+
mapStyle = DEFAULT_STYLE
|
|
136
|
+
} = props;
|
|
137
|
+
const mapOptions = {
|
|
138
|
+
...props,
|
|
139
|
+
...props.initialViewState,
|
|
140
|
+
container,
|
|
141
|
+
style: normalizeStyle(mapStyle)
|
|
142
|
+
};
|
|
143
|
+
const viewState = mapOptions.initialViewState || mapOptions.viewState || mapOptions;
|
|
144
|
+
Object.assign(mapOptions, {
|
|
145
|
+
center: [viewState.longitude || 0, viewState.latitude || 0],
|
|
146
|
+
zoom: viewState.zoom || 0,
|
|
147
|
+
pitch: viewState.pitch || 0,
|
|
148
|
+
bearing: viewState.bearing || 0
|
|
149
|
+
});
|
|
150
|
+
if (props.gl) {
|
|
151
|
+
const getContext = HTMLCanvasElement.prototype.getContext;
|
|
152
|
+
HTMLCanvasElement.prototype.getContext = () => {
|
|
153
|
+
HTMLCanvasElement.prototype.getContext = getContext;
|
|
154
|
+
return props.gl;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const map = new this._MapClass(mapOptions);
|
|
158
|
+
if (viewState.padding) {
|
|
159
|
+
map.setPadding(viewState.padding);
|
|
160
|
+
}
|
|
161
|
+
if (props.cursor) {
|
|
162
|
+
map.getCanvas().style.cursor = props.cursor;
|
|
163
|
+
}
|
|
164
|
+
map.transformCameraUpdate = this._onCameraUpdate;
|
|
165
|
+
map.on("style.load", () => {
|
|
166
|
+
this._styleComponents = {
|
|
167
|
+
light: map.getLight(),
|
|
168
|
+
sky: map.getSky(),
|
|
169
|
+
projection: map.getProjection?.(),
|
|
170
|
+
terrain: map.getTerrain()
|
|
171
|
+
};
|
|
172
|
+
this._updateStyleComponents(this.props);
|
|
173
|
+
});
|
|
174
|
+
map.on("sourcedata", () => {
|
|
175
|
+
this._updateStyleComponents(this.props);
|
|
176
|
+
});
|
|
177
|
+
for (const eventName in pointerEvents) {
|
|
178
|
+
map.on(eventName, this._onPointerEvent);
|
|
179
|
+
}
|
|
180
|
+
for (const eventName in cameraEvents) {
|
|
181
|
+
map.on(eventName, this._onCameraEvent);
|
|
182
|
+
}
|
|
183
|
+
for (const eventName in otherEvents) {
|
|
184
|
+
map.on(eventName, this._onEvent);
|
|
185
|
+
}
|
|
186
|
+
this._map = map;
|
|
187
|
+
}
|
|
188
|
+
recycle() {
|
|
189
|
+
const container = this.map.getContainer();
|
|
190
|
+
const children = container.querySelector("[mapboxgl-children]");
|
|
191
|
+
children?.remove();
|
|
192
|
+
Maplibre.savedMaps.push(this);
|
|
193
|
+
}
|
|
194
|
+
destroy() {
|
|
195
|
+
this._map.remove();
|
|
196
|
+
}
|
|
197
|
+
redraw() {
|
|
198
|
+
const map = this._map;
|
|
199
|
+
if (map.style) {
|
|
200
|
+
if (map._frame) {
|
|
201
|
+
map._frame.cancel();
|
|
202
|
+
map._frame = null;
|
|
203
|
+
}
|
|
204
|
+
map._render();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
_updateSize(nextProps) {
|
|
208
|
+
const {
|
|
209
|
+
viewState
|
|
210
|
+
} = nextProps;
|
|
211
|
+
if (viewState) {
|
|
212
|
+
const map = this._map;
|
|
213
|
+
if (viewState.width !== map.transform.width || viewState.height !== map.transform.height) {
|
|
214
|
+
map.resize();
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
_updateViewState(nextProps) {
|
|
221
|
+
const map = this._map;
|
|
222
|
+
const tr = map.transform;
|
|
223
|
+
const isMoving = map.isMoving();
|
|
224
|
+
if (!isMoving) {
|
|
225
|
+
const changes = applyViewStateToTransform(tr, nextProps);
|
|
226
|
+
if (Object.keys(changes).length > 0) {
|
|
227
|
+
this._internalUpdate = true;
|
|
228
|
+
map.jumpTo(changes);
|
|
229
|
+
this._internalUpdate = false;
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
_updateSettings(nextProps, currProps) {
|
|
236
|
+
const map = this._map;
|
|
237
|
+
let changed = false;
|
|
238
|
+
for (const propName of settingNames) {
|
|
239
|
+
if (propName in nextProps && !deepEqual(nextProps[propName], currProps[propName])) {
|
|
240
|
+
changed = true;
|
|
241
|
+
const setter = map[`set${propName[0].toUpperCase()}${propName.slice(1)}`];
|
|
242
|
+
setter?.call(map, nextProps[propName]);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return changed;
|
|
246
|
+
}
|
|
247
|
+
_updateStyle(nextProps, currProps) {
|
|
248
|
+
if (nextProps.cursor !== currProps.cursor) {
|
|
249
|
+
this._map.getCanvas().style.cursor = nextProps.cursor || "";
|
|
250
|
+
}
|
|
251
|
+
if (nextProps.mapStyle !== currProps.mapStyle) {
|
|
252
|
+
const {
|
|
253
|
+
mapStyle = DEFAULT_STYLE,
|
|
254
|
+
styleDiffing = true
|
|
255
|
+
} = nextProps;
|
|
256
|
+
const options = {
|
|
257
|
+
diff: styleDiffing
|
|
258
|
+
};
|
|
259
|
+
if ("localIdeographFontFamily" in nextProps) {
|
|
260
|
+
options.localIdeographFontFamily = nextProps.localIdeographFontFamily;
|
|
261
|
+
}
|
|
262
|
+
this._map.setStyle(normalizeStyle(mapStyle), options);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
_updateStyleComponents(_ref) {
|
|
266
|
+
let {
|
|
267
|
+
light,
|
|
268
|
+
projection,
|
|
269
|
+
sky,
|
|
270
|
+
terrain
|
|
271
|
+
} = _ref;
|
|
272
|
+
const map = this._map;
|
|
273
|
+
const currProps = this._styleComponents;
|
|
274
|
+
if (map.style._loaded) {
|
|
275
|
+
if (light && !deepEqual(light, currProps.light)) {
|
|
276
|
+
currProps.light = light;
|
|
277
|
+
map.setLight(light);
|
|
278
|
+
}
|
|
279
|
+
if (projection && !deepEqual(projection, currProps.projection) && projection !== currProps.projection?.type) {
|
|
280
|
+
currProps.projection = typeof projection === "string" ? {
|
|
281
|
+
type: projection
|
|
282
|
+
} : projection;
|
|
283
|
+
map.setProjection?.(currProps.projection);
|
|
284
|
+
}
|
|
285
|
+
if (sky && !deepEqual(sky, currProps.sky)) {
|
|
286
|
+
currProps.sky = sky;
|
|
287
|
+
map.setSky(sky);
|
|
288
|
+
}
|
|
289
|
+
if (terrain !== undefined && !deepEqual(terrain, currProps.terrain)) {
|
|
290
|
+
if (!terrain || map.getSource(terrain.source)) {
|
|
291
|
+
currProps.terrain = terrain;
|
|
292
|
+
map.setTerrain(terrain);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
_updateHandlers(nextProps, currProps) {
|
|
298
|
+
const map = this._map;
|
|
299
|
+
for (const propName of handlerNames) {
|
|
300
|
+
const newValue = nextProps[propName] ?? true;
|
|
301
|
+
const oldValue = currProps[propName] ?? true;
|
|
302
|
+
if (!deepEqual(newValue, oldValue)) {
|
|
303
|
+
if (newValue) {
|
|
304
|
+
map[propName].enable(newValue);
|
|
305
|
+
} else {
|
|
306
|
+
map[propName].disable();
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
_onEvent = e => {
|
|
312
|
+
const cb = this.props[otherEvents[e.type]];
|
|
313
|
+
if (cb) {
|
|
314
|
+
cb(e);
|
|
315
|
+
} else if (e.type === "error") {
|
|
316
|
+
console.error(e.error);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
_onCameraEvent = e => {
|
|
320
|
+
if (this._internalUpdate) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
e.viewState = this._propsedCameraUpdate || transformToViewState(this._map.transform);
|
|
324
|
+
const cb = this.props[cameraEvents[e.type]];
|
|
325
|
+
if (cb) {
|
|
326
|
+
cb(e);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
_onCameraUpdate = tr => {
|
|
330
|
+
if (this._internalUpdate) {
|
|
331
|
+
return tr;
|
|
332
|
+
}
|
|
333
|
+
this._propsedCameraUpdate = transformToViewState(tr);
|
|
334
|
+
return applyViewStateToTransform(tr, this.props);
|
|
335
|
+
};
|
|
336
|
+
_queryRenderedFeatures(point) {
|
|
337
|
+
const map = this._map;
|
|
338
|
+
const {
|
|
339
|
+
interactiveLayerIds = []
|
|
340
|
+
} = this.props;
|
|
341
|
+
try {
|
|
342
|
+
return map.queryRenderedFeatures(point, {
|
|
343
|
+
layers: interactiveLayerIds.filter(map.getLayer.bind(map))
|
|
344
|
+
});
|
|
345
|
+
} catch {
|
|
346
|
+
return [];
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
_updateHover(e) {
|
|
350
|
+
const {
|
|
351
|
+
props
|
|
352
|
+
} = this;
|
|
353
|
+
const shouldTrackHoveredFeatures = props.interactiveLayerIds && (props.onMouseMove || props.onMouseEnter || props.onMouseLeave);
|
|
354
|
+
if (shouldTrackHoveredFeatures) {
|
|
355
|
+
const eventType = e.type;
|
|
356
|
+
const wasHovering = this._hoveredFeatures?.length > 0;
|
|
357
|
+
const features = this._queryRenderedFeatures(e.point);
|
|
358
|
+
const isHovering = features.length > 0;
|
|
359
|
+
if (!isHovering && wasHovering) {
|
|
360
|
+
e.type = "mouseleave";
|
|
361
|
+
this._onPointerEvent(e);
|
|
362
|
+
}
|
|
363
|
+
this._hoveredFeatures = features;
|
|
364
|
+
if (isHovering && !wasHovering) {
|
|
365
|
+
e.type = "mouseenter";
|
|
366
|
+
this._onPointerEvent(e);
|
|
367
|
+
}
|
|
368
|
+
e.type = eventType;
|
|
369
|
+
} else {
|
|
370
|
+
this._hoveredFeatures = null;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
_onPointerEvent = e => {
|
|
374
|
+
if (e.type === "mousemove" || e.type === "mouseout") {
|
|
375
|
+
this._updateHover(e);
|
|
376
|
+
}
|
|
377
|
+
const cb = this.props[pointerEvents[e.type]];
|
|
378
|
+
if (cb) {
|
|
379
|
+
if (this.props.interactiveLayerIds && e.type !== "mouseover" && e.type !== "mouseout") {
|
|
380
|
+
e.features = this._hoveredFeatures || this._queryRenderedFeatures(e.point);
|
|
381
|
+
}
|
|
382
|
+
cb(e);
|
|
383
|
+
delete e.features;
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
//# sourceMappingURL=maplibre.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maplibre.js","names":["transformToViewState","applyViewStateToTransform","normalizeStyle","deepEqual","DEFAULT_STYLE","version","sources","layers","pointerEvents","mousedown","mouseup","mouseover","mousemove","click","dblclick","mouseenter","mouseleave","mouseout","contextmenu","touchstart","touchend","touchmove","touchcancel","cameraEvents","movestart","move","moveend","dragstart","drag","dragend","zoomstart","zoom","zoomend","rotatestart","rotate","rotateend","pitchstart","pitch","pitchend","otherEvents","wheel","boxzoomstart","boxzoomend","boxzoomcancel","resize","load","render","idle","remove","data","styledata","sourcedata","error","settingNames","handlerNames","Maplibre","_map","_internalUpdate","_hoveredFeatures","_propsedCameraUpdate","_styleComponents","savedMaps","constructor","MapClass","props","container","_MapClass","_initialize","map","setProps","oldProps","settingsChanged","_updateSettings","sizeChanged","_updateSize","viewStateChanged","_updateViewState","_updateStyle","_updateStyleComponents","_updateHandlers","isMoving","redraw","reuse","that","pop","oldContainer","getContainer","className","childNodes","length","appendChild","_container","resizeObserver","_resizeObserver","disconnect","observe","styleDiffing","initialViewState","bounds","fitBounds","fitBoundsOptions","duration","isStyleLoaded","fire","once","_update","mapStyle","mapOptions","style","viewState","Object","assign","center","longitude","latitude","bearing","gl","getContext","HTMLCanvasElement","prototype","padding","setPadding","cursor","getCanvas","transformCameraUpdate","_onCameraUpdate","on","light","getLight","sky","getSky","projection","getProjection","terrain","getTerrain","eventName","_onPointerEvent","_onCameraEvent","_onEvent","recycle","children","querySelector","push","destroy","_frame","cancel","_render","nextProps","width","transform","height","tr","changes","keys","jumpTo","currProps","changed","propName","setter","toUpperCase","slice","call","options","diff","localIdeographFontFamily","setStyle","_ref","_loaded","setLight","type","setProjection","setSky","undefined","getSource","source","setTerrain","newValue","oldValue","enable","disable","e","cb","console","_queryRenderedFeatures","point","interactiveLayerIds","queryRenderedFeatures","filter","getLayer","bind","_updateHover","shouldTrackHoveredFeatures","onMouseMove","onMouseEnter","onMouseLeave","eventType","wasHovering","features","isHovering"],"sources":["../../src/maplibre/maplibre.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-floating-promises */\nimport {\n transformToViewState,\n applyViewStateToTransform,\n} from \"../utils/transform\";\nimport { normalizeStyle } from \"../utils/style-utils\";\nimport { deepEqual } from \"../utils/deep-equal\";\n\nimport type { TransformLike } from \"../types/internal\";\nimport type {\n ViewState,\n Point,\n PointLike,\n PaddingOptions,\n ImmutableLike,\n LngLatBoundsLike,\n MapGeoJSONFeature,\n} from \"../types/common\";\nimport type {\n StyleSpecification,\n SkySpecification,\n LightSpecification,\n TerrainSpecification,\n ProjectionSpecification,\n} from \"../types/style-spec\";\nimport type { Map as MapInstance } from \"../types/lib\";\nimport type {\n MapCallbacks,\n ViewStateChangeEvent,\n MapEvent,\n ErrorEvent,\n MapMouseEvent,\n} from \"../types/events\";\n\nexport type MaplibreProps = Partial<ViewState> &\n MapCallbacks & {\n /** Camera options used when constructing the Map instance */\n initialViewState?: Partial<ViewState> & {\n /** The initial bounds of the map. If bounds is specified, it overrides longitude, latitude and zoom options. */\n bounds?: LngLatBoundsLike;\n /** A fitBounds options object to use only when setting the bounds option. */\n fitBoundsOptions?: {\n offset?: PointLike;\n minZoom?: number;\n maxZoom?: number;\n padding?: number | PaddingOptions;\n };\n };\n\n /** If provided, render into an external WebGL context */\n gl?: WebGLRenderingContext;\n\n /** For external controller to override the camera state */\n viewState?: ViewState & {\n width: number;\n height: number;\n };\n\n // Styling\n\n /** Mapbox style */\n mapStyle?: string | StyleSpecification | ImmutableLike<StyleSpecification>;\n /** Enable diffing when the map style changes\n * @default true\n */\n styleDiffing?: boolean;\n /** The projection property of the style. Must conform to the Projection Style Specification.\n * @default 'mercator'\n */\n projection?: ProjectionSpecification | \"mercator\" | \"globe\";\n /** Light properties of the map. */\n light?: LightSpecification;\n /** Terrain property of the style. Must conform to the Terrain Style Specification.\n * If `undefined` is provided, removes terrain from the map. */\n terrain?: TerrainSpecification;\n /** Sky properties of the map. Must conform to the Sky Style Specification. */\n sky?: SkySpecification;\n\n /** Default layers to query on pointer events */\n interactiveLayerIds?: string[];\n /** CSS cursor */\n cursor?: string;\n };\n\nconst DEFAULT_STYLE = {\n version: 8,\n sources: {},\n layers: [],\n} as StyleSpecification;\n\nconst pointerEvents = {\n mousedown: \"onMouseDown\",\n mouseup: \"onMouseUp\",\n mouseover: \"onMouseOver\",\n mousemove: \"onMouseMove\",\n click: \"onClick\",\n dblclick: \"onDblClick\",\n mouseenter: \"onMouseEnter\",\n mouseleave: \"onMouseLeave\",\n mouseout: \"onMouseOut\",\n contextmenu: \"onContextMenu\",\n touchstart: \"onTouchStart\",\n touchend: \"onTouchEnd\",\n touchmove: \"onTouchMove\",\n touchcancel: \"onTouchCancel\",\n};\nconst cameraEvents = {\n movestart: \"onMoveStart\",\n move: \"onMove\",\n moveend: \"onMoveEnd\",\n dragstart: \"onDragStart\",\n drag: \"onDrag\",\n dragend: \"onDragEnd\",\n zoomstart: \"onZoomStart\",\n zoom: \"onZoom\",\n zoomend: \"onZoomEnd\",\n rotatestart: \"onRotateStart\",\n rotate: \"onRotate\",\n rotateend: \"onRotateEnd\",\n pitchstart: \"onPitchStart\",\n pitch: \"onPitch\",\n pitchend: \"onPitchEnd\",\n};\nconst otherEvents = {\n wheel: \"onWheel\",\n boxzoomstart: \"onBoxZoomStart\",\n boxzoomend: \"onBoxZoomEnd\",\n boxzoomcancel: \"onBoxZoomCancel\",\n resize: \"onResize\",\n load: \"onLoad\",\n render: \"onRender\",\n idle: \"onIdle\",\n remove: \"onRemove\",\n data: \"onData\",\n styledata: \"onStyleData\",\n sourcedata: \"onSourceData\",\n error: \"onError\",\n};\nconst settingNames = [\n \"minZoom\",\n \"maxZoom\",\n \"minPitch\",\n \"maxPitch\",\n \"maxBounds\",\n \"projection\",\n \"renderWorldCopies\",\n];\nconst handlerNames = [\n \"scrollZoom\",\n \"boxZoom\",\n \"dragRotate\",\n \"dragPan\",\n \"keyboard\",\n \"doubleClickZoom\",\n \"touchZoomRotate\",\n \"touchPitch\",\n];\n\n/**\n * A wrapper for mapbox-gl's Map class\n */\nexport default class Maplibre {\n private _MapClass: { new (options: any): MapInstance };\n // mapboxgl.Map instance\n private _map: MapInstance = null;\n // User-supplied props\n props: MaplibreProps;\n\n // Internal states\n private _internalUpdate: boolean = false;\n private _hoveredFeatures: MapGeoJSONFeature[] = null;\n private _propsedCameraUpdate: ViewState | null = null;\n private _styleComponents: {\n light?: LightSpecification;\n sky?: SkySpecification;\n projection?: ProjectionSpecification;\n terrain?: TerrainSpecification | null;\n } = {};\n\n static savedMaps: Maplibre[] = [];\n\n constructor(\n MapClass: { new (options: any): MapInstance },\n props: MaplibreProps,\n container: HTMLDivElement,\n ) {\n this._MapClass = MapClass;\n this.props = props;\n this._initialize(container);\n }\n\n get map(): MapInstance {\n return this._map;\n }\n\n setProps(props: MaplibreProps) {\n const oldProps = this.props;\n this.props = props;\n\n const settingsChanged = this._updateSettings(props, oldProps);\n const sizeChanged = this._updateSize(props);\n const viewStateChanged = this._updateViewState(props);\n this._updateStyle(props, oldProps);\n this._updateStyleComponents(props);\n this._updateHandlers(props, oldProps);\n\n // If 1) view state has changed to match props and\n // 2) the props change is not triggered by map events,\n // it's driven by an external state change. Redraw immediately\n if (\n settingsChanged ||\n sizeChanged ||\n (viewStateChanged && !this._map.isMoving())\n ) {\n this.redraw();\n }\n }\n\n static reuse(props: MaplibreProps, container: HTMLDivElement): Maplibre {\n const that = Maplibre.savedMaps.pop();\n if (!that) {\n return null;\n }\n\n const map = that.map;\n // When reusing the saved map, we need to reparent the map(canvas) and other child nodes\n // intoto the new container from the props.\n // Step 1: reparenting child nodes from old container to new container\n const oldContainer = map.getContainer();\n container.className = oldContainer.className;\n while (oldContainer.childNodes.length > 0) {\n container.appendChild(oldContainer.childNodes[0]);\n }\n // Step 2: replace the internal container with new container from the react component\n // @ts-ignore\n map._container = container;\n\n // With maplibre-gl as mapLib, map uses ResizeObserver to observe when its container resizes.\n // When reusing the saved map, we need to disconnect the observer and observe the new container.\n // Step 3: telling the ResizeObserver to disconnect and observe the new container\n // @ts-ignore\n const resizeObserver = map._resizeObserver;\n if (resizeObserver) {\n resizeObserver.disconnect();\n resizeObserver.observe(container);\n }\n\n // Step 4: apply new props\n that.setProps({ ...props, styleDiffing: false });\n map.resize();\n const { initialViewState } = props;\n if (initialViewState) {\n if (initialViewState.bounds) {\n map.fitBounds(initialViewState.bounds, {\n ...initialViewState.fitBoundsOptions,\n duration: 0,\n });\n } else {\n that._updateViewState(initialViewState);\n }\n }\n\n // Simulate load event\n if (map.isStyleLoaded()) {\n map.fire(\"load\");\n } else {\n map.once(\"style.load\", () => map.fire(\"load\"));\n }\n\n // Force reload\n // @ts-ignore\n map._update();\n return that;\n }\n\n /* eslint-disable complexity,max-statements */\n private _initialize(container: HTMLDivElement) {\n const { props } = this;\n const { mapStyle = DEFAULT_STYLE } = props;\n const mapOptions = {\n ...props,\n ...props.initialViewState,\n container,\n style: normalizeStyle(mapStyle),\n };\n\n const viewState =\n mapOptions.initialViewState || mapOptions.viewState || mapOptions;\n Object.assign(mapOptions, {\n center: [viewState.longitude || 0, viewState.latitude || 0],\n zoom: viewState.zoom || 0,\n pitch: viewState.pitch || 0,\n bearing: viewState.bearing || 0,\n });\n\n if (props.gl) {\n // eslint-disable-next-line\n const getContext = HTMLCanvasElement.prototype.getContext;\n // Hijack canvas.getContext to return our own WebGLContext\n // This will be called inside the mapboxgl.Map constructor\n // @ts-expect-error\n HTMLCanvasElement.prototype.getContext = () => {\n // Unhijack immediately\n HTMLCanvasElement.prototype.getContext = getContext;\n return props.gl;\n };\n }\n\n const map = new this._MapClass(mapOptions);\n // Props that are not part of constructor options\n if (viewState.padding) {\n map.setPadding(viewState.padding);\n }\n if (props.cursor) {\n map.getCanvas().style.cursor = props.cursor;\n }\n\n // add listeners\n map.transformCameraUpdate = this._onCameraUpdate;\n map.on(\"style.load\", () => {\n // Map style has changed, this would have wiped out all settings from props\n this._styleComponents = {\n light: map.getLight(),\n sky: map.getSky(),\n // @ts-ignore getProjection() does not exist in v4\n projection: map.getProjection?.(),\n terrain: map.getTerrain(),\n };\n this._updateStyleComponents(this.props);\n });\n map.on(\"sourcedata\", () => {\n // Some sources have loaded, we may need them to attach terrain\n this._updateStyleComponents(this.props);\n });\n for (const eventName in pointerEvents) {\n map.on(eventName, this._onPointerEvent);\n }\n for (const eventName in cameraEvents) {\n map.on(eventName, this._onCameraEvent);\n }\n for (const eventName in otherEvents) {\n map.on(eventName, this._onEvent);\n }\n this._map = map;\n }\n /* eslint-enable complexity,max-statements */\n\n recycle() {\n // Clean up unnecessary elements before storing for reuse.\n const container = this.map.getContainer();\n const children = container.querySelector(\"[mapboxgl-children]\");\n children?.remove();\n\n Maplibre.savedMaps.push(this);\n }\n\n destroy() {\n this._map.remove();\n }\n\n // Force redraw the map now. Typically resize() and jumpTo() is reflected in the next\n // render cycle, which is managed by Mapbox's animation loop.\n // This removes the synchronization issue caused by requestAnimationFrame.\n redraw() {\n const map = this._map as any;\n // map._render will throw error if style does not exist\n // https://github.com/mapbox/mapbox-gl-js/blob/fb9fc316da14e99ff4368f3e4faa3888fb43c513\n // /src/ui/map.js#L1834\n if (map.style) {\n // cancel the scheduled update\n if (map._frame) {\n map._frame.cancel();\n map._frame = null;\n }\n // the order is important - render() may schedule another update\n map._render();\n }\n }\n\n /* Trigger map resize if size is controlled\n @param {object} nextProps\n @returns {bool} true if size has changed\n */\n private _updateSize(nextProps: MaplibreProps): boolean {\n // Check if size is controlled\n const { viewState } = nextProps;\n if (viewState) {\n const map = this._map;\n if (\n viewState.width !== map.transform.width ||\n viewState.height !== map.transform.height\n ) {\n map.resize();\n return true;\n }\n }\n return false;\n }\n\n // Adapted from map.jumpTo\n /* Update camera to match props\n @param {object} nextProps\n @param {bool} triggerEvents - should fire camera events\n @returns {bool} true if anything is changed\n */\n private _updateViewState(nextProps: MaplibreProps): boolean {\n const map = this._map;\n const tr = map.transform;\n const isMoving = map.isMoving();\n\n // Avoid manipulating the real transform when interaction/animation is ongoing\n // as it would interfere with Mapbox's handlers\n if (!isMoving) {\n const changes: any = applyViewStateToTransform(tr, nextProps);\n if (Object.keys(changes).length > 0) {\n this._internalUpdate = true;\n map.jumpTo(changes);\n this._internalUpdate = false;\n return true;\n }\n }\n\n return false;\n }\n\n /* Update camera constraints and projection settings to match props\n @param {object} nextProps\n @param {object} currProps\n @returns {bool} true if anything is changed\n */\n private _updateSettings(\n nextProps: MaplibreProps,\n currProps: MaplibreProps,\n ): boolean {\n const map = this._map;\n let changed = false;\n for (const propName of settingNames) {\n if (\n propName in nextProps &&\n !deepEqual(nextProps[propName], currProps[propName])\n ) {\n changed = true;\n const setter =\n map[`set${propName[0].toUpperCase()}${propName.slice(1)}`];\n setter?.call(map, nextProps[propName]);\n }\n }\n return changed;\n }\n\n /* Update map style to match props */\n private _updateStyle(\n nextProps: MaplibreProps,\n currProps: MaplibreProps,\n ): void {\n if (nextProps.cursor !== currProps.cursor) {\n this._map.getCanvas().style.cursor = nextProps.cursor || \"\";\n }\n if (nextProps.mapStyle !== currProps.mapStyle) {\n const { mapStyle = DEFAULT_STYLE, styleDiffing = true } = nextProps;\n const options: any = {\n diff: styleDiffing,\n };\n if (\"localIdeographFontFamily\" in nextProps) {\n // @ts-ignore Mapbox specific prop\n options.localIdeographFontFamily = nextProps.localIdeographFontFamily;\n }\n this._map.setStyle(normalizeStyle(mapStyle), options);\n }\n }\n\n /* Update fog, light, projection and terrain to match props\n * These props are special because\n * 1. They can not be applied right away. Certain conditions (style loaded, source loaded, etc.) must be met\n * 2. They can be overwritten by mapStyle\n */\n private _updateStyleComponents({\n light,\n projection,\n sky,\n terrain,\n }: MaplibreProps): void {\n const map = this._map;\n const currProps = this._styleComponents;\n // We can safely manipulate map style once it's loaded\n if (map.style._loaded) {\n if (light && !deepEqual(light, currProps.light)) {\n currProps.light = light;\n map.setLight(light);\n }\n if (\n projection &&\n !deepEqual(projection, currProps.projection) &&\n projection !== currProps.projection?.type\n ) {\n currProps.projection =\n typeof projection === \"string\" ? { type: projection } : projection;\n // @ts-ignore setProjection does not exist in v4\n map.setProjection?.(currProps.projection);\n }\n if (sky && !deepEqual(sky, currProps.sky)) {\n currProps.sky = sky;\n map.setSky(sky);\n }\n if (terrain !== undefined && !deepEqual(terrain, currProps.terrain)) {\n if (!terrain || map.getSource(terrain.source)) {\n currProps.terrain = terrain;\n map.setTerrain(terrain);\n }\n }\n }\n }\n\n /* Update interaction handlers to match props */\n private _updateHandlers(\n nextProps: MaplibreProps,\n currProps: MaplibreProps,\n ): void {\n const map = this._map;\n for (const propName of handlerNames) {\n const newValue = nextProps[propName] ?? true;\n const oldValue = currProps[propName] ?? true;\n if (!deepEqual(newValue, oldValue)) {\n if (newValue) {\n map[propName].enable(newValue);\n } else {\n map[propName].disable();\n }\n }\n }\n }\n\n private _onEvent = (e: MapEvent) => {\n // @ts-ignore\n const cb = this.props[otherEvents[e.type]];\n if (cb) {\n cb(e);\n } else if (e.type === \"error\") {\n console.error((e as ErrorEvent).error); // eslint-disable-line\n }\n };\n\n private _onCameraEvent = (e: ViewStateChangeEvent) => {\n if (this._internalUpdate) {\n return;\n }\n e.viewState =\n this._propsedCameraUpdate || transformToViewState(this._map.transform);\n // @ts-ignore\n const cb = this.props[cameraEvents[e.type]];\n if (cb) {\n cb(e);\n }\n };\n\n private _onCameraUpdate = (tr: TransformLike) => {\n if (this._internalUpdate) {\n return tr;\n }\n this._propsedCameraUpdate = transformToViewState(tr);\n return applyViewStateToTransform(tr, this.props) as any;\n };\n\n private _queryRenderedFeatures(point: Point) {\n const map = this._map;\n const { interactiveLayerIds = [] } = this.props;\n try {\n return map.queryRenderedFeatures(point, {\n layers: interactiveLayerIds.filter(map.getLayer.bind(map)),\n });\n } catch {\n // May fail if style is not loaded\n return [];\n }\n }\n\n private _updateHover(e: MapMouseEvent) {\n const { props } = this;\n const shouldTrackHoveredFeatures =\n props.interactiveLayerIds &&\n (props.onMouseMove || props.onMouseEnter || props.onMouseLeave);\n\n if (shouldTrackHoveredFeatures) {\n const eventType = e.type;\n const wasHovering = this._hoveredFeatures?.length > 0;\n const features = this._queryRenderedFeatures(e.point);\n const isHovering = features.length > 0;\n\n if (!isHovering && wasHovering) {\n e.type = \"mouseleave\";\n this._onPointerEvent(e);\n }\n this._hoveredFeatures = features;\n if (isHovering && !wasHovering) {\n e.type = \"mouseenter\";\n this._onPointerEvent(e);\n }\n e.type = eventType;\n } else {\n this._hoveredFeatures = null;\n }\n }\n\n private _onPointerEvent = (e: MapMouseEvent) => {\n if (e.type === \"mousemove\" || e.type === \"mouseout\") {\n this._updateHover(e);\n }\n\n // @ts-ignore\n const cb = this.props[pointerEvents[e.type]];\n if (cb) {\n if (\n this.props.interactiveLayerIds &&\n e.type !== \"mouseover\" &&\n e.type !== \"mouseout\"\n ) {\n e.features =\n this._hoveredFeatures || this._queryRenderedFeatures(e.point);\n }\n cb(e);\n delete e.features;\n }\n };\n}\n"],"mappings":"SAEEA,oBAAoB,EACpBC,yBAAyB;AAAA,SAElBC,cAAc;AAAA,SACdC,SAAS;AA8ElB,MAAMC,aAAa,GAAG;EACpBC,OAAO,EAAE,CAAC;EACVC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE;AACV,CAAuB;AAEvB,MAAMC,aAAa,GAAG;E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