react-bkoi-gl 2.0.0 → 2.1.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/LICENSE +21 -0
- package/README.md +1429 -176
- package/dist/index.cjs +1299 -266
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +870 -0
- package/dist/index.d.ts +870 -2
- package/dist/index.js +2420 -2
- package/dist/index.js.map +1 -1
- package/dist/styles/react-bkoi-gl.css +95 -1
- package/package.json +83 -31
- package/dist/components/attribution-control.d.ts +0 -9
- package/dist/components/attribution-control.js +0 -20
- package/dist/components/attribution-control.js.map +0 -1
- package/dist/components/fullscreen-control.d.ts +0 -12
- package/dist/components/fullscreen-control.js +0 -21
- package/dist/components/fullscreen-control.js.map +0 -1
- package/dist/components/geolocate-control.d.ts +0 -21
- package/dist/components/geolocate-control.js +0 -46
- package/dist/components/geolocate-control.js.map +0 -1
- package/dist/components/layer.d.ts +0 -18
- package/dist/components/layer.js +0 -98
- package/dist/components/layer.js.map +0 -1
- package/dist/components/logo-control.d.ts +0 -9
- package/dist/components/logo-control.js +0 -28
- package/dist/components/logo-control.js.map +0 -1
- package/dist/components/map.d.ts +0 -27
- package/dist/components/map.js +0 -108
- package/dist/components/map.js.map +0 -1
- package/dist/components/marker.d.ts +0 -18
- package/dist/components/marker.js +0 -105
- package/dist/components/marker.js.map +0 -1
- package/dist/components/navigation-control.d.ts +0 -9
- package/dist/components/navigation-control.js +0 -19
- package/dist/components/navigation-control.js.map +0 -1
- package/dist/components/popup.d.ts +0 -15
- package/dist/components/popup.js +0 -68
- package/dist/components/popup.js.map +0 -1
- package/dist/components/scale-control.d.ts +0 -11
- package/dist/components/scale-control.js +0 -31
- package/dist/components/scale-control.js.map +0 -1
- package/dist/components/source.d.ts +0 -6
- package/dist/components/source.js +0 -95
- package/dist/components/source.js.map +0 -1
- package/dist/components/terrain-control.d.ts +0 -10
- package/dist/components/terrain-control.js +0 -19
- package/dist/components/terrain-control.js.map +0 -1
- package/dist/components/use-control.d.ts +0 -9
- package/dist/components/use-control.js +0 -30
- package/dist/components/use-control.js.map +0 -1
- package/dist/components/use-map.d.ts +0 -19
- package/dist/components/use-map.js +0 -54
- package/dist/components/use-map.js.map +0 -1
- package/dist/exports-maplibre-gl.d.ts +0 -33
- package/dist/exports-maplibre-gl.js +0 -21
- package/dist/exports-maplibre-gl.js.map +0 -1
- package/dist/maplibre/create-ref.d.ts +0 -9
- package/dist/maplibre/create-ref.js +0 -30
- package/dist/maplibre/create-ref.js.map +0 -1
- package/dist/maplibre/maplibre.d.ts +0 -81
- package/dist/maplibre/maplibre.js +0 -387
- package/dist/maplibre/maplibre.js.map +0 -1
- package/dist/styles.d.js +0 -2
- package/dist/styles.d.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/common.d.ts +0 -20
- package/dist/types/common.js +0 -2
- package/dist/types/common.js.map +0 -1
- package/dist/types/events.d.ts +0 -80
- package/dist/types/events.js +0 -2
- package/dist/types/events.js.map +0 -1
- package/dist/types/internal.d.ts +0 -14
- package/dist/types/internal.js +0 -2
- package/dist/types/internal.js.map +0 -1
- package/dist/types/lib.d.ts +0 -40
- package/dist/types/lib.js +0 -2
- package/dist/types/lib.js.map +0 -1
- package/dist/types/style-spec.d.ts +0 -1
- package/dist/types/style-spec.js +0 -2
- package/dist/types/style-spec.js.map +0 -1
- package/dist/utils/apply-react-style.d.ts +0 -2
- package/dist/utils/apply-react-style.js +0 -16
- package/dist/utils/apply-react-style.js.map +0 -1
- package/dist/utils/assert.d.ts +0 -1
- package/dist/utils/assert.js +0 -6
- package/dist/utils/assert.js.map +0 -1
- package/dist/utils/compare-class-names.d.ts +0 -2
- package/dist/utils/compare-class-names.js +0 -23
- package/dist/utils/compare-class-names.js.map +0 -1
- package/dist/utils/deep-equal.d.ts +0 -15
- package/dist/utils/deep-equal.js +0 -46
- package/dist/utils/deep-equal.js.map +0 -1
- package/dist/utils/set-globals.d.ts +0 -20
- package/dist/utils/set-globals.js +0 -31
- package/dist/utils/set-globals.js.map +0 -1
- package/dist/utils/style-utils.d.ts +0 -3
- package/dist/utils/style-utils.js +0 -42
- package/dist/utils/style-utils.js.map +0 -1
- package/dist/utils/transform.d.ts +0 -18
- package/dist/utils/transform.js +0 -33
- package/dist/utils/transform.js.map +0 -1
- package/dist/utils/use-isomorphic-layout-effect.d.ts +0 -3
- package/dist/utils/use-isomorphic-layout-effect.js +0 -4
- package/dist/utils/use-isomorphic-layout-effect.js.map +0 -1
- package/src/components/attribution-control.ts +0 -56
- package/src/components/fullscreen-control.ts +0 -40
- package/src/components/geolocate-control.ts +0 -96
- package/src/components/layer.ts +0 -141
- package/src/components/logo-control.ts +0 -44
- package/src/components/map.tsx +0 -166
- package/src/components/marker.ts +0 -155
- package/src/components/navigation-control.ts +0 -28
- package/src/components/popup.ts +0 -113
- package/src/components/scale-control.ts +0 -44
- package/src/components/source.ts +0 -159
- package/src/components/terrain-control.ts +0 -29
- package/src/components/use-control.ts +0 -68
- package/src/components/use-map.tsx +0 -71
- package/src/exports-maplibre-gl.ts +0 -37
- package/src/index.ts +0 -3
- package/src/maplibre/create-ref.ts +0 -70
- package/src/maplibre/maplibre.ts +0 -624
- package/src/styles.d.ts +0 -4
- package/src/types/common.ts +0 -34
- package/src/types/events.ts +0 -133
- package/src/types/internal.ts +0 -26
- package/src/types/lib.ts +0 -84
- package/src/types/style-spec.ts +0 -34
- package/src/utils/apply-react-style.ts +0 -24
- package/src/utils/assert.ts +0 -5
- package/src/utils/compare-class-names.ts +0 -29
- package/src/utils/deep-equal.ts +0 -61
- package/src/utils/set-globals.ts +0 -51
- package/src/utils/style-utils.ts +0 -68
- package/src/utils/transform.ts +0 -58
- package/src/utils/use-isomorphic-layout-effect.ts +0 -8
package/dist/types/lib.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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";
|
|
3
|
-
/**
|
|
4
|
-
* A user-facing type that represents the minimal intersection between Mapbox and Maplibre
|
|
5
|
-
* User provided `mapLib` is supposed to implement this interface
|
|
6
|
-
* Only losely typed for compatibility
|
|
7
|
-
*/
|
|
8
|
-
export interface MapLib {
|
|
9
|
-
supported?: (options: any) => boolean;
|
|
10
|
-
Map: {
|
|
11
|
-
new (options: MapOptions): Map;
|
|
12
|
-
};
|
|
13
|
-
Marker: {
|
|
14
|
-
new (options: MarkerOptions): Marker;
|
|
15
|
-
};
|
|
16
|
-
Popup: {
|
|
17
|
-
new (options: PopupOptions): Popup;
|
|
18
|
-
};
|
|
19
|
-
AttributionControl: {
|
|
20
|
-
new (options: AttributionControlOptions): AttributionControl;
|
|
21
|
-
};
|
|
22
|
-
FullscreenControl: {
|
|
23
|
-
new (options: FullscreenControlOptions): FullscreenControl;
|
|
24
|
-
};
|
|
25
|
-
GeolocateControl: {
|
|
26
|
-
new (options: GeolocateControlOptions): GeolocateControl;
|
|
27
|
-
};
|
|
28
|
-
NavigationControl: {
|
|
29
|
-
new (options: NavigationControlOptions): NavigationControl;
|
|
30
|
-
};
|
|
31
|
-
ScaleControl: {
|
|
32
|
-
new (options: ScaleControlOptions): ScaleControl;
|
|
33
|
-
};
|
|
34
|
-
TerrainControl: {
|
|
35
|
-
new (options: TerrainSpecification): TerrainControl;
|
|
36
|
-
};
|
|
37
|
-
LogoControl: {
|
|
38
|
-
new (options: LogoControlOptions): LogoControl;
|
|
39
|
-
};
|
|
40
|
-
}
|
package/dist/types/lib.js
DELETED
package/dist/types/lib.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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";
|
package/dist/types/style-spec.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,16 +0,0 @@
|
|
|
1
|
-
const unitlessNumber = /box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;
|
|
2
|
-
export function applyReactStyle(element, styles) {
|
|
3
|
-
if (!element || !styles) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
const style = element.style;
|
|
7
|
-
for (const key in styles) {
|
|
8
|
-
const value = styles[key];
|
|
9
|
-
if (Number.isFinite(value) && !unitlessNumber.test(key)) {
|
|
10
|
-
style[key] = `${value}px`;
|
|
11
|
-
} else {
|
|
12
|
-
style[key] = value;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=apply-react-style.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
package/dist/utils/assert.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function assert(condition: any, message: string): void;
|
package/dist/utils/assert.js
DELETED
package/dist/utils/assert.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","names":["assert","condition","message","Error"],"sources":["../../src/utils/assert.ts"],"sourcesContent":["export default function assert(condition: any, message: string) {\n if (!condition) {\n throw new Error(message);\n }\n}\n"],"mappings":"AAAA,eAAe,SAASA,MAAMA,CAACC,SAAc,EAAEC,OAAe,EAAE;EAC9D,IAAI,CAACD,SAAS,EAAE;IACd,MAAM,IAAIE,KAAK,CAACD,OAAO,CAAC;EAC1B;AACF","ignoreList":[]}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { PointLike } from "../types/common";
|
|
2
|
-
/**
|
|
3
|
-
* Compare two points
|
|
4
|
-
* @param a
|
|
5
|
-
* @param b
|
|
6
|
-
* @returns true if the points are equal
|
|
7
|
-
*/
|
|
8
|
-
export declare function arePointsEqual(a?: PointLike, b?: PointLike): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Compare any two objects
|
|
11
|
-
* @param a
|
|
12
|
-
* @param b
|
|
13
|
-
* @returns true if the objects are deep equal
|
|
14
|
-
*/
|
|
15
|
-
export declare function deepEqual(a: any, b: any): boolean;
|
package/dist/utils/deep-equal.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export function arePointsEqual(a, b) {
|
|
2
|
-
const ax = Array.isArray(a) ? a[0] : a ? a.x : 0;
|
|
3
|
-
const ay = Array.isArray(a) ? a[1] : a ? a.y : 0;
|
|
4
|
-
const bx = Array.isArray(b) ? b[0] : b ? b.x : 0;
|
|
5
|
-
const by = Array.isArray(b) ? b[1] : b ? b.y : 0;
|
|
6
|
-
return ax === bx && ay === by;
|
|
7
|
-
}
|
|
8
|
-
export function deepEqual(a, b) {
|
|
9
|
-
if (a === b) {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
if (!a || !b) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
if (Array.isArray(a)) {
|
|
16
|
-
if (!Array.isArray(b) || a.length !== b.length) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
for (let i = 0; i < a.length; i++) {
|
|
20
|
-
if (!deepEqual(a[i], b[i])) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
} else if (Array.isArray(b)) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
if (typeof a === "object" && typeof b === "object") {
|
|
29
|
-
const aKeys = Object.keys(a);
|
|
30
|
-
const bKeys = Object.keys(b);
|
|
31
|
-
if (aKeys.length !== bKeys.length) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
for (const key of aKeys) {
|
|
35
|
-
if (!b.hasOwnProperty(key)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
if (!deepEqual(a[key], b[key])) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=deep-equal.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
export type GlobalSettings = {
|
|
2
|
-
/** The maximum number of images (raster tiles, sprites, icons) to load in parallel.
|
|
3
|
-
* @default 16
|
|
4
|
-
*/
|
|
5
|
-
maxParallelImageRequests?: number;
|
|
6
|
-
/** The map's RTL text plugin. Necessary for supporting the Arabic and Hebrew languages, which are written right-to-left. */
|
|
7
|
-
RTLTextPlugin?: string | {
|
|
8
|
-
pluginUrl: string;
|
|
9
|
-
lazy?: boolean;
|
|
10
|
-
};
|
|
11
|
-
/** The number of web workers instantiated on a page with maplibre-gl maps.
|
|
12
|
-
* @default 2
|
|
13
|
-
*/
|
|
14
|
-
workerCount?: number;
|
|
15
|
-
/** Provides an interface for loading maplibre-gl's WebWorker bundle from a self-hosted URL.
|
|
16
|
-
* This is useful if your site needs to operate in a strict CSP (Content Security Policy) environment
|
|
17
|
-
* wherein you are not allowed to load JavaScript code from a Blob URL, which is default behavior. */
|
|
18
|
-
workerUrl?: string;
|
|
19
|
-
};
|
|
20
|
-
export default function setGlobals(mapLib: any, props: GlobalSettings): void;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export default function setGlobals(mapLib, props) {
|
|
2
|
-
const {
|
|
3
|
-
RTLTextPlugin,
|
|
4
|
-
maxParallelImageRequests,
|
|
5
|
-
workerCount,
|
|
6
|
-
workerUrl
|
|
7
|
-
} = props;
|
|
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 => {
|
|
16
|
-
if (error) {
|
|
17
|
-
console.error(error);
|
|
18
|
-
}
|
|
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);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=set-globals.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,42 +0,0 @@
|
|
|
1
|
-
const refProps = ["type", "source", "source-layer", "minzoom", "maxzoom", "filter", "layout"];
|
|
2
|
-
export function normalizeStyle(style) {
|
|
3
|
-
if (!style) {
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
6
|
-
if (typeof style === "string") {
|
|
7
|
-
return style;
|
|
8
|
-
}
|
|
9
|
-
if ("toJS" in style) {
|
|
10
|
-
style = style.toJS();
|
|
11
|
-
}
|
|
12
|
-
if (!style.layers) {
|
|
13
|
-
return style;
|
|
14
|
-
}
|
|
15
|
-
const layerIndex = {};
|
|
16
|
-
for (const layer of style.layers) {
|
|
17
|
-
layerIndex[layer.id] = layer;
|
|
18
|
-
}
|
|
19
|
-
const layers = style.layers.map(layer => {
|
|
20
|
-
let normalizedLayer = null;
|
|
21
|
-
if ("interactive" in layer) {
|
|
22
|
-
normalizedLayer = Object.assign({}, layer);
|
|
23
|
-
delete normalizedLayer.interactive;
|
|
24
|
-
}
|
|
25
|
-
const layerRef = layerIndex[layer.ref];
|
|
26
|
-
if (layerRef) {
|
|
27
|
-
normalizedLayer = normalizedLayer || Object.assign({}, layer);
|
|
28
|
-
delete normalizedLayer.ref;
|
|
29
|
-
for (const propName of refProps) {
|
|
30
|
-
if (propName in layerRef) {
|
|
31
|
-
normalizedLayer[propName] = layerRef[propName];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return normalizedLayer || layer;
|
|
36
|
-
});
|
|
37
|
-
return {
|
|
38
|
-
...style,
|
|
39
|
-
layers
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=style-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,18 +0,0 @@
|
|
|
1
|
-
import type { MaplibreProps } from "../maplibre/maplibre";
|
|
2
|
-
import type { ViewState } from "../types/common";
|
|
3
|
-
import type { TransformLike } from "../types/internal";
|
|
4
|
-
/**
|
|
5
|
-
* Capture a transform's current state
|
|
6
|
-
* @param transform
|
|
7
|
-
* @returns descriptor of the view state
|
|
8
|
-
*/
|
|
9
|
-
export declare function transformToViewState(tr: TransformLike): ViewState;
|
|
10
|
-
/**
|
|
11
|
-
* Applies requested view state to a transform
|
|
12
|
-
* @returns an object containing detected changes
|
|
13
|
-
*/
|
|
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
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { deepEqual } from "./deep-equal.js";
|
|
2
|
-
export function transformToViewState(tr) {
|
|
3
|
-
return {
|
|
4
|
-
longitude: tr.center.lng,
|
|
5
|
-
latitude: tr.center.lat,
|
|
6
|
-
zoom: tr.zoom,
|
|
7
|
-
pitch: tr.pitch,
|
|
8
|
-
bearing: tr.bearing,
|
|
9
|
-
padding: tr.padding
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export function applyViewStateToTransform(tr, props) {
|
|
13
|
-
const v = props.viewState || props;
|
|
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);
|
|
18
|
-
}
|
|
19
|
-
if ("zoom" in v && v.zoom !== tr.zoom) {
|
|
20
|
-
changes.zoom = v.zoom;
|
|
21
|
-
}
|
|
22
|
-
if ("bearing" in v && v.bearing !== tr.bearing) {
|
|
23
|
-
changes.bearing = v.bearing;
|
|
24
|
-
}
|
|
25
|
-
if ("pitch" in v && v.pitch !== tr.pitch) {
|
|
26
|
-
changes.pitch = v.pitch;
|
|
27
|
-
}
|
|
28
|
-
if (v.padding && tr.padding && !deepEqual(v.padding, tr.padding)) {
|
|
29
|
-
changes.padding = v.padding;
|
|
30
|
-
}
|
|
31
|
-
return changes;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","names":["deepEqual","transformToViewState","tr","longitude","center","lng","latitude","lat","zoom","pitch","bearing","padding","applyViewStateToTransform","props","v","viewState","changes","LngLat","constructor"],"sources":["../../src/utils/transform.ts"],"sourcesContent":["import type { MaplibreProps } from \"../maplibre/maplibre\";\nimport type { ViewState } from \"../types/common\";\nimport type { TransformLike } from \"../types/internal\";\nimport { deepEqual } from \"./deep-equal\";\n\n/**\n * Capture a transform's current state\n * @param transform\n * @returns descriptor of the view state\n */\nexport function transformToViewState(tr: TransformLike): ViewState {\n return {\n longitude: tr.center.lng,\n latitude: tr.center.lat,\n zoom: tr.zoom,\n pitch: tr.pitch,\n bearing: tr.bearing,\n padding: tr.padding,\n };\n}\n\n/* eslint-disable complexity */\n/**\n * Applies requested view state to a transform\n * @returns an object containing detected changes\n */\nexport function applyViewStateToTransform(\n /** An object that describes Maplibre's camera state */\n tr: TransformLike,\n /** Props from Map component */\n props: MaplibreProps,\n): Partial<TransformLike> {\n const v: Partial<ViewState> = props.viewState || props;\n const changes: Partial<TransformLike> = {};\n\n if (\n \"longitude\" in v &&\n \"latitude\" in v &&\n (v.longitude !== tr.center.lng || v.latitude !== tr.center.lat)\n ) {\n const LngLat = tr.center.constructor;\n // @ts-expect-error we should not import LngLat class from maplibre-gl because we don't know the source of mapLib\n changes.center = new LngLat(v.longitude, v.latitude);\n }\n if (\"zoom\" in v && v.zoom !== tr.zoom) {\n changes.zoom = v.zoom;\n }\n if (\"bearing\" in v && v.bearing !== tr.bearing) {\n changes.bearing = v.bearing;\n }\n if (\"pitch\" in v && v.pitch !== tr.pitch) {\n changes.pitch = v.pitch;\n }\n if (v.padding && tr.padding && !deepEqual(v.padding, tr.padding)) {\n changes.padding = v.padding;\n }\n return changes;\n}\n"],"mappings":"SAGSA,SAAS;AAOlB,OAAO,SAASC,oBAAoBA,CAACC,EAAiB,EAAa;EACjE,OAAO;IACLC,SAAS,EAAED,EAAE,CAACE,MAAM,CAACC,GAAG;IACxBC,QAAQ,EAAEJ,EAAE,CAACE,MAAM,CAACG,GAAG;IACvBC,IAAI,EAAEN,EAAE,CAACM,IAAI;IACbC,KAAK,EAAEP,EAAE,CAACO,KAAK;IACfC,OAAO,EAAER,EAAE,CAACQ,OAAO;IACnBC,OAAO,EAAET,EAAE,CAACS;EACd,CAAC;AACH;AAOA,OAAO,SAASC,yBAAyBA,CAEvCV,EAAiB,EAEjBW,KAAoB,EACI;EACxB,MAAMC,CAAqB,GAAGD,KAAK,CAACE,SAAS,IAAIF,KAAK;EACtD,MAAMG,OAA+B,GAAG,CAAC,CAAC;EAE1C,IACE,WAAW,IAAIF,CAAC,IAChB,UAAU,IAAIA,CAAC,KACdA,CAAC,CAACX,SAAS,KAAKD,EAAE,CAACE,MAAM,CAACC,GAAG,IAAIS,CAAC,CAACR,QAAQ,KAAKJ,EAAE,CAACE,MAAM,CAACG,GAAG,CAAC,EAC/D;IACA,MAAMU,MAAM,GAAGf,EAAE,CAACE,MAAM,CAACc,WAAW;IAEpCF,OAAO,CAACZ,MAAM,GAAG,IAAIa,MAAM,CAACH,CAAC,CAACX,SAAS,EAAEW,CAAC,CAACR,QAAQ,CAAC;EACtD;EACA,IAAI,MAAM,IAAIQ,CAAC,IAAIA,CAAC,CAACN,IAAI,KAAKN,EAAE,CAACM,IAAI,EAAE;IACrCQ,OAAO,CAACR,IAAI,GAAGM,CAAC,CAACN,IAAI;EACvB;EACA,IAAI,SAAS,IAAIM,CAAC,IAAIA,CAAC,CAACJ,OAAO,KAAKR,EAAE,CAACQ,OAAO,EAAE;IAC9CM,OAAO,CAACN,OAAO,GAAGI,CAAC,CAACJ,OAAO;EAC7B;EACA,IAAI,OAAO,IAAII,CAAC,IAAIA,CAAC,CAACL,KAAK,KAAKP,EAAE,CAACO,KAAK,EAAE;IACxCO,OAAO,CAACP,KAAK,GAAGK,CAAC,CAACL,KAAK;EACzB;EACA,IAAIK,CAAC,CAACH,OAAO,IAAIT,EAAE,CAACS,OAAO,IAAI,CAACX,SAAS,CAACc,CAAC,CAACH,OAAO,EAAET,EAAE,CAACS,OAAO,CAAC,EAAE;IAChEK,OAAO,CAACL,OAAO,GAAGG,CAAC,CAACH,OAAO;EAC7B;EACA,OAAOK,OAAO;AAChB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-isomorphic-layout-effect.js","names":["useEffect","useLayoutEffect","useIsomorphicLayoutEffect","document"],"sources":["../../src/utils/use-isomorphic-layout-effect.ts"],"sourcesContent":["// From https://github.com/streamich/react-use/blob/master/src/useIsomorphicLayoutEffect.ts\n// useLayoutEffect but does not trigger warning in server-side rendering\nimport { useEffect, useLayoutEffect } from \"react\";\n\nconst useIsomorphicLayoutEffect =\n typeof document !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport default useIsomorphicLayoutEffect;\n"],"mappings":"AAEA,SAASA,SAAS,EAAEC,eAAe,QAAQ,OAAO;AAElD,MAAMC,yBAAyB,GAC7B,OAAOC,QAAQ,KAAK,WAAW,GAAGF,eAAe,GAAGD,SAAS;AAE/D,eAAeE,yBAAyB","ignoreList":[]}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-statements */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { useEffect, memo } from "react";
|
|
5
|
-
import { applyReactStyle } from "../utils/apply-react-style";
|
|
6
|
-
import { useControl } from "./use-control";
|
|
7
|
-
|
|
8
|
-
import type { ControlPosition, AttributionControlOptions } from "../types/lib";
|
|
9
|
-
|
|
10
|
-
export type AttributionControlProps = AttributionControlOptions & {
|
|
11
|
-
/** Placement of the control relative to the map. */
|
|
12
|
-
position?: ControlPosition;
|
|
13
|
-
/** CSS style override, applied to the control's container */
|
|
14
|
-
style?: React.CSSProperties;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
function _AttributionControl(props: AttributionControlProps) {
|
|
18
|
-
const ctrl = useControl(
|
|
19
|
-
({ mapLib }) => new mapLib.AttributionControl(props),
|
|
20
|
-
{ position: props.position },
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
applyReactStyle(ctrl._container, props.style);
|
|
25
|
-
|
|
26
|
-
// Ensure the container is available
|
|
27
|
-
if (!ctrl._container) return;
|
|
28
|
-
|
|
29
|
-
// Create and append the custom attribution control
|
|
30
|
-
// const customAttribution = document.createElement('details');
|
|
31
|
-
// customAttribution.className = 'maplibregl-ctrl maplibregl-ctrl-attrib maplibregl-compact maplibregl-compact-show';
|
|
32
|
-
// customAttribution.setAttribute('open', '');
|
|
33
|
-
|
|
34
|
-
// const summary = document.createElement('summary');
|
|
35
|
-
// summary.className = 'maplibregl-ctrl-attrib-button';
|
|
36
|
-
// summary.setAttribute('title', 'Toggle attribution');
|
|
37
|
-
// summary.setAttribute('aria-label', 'Toggle attribution');
|
|
38
|
-
// customAttribution.appendChild(summary);
|
|
39
|
-
|
|
40
|
-
// const innerDiv = document.createElement('div');
|
|
41
|
-
// innerDiv.className = 'maplibregl-ctrl-attrib-inner';
|
|
42
|
-
// innerDiv.innerHTML = `
|
|
43
|
-
// <a href="https://barikoi.com/" target="_blank">© Barikoi</a> |
|
|
44
|
-
// <a href="https://www.openmaptiles.org/" target="_blank">© OpenMapTiles</a> |
|
|
45
|
-
// <a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap contributors</a>
|
|
46
|
-
// `;
|
|
47
|
-
// customAttribution.appendChild(innerDiv);
|
|
48
|
-
|
|
49
|
-
// ctrl._container.appendChild(customAttribution);
|
|
50
|
-
}, [props.style, ctrl._container]);
|
|
51
|
-
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const AttributionControl: React.FC<AttributionControlProps> =
|
|
56
|
-
memo(_AttributionControl);
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/* global document */
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { useEffect, memo } from "react";
|
|
4
|
-
import { applyReactStyle } from "../utils/apply-react-style";
|
|
5
|
-
import { useControl } from "./use-control";
|
|
6
|
-
|
|
7
|
-
import type { ControlPosition, FullscreenControlOptions } from "../types/lib";
|
|
8
|
-
|
|
9
|
-
export type FullscreenControlProps = Omit<
|
|
10
|
-
FullscreenControlOptions,
|
|
11
|
-
"container"
|
|
12
|
-
> & {
|
|
13
|
-
/** Id of the DOM element which should be made full screen. By default, the map container
|
|
14
|
-
* element will be made full screen. */
|
|
15
|
-
containerId?: string;
|
|
16
|
-
/** Placement of the control relative to the map. */
|
|
17
|
-
position?: ControlPosition;
|
|
18
|
-
/** CSS style override, applied to the control's container */
|
|
19
|
-
style?: React.CSSProperties;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function _FullscreenControl(props: FullscreenControlProps) {
|
|
23
|
-
const ctrl = useControl(
|
|
24
|
-
({ mapLib }) =>
|
|
25
|
-
new mapLib.FullscreenControl({
|
|
26
|
-
container:
|
|
27
|
-
props.containerId && document.getElementById(props.containerId),
|
|
28
|
-
}),
|
|
29
|
-
{ position: props.position },
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
applyReactStyle(ctrl._controlContainer, props.style);
|
|
34
|
-
}, [props.style]);
|
|
35
|
-
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const FullscreenControl: React.FC<FullscreenControlProps> =
|
|
40
|
-
memo(_FullscreenControl);
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
useImperativeHandle,
|
|
4
|
-
useRef,
|
|
5
|
-
useEffect,
|
|
6
|
-
forwardRef,
|
|
7
|
-
memo,
|
|
8
|
-
} from "react";
|
|
9
|
-
import { applyReactStyle } from "../utils/apply-react-style";
|
|
10
|
-
import { useControl } from "./use-control";
|
|
11
|
-
|
|
12
|
-
import type {
|
|
13
|
-
ControlPosition,
|
|
14
|
-
GeolocateControl as GeolocateControlInstance,
|
|
15
|
-
GeolocateControlOptions,
|
|
16
|
-
} from "../types/lib";
|
|
17
|
-
import type {
|
|
18
|
-
GeolocateEvent,
|
|
19
|
-
GeolocateResultEvent,
|
|
20
|
-
GeolocateErrorEvent,
|
|
21
|
-
} from "../types/events";
|
|
22
|
-
|
|
23
|
-
export type GeolocateControlProps = GeolocateControlOptions & {
|
|
24
|
-
/** Placement of the control relative to the map. */
|
|
25
|
-
position?: ControlPosition;
|
|
26
|
-
/** CSS style override, applied to the control's container */
|
|
27
|
-
style?: React.CSSProperties;
|
|
28
|
-
|
|
29
|
-
/** Called on each Geolocation API position update that returned as success. */
|
|
30
|
-
onGeolocate?: (e: GeolocateResultEvent) => void;
|
|
31
|
-
/** Called on each Geolocation API position update that returned as an error. */
|
|
32
|
-
onError?: (e: GeolocateErrorEvent) => void;
|
|
33
|
-
/** Called on each Geolocation API position update that returned as success but user position
|
|
34
|
-
* is out of map `maxBounds`. */
|
|
35
|
-
onOutOfMaxBounds?: (e: GeolocateResultEvent) => void;
|
|
36
|
-
/** Called when the GeolocateControl changes to the active lock state. */
|
|
37
|
-
onTrackUserLocationStart?: (e: GeolocateEvent) => void;
|
|
38
|
-
/** Called when the GeolocateControl changes to the background state. */
|
|
39
|
-
onTrackUserLocationEnd?: (e: GeolocateEvent) => void;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function _GeolocateControl(
|
|
43
|
-
props: GeolocateControlProps,
|
|
44
|
-
ref: React.Ref<GeolocateControlInstance>,
|
|
45
|
-
) {
|
|
46
|
-
const thisRef = useRef({ props });
|
|
47
|
-
|
|
48
|
-
const ctrl = useControl(
|
|
49
|
-
({ mapLib }) => {
|
|
50
|
-
const gc = new mapLib.GeolocateControl(props);
|
|
51
|
-
|
|
52
|
-
// Hack: fix GeolocateControl reuse
|
|
53
|
-
// When using React strict mode, the component is mounted twice.
|
|
54
|
-
// GeolocateControl's UI creation is asynchronous. Removing and adding it back causes the UI to be initialized twice.
|
|
55
|
-
const setupUI = gc._setupUI;
|
|
56
|
-
gc._setupUI = () => {
|
|
57
|
-
if (!gc._container.hasChildNodes()) {
|
|
58
|
-
setupUI();
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
gc.on("geolocate", (e) => {
|
|
63
|
-
thisRef.current.props.onGeolocate?.(e as GeolocateResultEvent);
|
|
64
|
-
});
|
|
65
|
-
gc.on("error", (e) => {
|
|
66
|
-
thisRef.current.props.onError?.(e as GeolocateErrorEvent);
|
|
67
|
-
});
|
|
68
|
-
gc.on("outofmaxbounds", (e) => {
|
|
69
|
-
thisRef.current.props.onOutOfMaxBounds?.(e as GeolocateResultEvent);
|
|
70
|
-
});
|
|
71
|
-
gc.on("trackuserlocationstart", (e) => {
|
|
72
|
-
thisRef.current.props.onTrackUserLocationStart?.(e as GeolocateEvent);
|
|
73
|
-
});
|
|
74
|
-
gc.on("trackuserlocationend", (e) => {
|
|
75
|
-
thisRef.current.props.onTrackUserLocationEnd?.(e as GeolocateEvent);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
return gc;
|
|
79
|
-
},
|
|
80
|
-
{ position: props.position },
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
thisRef.current.props = props;
|
|
84
|
-
|
|
85
|
-
useImperativeHandle(ref, () => ctrl, []);
|
|
86
|
-
|
|
87
|
-
useEffect(() => {
|
|
88
|
-
applyReactStyle(ctrl._container, props.style);
|
|
89
|
-
}, [props.style]);
|
|
90
|
-
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const GeolocateControl: React.FC<GeolocateControlProps> = memo(
|
|
95
|
-
forwardRef(_GeolocateControl),
|
|
96
|
-
);
|