react-three-map 0.8.1 → 1.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +41 -24
- package/dist/cjs/main.js +1283 -44
- package/dist/es/main.mjs +2 -1
- package/dist/es/main10.mjs +71 -10
- package/dist/es/main10.mjs.map +1 -1
- package/dist/es/main11.mjs +12 -35
- package/dist/es/main11.mjs.map +1 -1
- package/dist/es/main12.mjs +12 -13
- package/dist/es/main12.mjs.map +1 -1
- package/dist/es/main13.mjs +42 -24
- package/dist/es/main13.mjs.map +1 -1
- package/dist/es/main14.mjs +13 -4
- package/dist/es/main14.mjs.map +1 -1
- package/dist/es/main15.mjs +22 -31
- package/dist/es/main15.mjs.map +1 -1
- package/dist/es/main16.mjs +87 -22
- package/dist/es/main16.mjs.map +1 -1
- package/dist/es/main17.mjs +14 -94
- package/dist/es/main17.mjs.map +1 -1
- package/dist/es/main18.mjs +22 -62
- package/dist/es/main18.mjs.map +1 -1
- package/dist/es/main19.mjs +27 -20
- package/dist/es/main19.mjs.map +1 -1
- package/dist/es/main20.mjs +8 -23
- package/dist/es/main20.mjs.map +1 -1
- package/dist/es/main21.mjs +34 -16
- package/dist/es/main21.mjs.map +1 -1
- package/dist/es/main22.mjs +12 -80
- package/dist/es/main22.mjs.map +1 -1
- package/dist/es/main23.mjs +26 -0
- package/dist/es/main23.mjs.map +1 -0
- package/dist/es/main24.mjs +5 -0
- package/dist/es/main24.mjs.map +1 -0
- package/dist/es/main25.mjs +33 -0
- package/dist/es/main25.mjs.map +1 -0
- package/dist/es/main26.mjs +27 -0
- package/dist/es/main26.mjs.map +1 -0
- package/dist/es/main27.mjs +98 -0
- package/dist/es/main27.mjs.map +1 -0
- package/dist/es/main28.mjs +66 -0
- package/dist/es/main28.mjs.map +1 -0
- package/dist/es/main29.mjs +23 -0
- package/dist/es/main29.mjs.map +1 -0
- package/dist/es/main3.mjs +13 -4
- package/dist/es/main3.mjs.map +1 -1
- package/dist/es/main30.mjs +27 -0
- package/dist/es/main30.mjs.map +1 -0
- package/dist/es/main31.mjs +19 -0
- package/dist/es/main31.mjs.map +1 -0
- package/dist/es/main32.mjs +83 -0
- package/dist/es/main32.mjs.map +1 -0
- package/dist/es/main33.mjs +501 -0
- package/dist/es/main33.mjs.map +1 -0
- package/dist/es/main34.mjs +90 -0
- package/dist/es/main34.mjs.map +1 -0
- package/dist/es/main35.mjs +6 -0
- package/dist/es/main35.mjs.map +1 -0
- package/dist/es/main36.mjs +26 -0
- package/dist/es/main36.mjs.map +1 -0
- package/dist/es/main37.mjs +19 -0
- package/dist/es/main37.mjs.map +1 -0
- package/dist/es/main38.mjs +50 -0
- package/dist/es/main38.mjs.map +1 -0
- package/dist/es/main39.mjs +31 -0
- package/dist/es/main39.mjs.map +1 -0
- package/dist/es/main4.mjs +3 -3
- package/dist/es/main40.mjs +9 -0
- package/dist/es/main40.mjs.map +1 -0
- package/dist/es/main41.mjs +62 -0
- package/dist/es/main41.mjs.map +1 -0
- package/dist/es/main42.mjs +42 -0
- package/dist/es/main42.mjs.map +1 -0
- package/dist/es/main5.mjs +22 -2
- package/dist/es/main5.mjs.map +1 -1
- package/dist/es/main6.mjs +1 -1
- package/dist/es/main7.mjs +1 -1
- package/dist/es/main8.mjs +87 -20
- package/dist/es/main8.mjs.map +1 -1
- package/dist/es/main9.mjs +80 -24
- package/dist/es/main9.mjs.map +1 -1
- package/dist/maplibre/cjs/main.js +30 -9
- package/dist/maplibre/es/main.mjs +2 -1
- package/dist/maplibre/es/main.mjs.map +1 -1
- package/dist/maplibre/es/main14.mjs +1 -1
- package/dist/maplibre/es/main14.mjs.map +1 -1
- package/dist/maplibre/es/main16.mjs +2 -1
- package/dist/maplibre/es/main16.mjs.map +1 -1
- package/dist/maplibre/es/main3.mjs +2 -2
- package/dist/maplibre/es/main3.mjs.map +1 -1
- package/dist/maplibre/es/main5.mjs +21 -1
- package/dist/maplibre/es/main5.mjs.map +1 -1
- package/dist/maplibre/types/api/coords-to-vector-3.d.ts +1 -0
- package/dist/maplibre/types/core/canvas-in-layer/use-canvas-in-layer.d.ts +5 -1
- package/dist/maplibre/types/core/canvas-in-layer/use-render.d.ts +5 -1
- package/dist/maplibre/types/core/earth-radius.d.ts +1 -1
- package/dist/maplibre/types/core/generic-map.d.ts +2 -2
- package/dist/maplibre/types/{mapbox → maplibre}/canvas.d.ts +1 -1
- package/dist/maplibre/types/maplibre.index.d.ts +1 -1
- package/dist/types/api/coords-to-vector-3.d.ts +1 -0
- package/dist/types/core/canvas-in-layer/use-canvas-in-layer.d.ts +5 -1
- package/dist/types/core/canvas-in-layer/use-render.d.ts +5 -1
- package/dist/types/core/earth-radius.d.ts +1 -1
- package/dist/types/core/generic-map.d.ts +2 -2
- package/dist/types/mapbox/canvas.d.ts +1 -1
- package/made-with/studio-carto-urban-project.webp +0 -0
- package/package.json +7 -7
- package/stories/package.json +4 -4
- package/stories/yarn.lock +175 -98
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const globalSettings = [
|
|
2
|
+
"baseApiUrl",
|
|
3
|
+
"maxParallelImageRequests",
|
|
4
|
+
"workerClass",
|
|
5
|
+
"workerCount",
|
|
6
|
+
"workerUrl"
|
|
7
|
+
];
|
|
8
|
+
function setGlobals(mapLib, props) {
|
|
9
|
+
for (const key of globalSettings) {
|
|
10
|
+
if (key in props) {
|
|
11
|
+
mapLib[key] = props[key];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const { RTLTextPlugin = "https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js" } = props;
|
|
15
|
+
if (RTLTextPlugin && mapLib.getRTLTextPluginStatus && mapLib.getRTLTextPluginStatus() === "unavailable") {
|
|
16
|
+
mapLib.setRTLTextPlugin(RTLTextPlugin, (error) => {
|
|
17
|
+
if (error) {
|
|
18
|
+
console.error(error);
|
|
19
|
+
}
|
|
20
|
+
}, true);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
setGlobals as default
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=main36.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main36.mjs","sources":["../../node_modules/@vis.gl/react-mapbox/dist/utils/set-globals.js"],"sourcesContent":["const globalSettings = [\n 'baseApiUrl',\n 'maxParallelImageRequests',\n 'workerClass',\n 'workerCount',\n 'workerUrl'\n];\nexport default function setGlobals(mapLib, props) {\n for (const key of globalSettings) {\n if (key in props) {\n mapLib[key] = props[key];\n }\n }\n const { RTLTextPlugin = 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js' } = props;\n if (RTLTextPlugin &&\n mapLib.getRTLTextPluginStatus &&\n mapLib.getRTLTextPluginStatus() === 'unavailable') {\n mapLib.setRTLTextPlugin(RTLTextPlugin, (error) => {\n if (error) {\n // eslint-disable-next-line\n console.error(error);\n }\n }, true);\n }\n}\n//# sourceMappingURL=set-globals.js.map"],"names":[],"mappings":"AAAA,MAAM,iBAAiB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AACe,SAAS,WAAW,QAAQ,OAAO;AAC9C,aAAW,OAAO,gBAAgB;AAC9B,QAAI,OAAO,OAAO;AACd,aAAO,GAAG,IAAI,MAAM,GAAG;AAAA,IAC1B;AAAA,EACJ;AACD,QAAM,EAAE,gBAAgB,8FAA+F,IAAG;AAC1H,MAAI,iBACA,OAAO,0BACP,OAAO,uBAAwB,MAAK,eAAe;AACnD,WAAO,iBAAiB,eAAe,CAAC,UAAU;AAC9C,UAAI,OAAO;AAEP,gBAAQ,MAAM,KAAK;AAAA,MACtB;AAAA,IACJ,GAAE,IAAI;AAAA,EACV;AACL;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const unitlessNumber = /box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;
|
|
2
|
+
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
|
+
export {
|
|
17
|
+
applyReactStyle
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=main37.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main37.mjs","sources":["../../node_modules/@vis.gl/react-mapbox/dist/utils/apply-react-style.js"],"sourcesContent":["// This is a simplified version of\n// https://github.com/facebook/react/blob/4131af3e4bf52f3a003537ec95a1655147c81270/src/renderers/dom/shared/CSSPropertyOperations.js#L62\nconst unitlessNumber = /box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;\nexport function applyReactStyle(element, styles) {\n if (!element || !styles) {\n return;\n }\n const style = element.style;\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 }\n else {\n style[key] = value;\n }\n }\n}\n//# sourceMappingURL=apply-react-style.js.map"],"names":[],"mappings":"AAEA,MAAM,iBAAiB;AAChB,SAAS,gBAAgB,SAAS,QAAQ;AAC7C,MAAI,CAAC,WAAW,CAAC,QAAQ;AACrB;AAAA,EACH;AACD,QAAM,QAAQ,QAAQ;AACtB,aAAW,OAAO,QAAQ;AACtB,UAAM,QAAQ,OAAO,GAAG;AACxB,QAAI,OAAO,SAAS,KAAK,KAAK,CAAC,eAAe,KAAK,GAAG,GAAG;AACrD,YAAM,GAAG,IAAI,GAAG,KAAK;AAAA,IACxB,OACI;AACD,YAAM,GAAG,IAAI;AAAA,IAChB;AAAA,EACJ;AACL;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
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
|
+
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
|
+
export {
|
|
47
|
+
arePointsEqual,
|
|
48
|
+
deepEqual
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=main38.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main38.mjs","sources":["../../node_modules/@vis.gl/react-mapbox/dist/utils/deep-equal.js"],"sourcesContent":["/**\n * Compare two points\n * @param a\n * @param b\n * @returns true if the points are equal\n */\nexport function arePointsEqual(a, b) {\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/* 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, b) {\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 }\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//# sourceMappingURL=deep-equal.js.map"],"names":[],"mappings":"AAMO,SAAS,eAAe,GAAG,GAAG;AACjC,QAAM,KAAK,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,IAAI;AAC/C,QAAM,KAAK,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,IAAI;AAC/C,QAAM,KAAK,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,IAAI;AAC/C,QAAM,KAAK,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,IAAI,EAAE,IAAI;AAC/C,SAAO,OAAO,MAAM,OAAO;AAC/B;AAQO,SAAS,UAAU,GAAG,GAAG;AAC5B,MAAI,MAAM,GAAG;AACT,WAAO;AAAA,EACV;AACD,MAAI,CAAC,KAAK,CAAC,GAAG;AACV,WAAO;AAAA,EACV;AACD,MAAI,MAAM,QAAQ,CAAC,GAAG;AAClB,QAAI,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ;AAC5C,aAAO;AAAA,IACV;AACD,aAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AAC/B,UAAI,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG;AACxB,eAAO;AAAA,MACV;AAAA,IACJ;AACD,WAAO;AAAA,EACV,WACQ,MAAM,QAAQ,CAAC,GAAG;AACvB,WAAO;AAAA,EACV;AACD,MAAI,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU;AAChD,UAAM,QAAQ,OAAO,KAAK,CAAC;AAC3B,UAAM,QAAQ,OAAO,KAAK,CAAC;AAC3B,QAAI,MAAM,WAAW,MAAM,QAAQ;AAC/B,aAAO;AAAA,IACV;AACD,eAAW,OAAO,OAAO;AACrB,UAAI,CAAC,EAAE,eAAe,GAAG,GAAG;AACxB,eAAO;AAAA,MACV;AACD,UAAI,CAAC,UAAU,EAAE,GAAG,GAAG,EAAE,GAAG,CAAC,GAAG;AAC5B,eAAO;AAAA,MACV;AAAA,IACJ;AACD,WAAO;AAAA,EACV;AACD,SAAO;AACX;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useContext, useMemo, useEffect } from "react";
|
|
2
|
+
import { MapContext } from "./main8.mjs";
|
|
3
|
+
function useControl(onCreate, arg1, arg2, arg3) {
|
|
4
|
+
const context = useContext(MapContext);
|
|
5
|
+
const ctrl = useMemo(() => onCreate(context), []);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const opts = arg3 || arg2 || arg1;
|
|
8
|
+
const onAdd = typeof arg1 === "function" && typeof arg2 === "function" ? arg1 : null;
|
|
9
|
+
const onRemove = typeof arg2 === "function" ? arg2 : typeof arg1 === "function" ? arg1 : null;
|
|
10
|
+
const { map } = context;
|
|
11
|
+
if (!map.hasControl(ctrl)) {
|
|
12
|
+
map.addControl(ctrl, opts == null ? void 0 : opts.position);
|
|
13
|
+
if (onAdd) {
|
|
14
|
+
onAdd(context);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return () => {
|
|
18
|
+
if (onRemove) {
|
|
19
|
+
onRemove(context);
|
|
20
|
+
}
|
|
21
|
+
if (map.hasControl(ctrl)) {
|
|
22
|
+
map.removeControl(ctrl);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}, []);
|
|
26
|
+
return ctrl;
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
useControl
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=main39.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main39.mjs","sources":["../../node_modules/@vis.gl/react-mapbox/dist/components/use-control.js"],"sourcesContent":["import { useContext, useMemo, useEffect } from 'react';\nimport { MapContext } from \"./map.js\";\nexport function useControl(onCreate, arg1, arg2, arg3) {\n const context = useContext(MapContext);\n const ctrl = useMemo(() => onCreate(context), []);\n useEffect(() => {\n const opts = (arg3 || arg2 || arg1);\n const onAdd = typeof arg1 === 'function' && typeof arg2 === 'function' ? arg1 : null;\n const onRemove = typeof arg2 === 'function' ? arg2 : typeof arg1 === 'function' ? arg1 : null;\n const { map } = context;\n if (!map.hasControl(ctrl)) {\n map.addControl(ctrl, opts?.position);\n if (onAdd) {\n onAdd(context);\n }\n }\n return () => {\n if (onRemove) {\n onRemove(context);\n }\n // Map might have been removed (parent effects are destroyed before child ones)\n if (map.hasControl(ctrl)) {\n map.removeControl(ctrl);\n }\n };\n }, []);\n return ctrl;\n}\n//# sourceMappingURL=use-control.js.map"],"names":[],"mappings":";;AAEO,SAAS,WAAW,UAAU,MAAM,MAAM,MAAM;AACnD,QAAM,UAAU,WAAW,UAAU;AACrC,QAAM,OAAO,QAAQ,MAAM,SAAS,OAAO,GAAG,CAAA,CAAE;AAChD,YAAU,MAAM;AACZ,UAAM,OAAQ,QAAQ,QAAQ;AAC9B,UAAM,QAAQ,OAAO,SAAS,cAAc,OAAO,SAAS,aAAa,OAAO;AAChF,UAAM,WAAW,OAAO,SAAS,aAAa,OAAO,OAAO,SAAS,aAAa,OAAO;AACzF,UAAM,EAAE,IAAK,IAAG;AAChB,QAAI,CAAC,IAAI,WAAW,IAAI,GAAG;AACvB,UAAI,WAAW,MAAM,6BAAM,QAAQ;AACnC,UAAI,OAAO;AACP,cAAM,OAAO;AAAA,MAChB;AAAA,IACJ;AACD,WAAO,MAAM;AACT,UAAI,UAAU;AACV,iBAAS,OAAO;AAAA,MACnB;AAED,UAAI,IAAI,WAAW,IAAI,GAAG;AACtB,YAAI,cAAc,IAAI;AAAA,MACzB;AAAA,IACb;AAAA,EACK,GAAE,CAAE,CAAA;AACL,SAAO;AACX;","x_google_ignoreList":[0]}
|
package/dist/es/main4.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { createPortal, useThree, useFrame } from "@react-three/fiber";
|
|
3
3
|
import { memo, useState, useRef, useLayoutEffect } from "react";
|
|
4
4
|
import { Scene } from "three";
|
|
5
|
-
import { syncCamera } from "./
|
|
6
|
-
import { useCoordsToMatrix } from "./
|
|
7
|
-
import { useR3M } from "./
|
|
5
|
+
import { syncCamera } from "./main21.mjs";
|
|
6
|
+
import { useCoordsToMatrix } from "./main22.mjs";
|
|
7
|
+
import { useR3M } from "./main23.mjs";
|
|
8
8
|
const Coordinates = memo(({
|
|
9
9
|
latitude,
|
|
10
10
|
longitude,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main40.mjs","sources":["../../node_modules/@vis.gl/react-mapbox/dist/utils/assert.js"],"sourcesContent":["export default function assert(condition, message) {\n if (!condition) {\n throw new Error(message);\n }\n}\n//# sourceMappingURL=assert.js.map"],"names":[],"mappings":"AAAe,SAAS,OAAO,WAAW,SAAS;AAC/C,MAAI,CAAC,WAAW;AACZ,UAAM,IAAI,MAAM,OAAO;AAAA,EAC1B;AACL;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { deepEqual } from "./main38.mjs";
|
|
2
|
+
function cloneTransform(tr) {
|
|
3
|
+
const newTransform = tr.clone();
|
|
4
|
+
newTransform.pixelsToGLUnits = tr.pixelsToGLUnits;
|
|
5
|
+
return newTransform;
|
|
6
|
+
}
|
|
7
|
+
function syncProjection(src, dest) {
|
|
8
|
+
if (!src.getProjection) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const srcProjection = src.getProjection();
|
|
12
|
+
const destProjection = dest.getProjection();
|
|
13
|
+
if (!deepEqual(srcProjection, destProjection)) {
|
|
14
|
+
dest.setProjection(srcProjection);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function transformToViewState(tr) {
|
|
18
|
+
return {
|
|
19
|
+
longitude: tr.center.lng,
|
|
20
|
+
latitude: tr.center.lat,
|
|
21
|
+
zoom: tr.zoom,
|
|
22
|
+
pitch: tr.pitch,
|
|
23
|
+
bearing: tr.bearing,
|
|
24
|
+
padding: tr.padding
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function applyViewStateToTransform(tr, props) {
|
|
28
|
+
const v = props.viewState || props;
|
|
29
|
+
let changed = false;
|
|
30
|
+
if ("zoom" in v) {
|
|
31
|
+
const zoom = tr.zoom;
|
|
32
|
+
tr.zoom = v.zoom;
|
|
33
|
+
changed = changed || zoom !== tr.zoom;
|
|
34
|
+
}
|
|
35
|
+
if ("bearing" in v) {
|
|
36
|
+
const bearing = tr.bearing;
|
|
37
|
+
tr.bearing = v.bearing;
|
|
38
|
+
changed = changed || bearing !== tr.bearing;
|
|
39
|
+
}
|
|
40
|
+
if ("pitch" in v) {
|
|
41
|
+
const pitch = tr.pitch;
|
|
42
|
+
tr.pitch = v.pitch;
|
|
43
|
+
changed = changed || pitch !== tr.pitch;
|
|
44
|
+
}
|
|
45
|
+
if (v.padding && !tr.isPaddingEqual(v.padding)) {
|
|
46
|
+
changed = true;
|
|
47
|
+
tr.padding = v.padding;
|
|
48
|
+
}
|
|
49
|
+
if ("longitude" in v && "latitude" in v) {
|
|
50
|
+
const center = tr.center;
|
|
51
|
+
tr.center = new center.constructor(v.longitude, v.latitude);
|
|
52
|
+
changed = changed || center !== tr.center;
|
|
53
|
+
}
|
|
54
|
+
return changed;
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
applyViewStateToTransform,
|
|
58
|
+
cloneTransform,
|
|
59
|
+
syncProjection,
|
|
60
|
+
transformToViewState
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=main41.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main41.mjs","sources":["../../node_modules/@vis.gl/react-mapbox/dist/utils/transform.js"],"sourcesContent":["import { deepEqual } from \"./deep-equal.js\";\n/**\n * Make a copy of a transform\n * @param tr\n */\nexport function cloneTransform(tr) {\n const newTransform = tr.clone();\n // Work around mapbox bug - this value is not assigned in clone(), only in resize()\n newTransform.pixelsToGLUnits = tr.pixelsToGLUnits;\n return newTransform;\n}\n/**\n * Copy projection from one transform to another. This only applies to mapbox-gl transforms\n * @param src the transform to copy projection settings from\n * @param dest to transform to copy projection settings to\n */\nexport function syncProjection(src, dest) {\n if (!src.getProjection) {\n return;\n }\n const srcProjection = src.getProjection();\n const destProjection = dest.getProjection();\n if (!deepEqual(srcProjection, destProjection)) {\n dest.setProjection(srcProjection);\n }\n}\n/**\n * Capture a transform's current state\n * @param transform\n * @returns descriptor of the view state\n */\nexport function transformToViewState(tr) {\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/* eslint-disable complexity */\n/**\n * Mutate a transform to match the given view state\n * @param transform\n * @param viewState\n * @returns true if the transform has changed\n */\nexport function applyViewStateToTransform(tr, props) {\n const v = props.viewState || props;\n let changed = false;\n if ('zoom' in v) {\n const zoom = tr.zoom;\n tr.zoom = v.zoom;\n changed = changed || zoom !== tr.zoom;\n }\n if ('bearing' in v) {\n const bearing = tr.bearing;\n tr.bearing = v.bearing;\n changed = changed || bearing !== tr.bearing;\n }\n if ('pitch' in v) {\n const pitch = tr.pitch;\n tr.pitch = v.pitch;\n changed = changed || pitch !== tr.pitch;\n }\n if (v.padding && !tr.isPaddingEqual(v.padding)) {\n changed = true;\n tr.padding = v.padding;\n }\n if ('longitude' in v && 'latitude' in v) {\n const center = tr.center;\n // @ts-ignore\n tr.center = new center.constructor(v.longitude, v.latitude);\n changed = changed || center !== tr.center;\n }\n return changed;\n}\n//# sourceMappingURL=transform.js.map"],"names":[],"mappings":";AAKO,SAAS,eAAe,IAAI;AAC/B,QAAM,eAAe,GAAG;AAExB,eAAa,kBAAkB,GAAG;AAClC,SAAO;AACX;AAMO,SAAS,eAAe,KAAK,MAAM;AACtC,MAAI,CAAC,IAAI,eAAe;AACpB;AAAA,EACH;AACD,QAAM,gBAAgB,IAAI;AAC1B,QAAM,iBAAiB,KAAK;AAC5B,MAAI,CAAC,UAAU,eAAe,cAAc,GAAG;AAC3C,SAAK,cAAc,aAAa;AAAA,EACnC;AACL;AAMO,SAAS,qBAAqB,IAAI;AACrC,SAAO;AAAA,IACH,WAAW,GAAG,OAAO;AAAA,IACrB,UAAU,GAAG,OAAO;AAAA,IACpB,MAAM,GAAG;AAAA,IACT,OAAO,GAAG;AAAA,IACV,SAAS,GAAG;AAAA,IACZ,SAAS,GAAG;AAAA,EACpB;AACA;AAQO,SAAS,0BAA0B,IAAI,OAAO;AACjD,QAAM,IAAI,MAAM,aAAa;AAC7B,MAAI,UAAU;AACd,MAAI,UAAU,GAAG;AACb,UAAM,OAAO,GAAG;AAChB,OAAG,OAAO,EAAE;AACZ,cAAU,WAAW,SAAS,GAAG;AAAA,EACpC;AACD,MAAI,aAAa,GAAG;AAChB,UAAM,UAAU,GAAG;AACnB,OAAG,UAAU,EAAE;AACf,cAAU,WAAW,YAAY,GAAG;AAAA,EACvC;AACD,MAAI,WAAW,GAAG;AACd,UAAM,QAAQ,GAAG;AACjB,OAAG,QAAQ,EAAE;AACb,cAAU,WAAW,UAAU,GAAG;AAAA,EACrC;AACD,MAAI,EAAE,WAAW,CAAC,GAAG,eAAe,EAAE,OAAO,GAAG;AAC5C,cAAU;AACV,OAAG,UAAU,EAAE;AAAA,EAClB;AACD,MAAI,eAAe,KAAK,cAAc,GAAG;AACrC,UAAM,SAAS,GAAG;AAElB,OAAG,SAAS,IAAI,OAAO,YAAY,EAAE,WAAW,EAAE,QAAQ;AAC1D,cAAU,WAAW,WAAW,GAAG;AAAA,EACtC;AACD,SAAO;AACX;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const refProps = ["type", "source", "source-layer", "minzoom", "maxzoom", "filter", "layout"];
|
|
2
|
+
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 { ...style, layers };
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
normalizeStyle
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=main42.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main42.mjs","sources":["../../node_modules/@vis.gl/react-mapbox/dist/utils/style-utils.js"],"sourcesContent":["const refProps = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout'];\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(style) {\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 for (const layer of style.layers) {\n layerIndex[layer.id] = layer;\n }\n const layers = style.layers.map(layer => {\n let normalizedLayer = null;\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 // 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 return normalizedLayer || layer;\n });\n // Do not mutate the style object provided by the user\n return { ...style, layers };\n}\n//# sourceMappingURL=style-utils.js.map"],"names":[],"mappings":"AAAA,MAAM,WAAW,CAAC,QAAQ,UAAU,gBAAgB,WAAW,WAAW,UAAU,QAAQ;AAIrF,SAAS,eAAe,OAAO;AAClC,MAAI,CAAC,OAAO;AACR,WAAO;AAAA,EACV;AACD,MAAI,OAAO,UAAU,UAAU;AAC3B,WAAO;AAAA,EACV;AACD,MAAI,UAAU,OAAO;AACjB,YAAQ,MAAM;EACjB;AACD,MAAI,CAAC,MAAM,QAAQ;AACf,WAAO;AAAA,EACV;AACD,QAAM,aAAa,CAAA;AACnB,aAAW,SAAS,MAAM,QAAQ;AAC9B,eAAW,MAAM,EAAE,IAAI;AAAA,EAC1B;AACD,QAAM,SAAS,MAAM,OAAO,IAAI,WAAS;AACrC,QAAI,kBAAkB;AACtB,QAAI,iBAAiB,OAAO;AACxB,wBAAkB,OAAO,OAAO,CAAE,GAAE,KAAK;AAGzC,aAAO,gBAAgB;AAAA,IAC1B;AAGD,UAAM,WAAW,WAAW,MAAM,GAAG;AACrC,QAAI,UAAU;AACV,wBAAkB,mBAAmB,OAAO,OAAO,CAAE,GAAE,KAAK;AAE5D,aAAO,gBAAgB;AAEvB,iBAAW,YAAY,UAAU;AAC7B,YAAI,YAAY,UAAU;AACtB,0BAAgB,QAAQ,IAAI,SAAS,QAAQ;AAAA,QAChD;AAAA,MACJ;AAAA,IACJ;AACD,WAAO,mBAAmB;AAAA,EAClC,CAAK;AAED,SAAO,EAAE,GAAG,OAAO;AACvB;","x_google_ignoreList":[0]}
|
package/dist/es/main5.mjs
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
|
-
import { earthRadius } from "./
|
|
2
|
+
import { earthRadius } from "./main24.mjs";
|
|
3
|
+
const mercatorScaleLookup = {};
|
|
4
|
+
function getMercatorScale(lat) {
|
|
5
|
+
const index = Math.round(lat * 1e3);
|
|
6
|
+
if (mercatorScaleLookup[index] === void 0) {
|
|
7
|
+
mercatorScaleLookup[index] = 1 / Math.cos(lat * MathUtils.DEG2RAD);
|
|
8
|
+
}
|
|
9
|
+
return mercatorScaleLookup[index];
|
|
10
|
+
}
|
|
11
|
+
function averageMercatorScale(originLat, pointLat, steps = 10) {
|
|
12
|
+
let totalScale = 0;
|
|
13
|
+
const latStep = (pointLat - originLat) / steps;
|
|
14
|
+
for (let i = 0; i <= steps; i++) {
|
|
15
|
+
const lat = originLat + latStep * i;
|
|
16
|
+
totalScale += getMercatorScale(lat);
|
|
17
|
+
}
|
|
18
|
+
return totalScale / (steps + 1);
|
|
19
|
+
}
|
|
3
20
|
function coordsToVector3(point, origin) {
|
|
4
21
|
const latitudeDiff = (point.latitude - origin.latitude) * MathUtils.DEG2RAD;
|
|
5
22
|
const longitudeDiff = (point.longitude - origin.longitude) * MathUtils.DEG2RAD;
|
|
6
23
|
const altitudeDiff = (point.altitude || 0) - (origin.altitude || 0);
|
|
7
24
|
const x = longitudeDiff * earthRadius * Math.cos(origin.latitude * MathUtils.DEG2RAD);
|
|
8
25
|
const y = altitudeDiff;
|
|
9
|
-
const
|
|
26
|
+
const steps = Math.ceil(Math.abs(point.latitude - origin.latitude)) * 100 + 1;
|
|
27
|
+
const avgScale = averageMercatorScale(origin.latitude, point.latitude, steps);
|
|
28
|
+
const z = -latitudeDiff * earthRadius / getMercatorScale(origin.latitude) * avgScale;
|
|
10
29
|
return [x, y, z];
|
|
11
30
|
}
|
|
12
31
|
export {
|
|
32
|
+
averageMercatorScale,
|
|
13
33
|
coordsToVector3
|
|
14
34
|
};
|
|
15
35
|
//# sourceMappingURL=main5.mjs.map
|
package/dist/es/main5.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main5.mjs","sources":["../../src/api/coords-to-vector-3.ts"],"sourcesContent":["import { MathUtils, Vector3Tuple } from 'three';\nimport { Coords } from './coords';\nimport { earthRadius } from \"../core/earth-radius\";\n\nexport function coordsToVector3(point: Coords, origin: Coords): Vector3Tuple {\n const latitudeDiff = (point.latitude - origin.latitude) * MathUtils.DEG2RAD;\n const longitudeDiff = (point.longitude - origin.longitude) * MathUtils.DEG2RAD;\n const altitudeDiff = (point.altitude || 0) - (origin.altitude || 0);\n\n const x = longitudeDiff * earthRadius * Math.cos(origin.latitude * MathUtils.DEG2RAD);\n const y = altitudeDiff;\n const z = -latitudeDiff * earthRadius;\n
|
|
1
|
+
{"version":3,"file":"main5.mjs","sources":["../../src/api/coords-to-vector-3.ts"],"sourcesContent":["import { MathUtils, Vector3Tuple } from 'three';\nimport { Coords } from './coords';\nimport { earthRadius } from \"../core/earth-radius\";\n\n\nconst mercatorScaleLookup: { [key: number]: number } = {};\n\nfunction getMercatorScale(lat: number): number {\n const index = Math.round(lat * 1000);\n if (mercatorScaleLookup[index] === undefined) {\n mercatorScaleLookup[index] = 1 / Math.cos(lat * MathUtils.DEG2RAD);\n }\n return mercatorScaleLookup[index];\n}\n\nexport function averageMercatorScale(originLat: number, pointLat: number, steps = 10): number {\n let totalScale = 0;\n const latStep = (pointLat - originLat) / steps;\n for (let i = 0; i <= steps; i++) {\n const lat = originLat + latStep * i;\n totalScale += getMercatorScale(lat);\n }\n return totalScale / (steps + 1);\n}\n\nexport function coordsToVector3(point: Coords, origin: Coords): Vector3Tuple {\n const latitudeDiff = (point.latitude - origin.latitude) * MathUtils.DEG2RAD;\n const longitudeDiff = (point.longitude - origin.longitude) * MathUtils.DEG2RAD;\n const altitudeDiff = (point.altitude || 0) - (origin.altitude || 0);\n\n const x = longitudeDiff * earthRadius * Math.cos(origin.latitude * MathUtils.DEG2RAD);\n const y = altitudeDiff;\n\n // dynamic step size based on latitude difference. calculate the mercator unit scale at origin\n // and the scale average along the line to the point for better accuracy far from origin\n const steps = Math.ceil(Math.abs(point.latitude - origin.latitude)) * 100 + 1;\n const avgScale = averageMercatorScale(origin.latitude, point.latitude, steps);\n\n const z = ((-latitudeDiff * earthRadius) / getMercatorScale(origin.latitude)) * avgScale;\n return [x, y, z] as Vector3Tuple;\n}"],"names":[],"mappings":";;AAKA,MAAM,sBAAiD,CAAA;AAEvD,SAAS,iBAAiB,KAAqB;AAC7C,QAAM,QAAQ,KAAK,MAAM,MAAM,GAAI;AAC/B,MAAA,oBAAoB,KAAK,MAAM,QAAW;AAC5C,wBAAoB,KAAK,IAAI,IAAI,KAAK,IAAI,MAAM,UAAU,OAAO;AAAA,EACnE;AACA,SAAO,oBAAoB,KAAK;AAClC;AAEO,SAAS,qBAAqB,WAAmB,UAAkB,QAAQ,IAAY;AAC5F,MAAI,aAAa;AACX,QAAA,WAAW,WAAW,aAAa;AACzC,WAAS,IAAI,GAAG,KAAK,OAAO,KAAK;AACzB,UAAA,MAAM,YAAY,UAAU;AAClC,kBAAc,iBAAiB,GAAG;AAAA,EACpC;AACA,SAAO,cAAc,QAAQ;AAC/B;AAEgB,SAAA,gBAAgB,OAAe,QAA8B;AAC3E,QAAM,gBAAgB,MAAM,WAAW,OAAO,YAAY,UAAU;AACpE,QAAM,iBAAiB,MAAM,YAAY,OAAO,aAAa,UAAU;AACvE,QAAM,gBAAgB,MAAM,YAAY,MAAM,OAAO,YAAY;AAE3D,QAAA,IAAI,gBAAgB,cAAc,KAAK,IAAI,OAAO,WAAW,UAAU,OAAO;AACpF,QAAM,IAAI;AAIJ,QAAA,QAAQ,KAAK,KAAK,KAAK,IAAI,MAAM,WAAW,OAAO,QAAQ,CAAC,IAAI,MAAM;AAC5E,QAAM,WAAW,qBAAqB,OAAO,UAAU,MAAM,UAAU,KAAK;AAE5E,QAAM,IAAM,CAAC,eAAe,cAAe,iBAAiB,OAAO,QAAQ,IAAK;AACzE,SAAA,CAAC,GAAG,GAAG,CAAC;AACjB;"}
|
package/dist/es/main6.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { memo, useMemo } from "react";
|
|
3
|
-
import { useCoords } from "./
|
|
3
|
+
import { useCoords } from "./main25.mjs";
|
|
4
4
|
import { coordsToVector3 } from "./main5.mjs";
|
|
5
5
|
const NearCoordinates = memo(({ children, ...coords }) => {
|
|
6
6
|
const { latitude, longitude, altitude } = useCoords();
|
package/dist/es/main7.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
|
-
import { earthRadius } from "./
|
|
2
|
+
import { earthRadius } from "./main24.mjs";
|
|
3
3
|
function vector3ToCoords(position, origin) {
|
|
4
4
|
const [x, y, z] = position;
|
|
5
5
|
const latitude = origin.latitude + -z / earthRadius * MathUtils.RAD2DEG;
|
package/dist/es/main8.mjs
CHANGED
|
@@ -1,26 +1,93 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useContext, useState, useRef, useEffect, useImperativeHandle, useMemo } from "react";
|
|
3
|
+
import { MountedMapsContext } from "./main17.mjs";
|
|
4
|
+
import Mapbox from "./main33.mjs";
|
|
5
|
+
import createRef from "./main34.mjs";
|
|
6
|
+
import useIsomorphicLayoutEffect from "./main35.mjs";
|
|
7
|
+
import setGlobals from "./main36.mjs";
|
|
8
|
+
const MapContext = React.createContext(null);
|
|
9
|
+
function _Map(props, ref) {
|
|
10
|
+
const mountedMapsContext = useContext(MountedMapsContext);
|
|
11
|
+
const [mapInstance, setMapInstance] = useState(null);
|
|
12
|
+
const containerRef = useRef();
|
|
13
|
+
const { current: contextValue } = useRef({ mapLib: null, map: null });
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const mapLib = props.mapLib;
|
|
16
|
+
let isMounted = true;
|
|
17
|
+
let mapbox;
|
|
18
|
+
Promise.resolve(mapLib || import("mapbox-gl")).then((module) => {
|
|
19
|
+
if (!isMounted) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!module) {
|
|
23
|
+
throw new Error("Invalid mapLib");
|
|
24
|
+
}
|
|
25
|
+
const mapboxgl = "Map" in module ? module : module.default;
|
|
26
|
+
if (!mapboxgl.Map) {
|
|
27
|
+
throw new Error("Invalid mapLib");
|
|
28
|
+
}
|
|
29
|
+
setGlobals(mapboxgl, props);
|
|
30
|
+
if (!mapboxgl.supported || mapboxgl.supported(props)) {
|
|
31
|
+
if (props.reuseMaps) {
|
|
32
|
+
mapbox = Mapbox.reuse(props, containerRef.current);
|
|
33
|
+
}
|
|
34
|
+
if (!mapbox) {
|
|
35
|
+
mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current);
|
|
36
|
+
}
|
|
37
|
+
contextValue.map = createRef(mapbox);
|
|
38
|
+
contextValue.mapLib = mapboxgl;
|
|
39
|
+
setMapInstance(mapbox);
|
|
40
|
+
mountedMapsContext == null ? void 0 : mountedMapsContext.onMapMount(contextValue.map, props.id);
|
|
41
|
+
} else {
|
|
42
|
+
throw new Error("Map is not supported by this browser");
|
|
43
|
+
}
|
|
44
|
+
}).catch((error) => {
|
|
45
|
+
const { onError } = props;
|
|
46
|
+
if (onError) {
|
|
47
|
+
onError({
|
|
48
|
+
type: "error",
|
|
49
|
+
target: null,
|
|
50
|
+
error
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
console.error(error);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return () => {
|
|
57
|
+
isMounted = false;
|
|
58
|
+
if (mapbox) {
|
|
59
|
+
mountedMapsContext == null ? void 0 : mountedMapsContext.onMapUnmount(props.id);
|
|
60
|
+
if (props.reuseMaps) {
|
|
61
|
+
mapbox.recycle();
|
|
62
|
+
} else {
|
|
63
|
+
mapbox.destroy();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}, []);
|
|
68
|
+
useIsomorphicLayoutEffect(() => {
|
|
69
|
+
if (mapInstance) {
|
|
70
|
+
mapInstance.setProps(props);
|
|
71
|
+
}
|
|
11
72
|
});
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
73
|
+
useImperativeHandle(ref, () => contextValue.map, [mapInstance]);
|
|
74
|
+
const style = useMemo(() => ({
|
|
75
|
+
position: "relative",
|
|
76
|
+
width: "100%",
|
|
77
|
+
height: "100%",
|
|
78
|
+
...props.style
|
|
79
|
+
}), [props.style]);
|
|
80
|
+
const CHILD_CONTAINER_STYLE = {
|
|
81
|
+
height: "100%"
|
|
21
82
|
};
|
|
83
|
+
return React.createElement("div", { id: props.id, ref: containerRef, style }, mapInstance && React.createElement(
|
|
84
|
+
MapContext.Provider,
|
|
85
|
+
{ value: contextValue },
|
|
86
|
+
React.createElement("div", { "mapboxgl-children": "", style: CHILD_CONTAINER_STYLE }, props.children)
|
|
87
|
+
));
|
|
22
88
|
}
|
|
89
|
+
React.forwardRef(_Map);
|
|
23
90
|
export {
|
|
24
|
-
|
|
91
|
+
MapContext
|
|
25
92
|
};
|
|
26
93
|
//# sourceMappingURL=main8.mjs.map
|
package/dist/es/main8.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main8.mjs","sources":["../../
|
|
1
|
+
{"version":3,"file":"main8.mjs","sources":["../../node_modules/@vis.gl/react-mapbox/dist/components/map.js"],"sourcesContent":["import * as React from 'react';\nimport { useState, useRef, useEffect, useContext, useMemo, useImperativeHandle } from 'react';\nimport { MountedMapsContext } from \"./use-map.js\";\nimport Mapbox from \"../mapbox/mapbox.js\";\nimport createRef from \"../mapbox/create-ref.js\";\nimport useIsomorphicLayoutEffect from \"../utils/use-isomorphic-layout-effect.js\";\nimport setGlobals from \"../utils/set-globals.js\";\nexport const MapContext = React.createContext(null);\nfunction _Map(props, ref) {\n const mountedMapsContext = useContext(MountedMapsContext);\n const [mapInstance, setMapInstance] = useState(null);\n const containerRef = useRef();\n const { current: contextValue } = useRef({ mapLib: null, map: null });\n useEffect(() => {\n const mapLib = props.mapLib;\n let isMounted = true;\n let mapbox;\n Promise.resolve(mapLib || import('mapbox-gl'))\n .then((module) => {\n if (!isMounted) {\n return;\n }\n if (!module) {\n throw new Error('Invalid mapLib');\n }\n const mapboxgl = 'Map' in module ? module : module.default;\n if (!mapboxgl.Map) {\n throw new Error('Invalid mapLib');\n }\n // workerUrl & workerClass may change the result of supported()\n // https://github.com/visgl/react-map-gl/discussions/2027\n setGlobals(mapboxgl, props);\n if (!mapboxgl.supported || mapboxgl.supported(props)) {\n if (props.reuseMaps) {\n mapbox = Mapbox.reuse(props, containerRef.current);\n }\n if (!mapbox) {\n mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current);\n }\n contextValue.map = createRef(mapbox);\n contextValue.mapLib = mapboxgl;\n setMapInstance(mapbox);\n mountedMapsContext?.onMapMount(contextValue.map, props.id);\n }\n else {\n throw new Error('Map is not supported by this browser');\n }\n })\n .catch(error => {\n const { onError } = props;\n if (onError) {\n onError({\n type: 'error',\n target: null,\n error\n });\n }\n else {\n console.error(error); // eslint-disable-line\n }\n });\n return () => {\n isMounted = false;\n if (mapbox) {\n mountedMapsContext?.onMapUnmount(props.id);\n if (props.reuseMaps) {\n mapbox.recycle();\n }\n else {\n mapbox.destroy();\n }\n }\n };\n }, []);\n useIsomorphicLayoutEffect(() => {\n if (mapInstance) {\n mapInstance.setProps(props);\n }\n });\n useImperativeHandle(ref, () => contextValue.map, [mapInstance]);\n const style = useMemo(() => ({\n position: 'relative',\n width: '100%',\n height: '100%',\n ...props.style\n }), [props.style]);\n const CHILD_CONTAINER_STYLE = {\n height: '100%'\n };\n return (React.createElement(\"div\", { id: props.id, ref: containerRef, style: style }, mapInstance && (React.createElement(MapContext.Provider, { value: contextValue },\n React.createElement(\"div\", { \"mapboxgl-children\": \"\", style: CHILD_CONTAINER_STYLE }, props.children)))));\n}\nexport const Map = React.forwardRef(_Map);\n//# sourceMappingURL=map.js.map"],"names":[],"mappings":";;;;;;;AAOY,MAAC,aAAa,MAAM,cAAc,IAAI;AAClD,SAAS,KAAK,OAAO,KAAK;AACtB,QAAM,qBAAqB,WAAW,kBAAkB;AACxD,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,IAAI;AACnD,QAAM,eAAe;AACrB,QAAM,EAAE,SAAS,aAAY,IAAK,OAAO,EAAE,QAAQ,MAAM,KAAK,KAAI,CAAE;AACpE,YAAU,MAAM;AACZ,UAAM,SAAS,MAAM;AACrB,QAAI,YAAY;AAChB,QAAI;AACJ,YAAQ,QAAQ,UAAU,OAAO,WAAW,CAAC,EACxC,KAAK,CAAC,WAAW;AAClB,UAAI,CAAC,WAAW;AACZ;AAAA,MACH;AACD,UAAI,CAAC,QAAQ;AACT,cAAM,IAAI,MAAM,gBAAgB;AAAA,MACnC;AACD,YAAM,WAAW,SAAS,SAAS,SAAS,OAAO;AACnD,UAAI,CAAC,SAAS,KAAK;AACf,cAAM,IAAI,MAAM,gBAAgB;AAAA,MACnC;AAGD,iBAAW,UAAU,KAAK;AAC1B,UAAI,CAAC,SAAS,aAAa,SAAS,UAAU,KAAK,GAAG;AAClD,YAAI,MAAM,WAAW;AACjB,mBAAS,OAAO,MAAM,OAAO,aAAa,OAAO;AAAA,QACpD;AACD,YAAI,CAAC,QAAQ;AACT,mBAAS,IAAI,OAAO,SAAS,KAAK,OAAO,aAAa,OAAO;AAAA,QAChE;AACD,qBAAa,MAAM,UAAU,MAAM;AACnC,qBAAa,SAAS;AACtB,uBAAe,MAAM;AACrB,iEAAoB,WAAW,aAAa,KAAK,MAAM;AAAA,MAC1D,OACI;AACD,cAAM,IAAI,MAAM,sCAAsC;AAAA,MACzD;AAAA,IACb,CAAS,EACI,MAAM,WAAS;AAChB,YAAM,EAAE,QAAS,IAAG;AACpB,UAAI,SAAS;AACT,gBAAQ;AAAA,UACJ,MAAM;AAAA,UACN,QAAQ;AAAA,UACR;AAAA,QACpB,CAAiB;AAAA,MACJ,OACI;AACD,gBAAQ,MAAM,KAAK;AAAA,MACtB;AAAA,IACb,CAAS;AACD,WAAO,MAAM;AACT,kBAAY;AACZ,UAAI,QAAQ;AACR,iEAAoB,aAAa,MAAM;AACvC,YAAI,MAAM,WAAW;AACjB,iBAAO,QAAO;AAAA,QACjB,OACI;AACD,iBAAO,QAAO;AAAA,QACjB;AAAA,MACJ;AAAA,IACb;AAAA,EACK,GAAE,CAAE,CAAA;AACL,4BAA0B,MAAM;AAC5B,QAAI,aAAa;AACb,kBAAY,SAAS,KAAK;AAAA,IAC7B;AAAA,EACT,CAAK;AACD,sBAAoB,KAAK,MAAM,aAAa,KAAK,CAAC,WAAW,CAAC;AAC9D,QAAM,QAAQ,QAAQ,OAAO;AAAA,IACzB,UAAU;AAAA,IACV,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,GAAG,MAAM;AAAA,EACZ,IAAG,CAAC,MAAM,KAAK,CAAC;AACjB,QAAM,wBAAwB;AAAA,IAC1B,QAAQ;AAAA,EAChB;AACI,SAAQ,MAAM,cAAc,OAAO,EAAE,IAAI,MAAM,IAAI,KAAK,cAAc,MAAc,GAAE,eAAgB,MAAM;AAAA,IAAc,WAAW;AAAA,IAAU,EAAE,OAAO,aAAc;AAAA,IAClK,MAAM,cAAc,OAAO,EAAE,qBAAqB,IAAI,OAAO,sBAAuB,GAAE,MAAM,QAAQ;AAAA,EAAC,CAAE;AAC/G;AACmB,MAAM,WAAW,IAAI;","x_google_ignoreList":[0]}
|
package/dist/es/main9.mjs
CHANGED
|
@@ -1,30 +1,86 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { memo,
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { memo, forwardRef, useContext, useRef, useMemo, useEffect, useImperativeHandle } from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
import { applyReactStyle } from "./main37.mjs";
|
|
5
|
+
import { MapContext } from "./main8.mjs";
|
|
6
|
+
import { arePointsEqual } from "./main38.mjs";
|
|
7
|
+
memo(forwardRef((props, ref) => {
|
|
8
|
+
const { map, mapLib } = useContext(MapContext);
|
|
9
|
+
const thisRef = useRef({ props });
|
|
10
|
+
thisRef.current.props = props;
|
|
11
|
+
const marker = useMemo(() => {
|
|
12
|
+
let hasChildren = false;
|
|
13
|
+
React.Children.forEach(props.children, (el) => {
|
|
14
|
+
if (el) {
|
|
15
|
+
hasChildren = true;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const options = {
|
|
19
|
+
...props,
|
|
20
|
+
element: hasChildren ? document.createElement("div") : null
|
|
21
|
+
};
|
|
22
|
+
const mk = new mapLib.Marker(options);
|
|
23
|
+
mk.setLngLat([props.longitude, props.latitude]);
|
|
24
|
+
mk.getElement().addEventListener("click", (e) => {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
(_b = (_a = thisRef.current.props).onClick) == null ? void 0 : _b.call(_a, {
|
|
27
|
+
type: "click",
|
|
28
|
+
target: mk,
|
|
29
|
+
originalEvent: e
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
mk.on("dragstart", (e) => {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
const evt = e;
|
|
35
|
+
evt.lngLat = marker.getLngLat();
|
|
36
|
+
(_b = (_a = thisRef.current.props).onDragStart) == null ? void 0 : _b.call(_a, evt);
|
|
37
|
+
});
|
|
38
|
+
mk.on("drag", (e) => {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const evt = e;
|
|
41
|
+
evt.lngLat = marker.getLngLat();
|
|
42
|
+
(_b = (_a = thisRef.current.props).onDrag) == null ? void 0 : _b.call(_a, evt);
|
|
43
|
+
});
|
|
44
|
+
mk.on("dragend", (e) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const evt = e;
|
|
47
|
+
evt.lngLat = marker.getLngLat();
|
|
48
|
+
(_b = (_a = thisRef.current.props).onDragEnd) == null ? void 0 : _b.call(_a, evt);
|
|
49
|
+
});
|
|
50
|
+
return mk;
|
|
51
|
+
}, []);
|
|
17
52
|
useEffect(() => {
|
|
18
|
-
|
|
19
|
-
parent.appendChild(el);
|
|
53
|
+
marker.addTo(map.getMap());
|
|
20
54
|
return () => {
|
|
21
|
-
|
|
55
|
+
marker.remove();
|
|
22
56
|
};
|
|
23
57
|
}, []);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
58
|
+
const { longitude, latitude, offset, style, draggable = false, popup = null, rotation = 0, rotationAlignment = "auto", pitchAlignment = "auto" } = props;
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
applyReactStyle(marker.getElement(), style);
|
|
61
|
+
}, [style]);
|
|
62
|
+
useImperativeHandle(ref, () => marker, []);
|
|
63
|
+
if (marker.getLngLat().lng !== longitude || marker.getLngLat().lat !== latitude) {
|
|
64
|
+
marker.setLngLat([longitude, latitude]);
|
|
65
|
+
}
|
|
66
|
+
if (offset && !arePointsEqual(marker.getOffset(), offset)) {
|
|
67
|
+
marker.setOffset(offset);
|
|
68
|
+
}
|
|
69
|
+
if (marker.isDraggable() !== draggable) {
|
|
70
|
+
marker.setDraggable(draggable);
|
|
71
|
+
}
|
|
72
|
+
if (marker.getRotation() !== rotation) {
|
|
73
|
+
marker.setRotation(rotation);
|
|
74
|
+
}
|
|
75
|
+
if (marker.getRotationAlignment() !== rotationAlignment) {
|
|
76
|
+
marker.setRotationAlignment(rotationAlignment);
|
|
77
|
+
}
|
|
78
|
+
if (marker.getPitchAlignment() !== pitchAlignment) {
|
|
79
|
+
marker.setPitchAlignment(pitchAlignment);
|
|
80
|
+
}
|
|
81
|
+
if (marker.getPopup() !== popup) {
|
|
82
|
+
marker.setPopup(popup);
|
|
83
|
+
}
|
|
84
|
+
return createPortal(props.children, marker.getElement());
|
|
85
|
+
}));
|
|
30
86
|
//# sourceMappingURL=main9.mjs.map
|