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/package.json
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-bkoi-gl",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"updatedAt": "12-05-2025 5:19:02 PM",
|
|
3
|
+
"version": "2.1.0",
|
|
5
4
|
"engines": {
|
|
6
|
-
"node": ">=18.
|
|
5
|
+
"node": ">=18.18.0"
|
|
7
6
|
},
|
|
8
|
-
"description": "React
|
|
7
|
+
"description": "A React library for Barikoi Maps with interactive components, markers, popups, and controls.",
|
|
9
8
|
"type": "module",
|
|
10
9
|
"types": "dist/index.d.ts",
|
|
11
10
|
"main": "dist/index.cjs",
|
|
12
11
|
"module": "dist/index.js",
|
|
13
12
|
"exports": {
|
|
14
13
|
".": {
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
19
22
|
},
|
|
20
23
|
"./styles": {
|
|
21
24
|
"types": "./dist/styles/index.d.ts",
|
|
@@ -28,59 +31,108 @@
|
|
|
28
31
|
"license": "MIT",
|
|
29
32
|
"homepage": "https://docs.barikoi.com/docs/maps-api",
|
|
30
33
|
"files": [
|
|
31
|
-
"src",
|
|
32
34
|
"dist",
|
|
35
|
+
"LICENSE",
|
|
33
36
|
"README.md"
|
|
34
37
|
],
|
|
35
38
|
"scripts": {
|
|
36
|
-
"typecheck": "tsc
|
|
37
|
-
"clean": "rm -rf dist
|
|
38
|
-
"build": "
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"clean": "rm -rf dist",
|
|
41
|
+
"build": "tsup && node scripts/modify-css.js",
|
|
39
42
|
"lint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
|
|
43
|
+
"lint:fix": "eslint src/ --ext .js,.jsx,.ts,.tsx --fix",
|
|
44
|
+
"lint:cache": "eslint src/ --ext .js,.jsx,.ts,.tsx --cache",
|
|
45
|
+
"lint:fix:cache": "eslint src/ --ext .js,.jsx,.ts,.tsx --fix --cache",
|
|
40
46
|
"test": "npm run typecheck && jest",
|
|
41
47
|
"coverage": "jest --coverage --passWithNoTests",
|
|
42
|
-
"
|
|
48
|
+
"prepare": "husky"
|
|
43
49
|
},
|
|
44
50
|
"dependencies": {
|
|
45
|
-
"@maplibre/maplibre-gl-style-spec": "^
|
|
46
|
-
"maplibre-gl": "^5.
|
|
51
|
+
"@maplibre/maplibre-gl-style-spec": "^24.4.1",
|
|
52
|
+
"maplibre-gl": "^5.15.0",
|
|
53
|
+
"maplibre-gl-draw": "^1.6.9"
|
|
47
54
|
},
|
|
48
55
|
"peerDependencies": {
|
|
49
56
|
"react": ">=16.3.0",
|
|
50
57
|
"react-dom": ">=16.3.0"
|
|
51
58
|
},
|
|
59
|
+
"lint-staged": {
|
|
60
|
+
"*.{js,jsx,ts,tsx}": [
|
|
61
|
+
"eslint --fix",
|
|
62
|
+
"prettier --write"
|
|
63
|
+
]
|
|
64
|
+
},
|
|
52
65
|
"devDependencies": {
|
|
53
|
-
"@commitlint/cli": "^
|
|
54
|
-
"@commitlint/config-conventional": "^
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@testing-library/
|
|
58
|
-
"@
|
|
59
|
-
"@types/
|
|
60
|
-
"@types/
|
|
66
|
+
"@commitlint/cli": "^20.4.4",
|
|
67
|
+
"@commitlint/config-conventional": "^20.4.4",
|
|
68
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
69
|
+
"@eslint/js": "^9.39.4",
|
|
70
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
71
|
+
"@testing-library/react": "^14.3.1",
|
|
72
|
+
"@types/jest": "^29.5.14",
|
|
73
|
+
"@types/node": "^22.13.3",
|
|
74
|
+
"@types/react": "^18.3.27",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^8.57.0",
|
|
76
|
+
"@typescript-eslint/parser": "^8.57.0",
|
|
61
77
|
"babel-jest": "^29.7.0",
|
|
78
|
+
"eslint": "^9.39.4",
|
|
79
|
+
"eslint-config-next": "^16.1.6",
|
|
80
|
+
"eslint-config-prettier": "^10.1.8",
|
|
81
|
+
"eslint-plugin-import": "^2.32.0",
|
|
82
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
83
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
84
|
+
"eslint-plugin-react": "^7.37.5",
|
|
85
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
86
|
+
"husky": "^9.1.7",
|
|
62
87
|
"identity-obj-proxy": "^3.0.0",
|
|
63
88
|
"jest": "^29.7.0",
|
|
64
|
-
"jest-environment-jsdom": "^
|
|
65
|
-
"
|
|
66
|
-
"
|
|
89
|
+
"jest-environment-jsdom": "^30.3.0",
|
|
90
|
+
"lint-staged": "^16.4.0",
|
|
91
|
+
"prettier": "^3.8.1",
|
|
92
|
+
"puppeteer": "^24.34.0",
|
|
67
93
|
"react": "^18.0.0",
|
|
68
94
|
"react-dom": "^18.0.0",
|
|
69
95
|
"react-test-renderer": "^18.0.0",
|
|
70
96
|
"tape-promise": "^4.0.0",
|
|
71
|
-
"ts-jest": "^29.
|
|
72
|
-
"
|
|
97
|
+
"ts-jest": "^29.4.6",
|
|
98
|
+
"tsup": "^8.5.1",
|
|
99
|
+
"typescript": "^5.9.3"
|
|
100
|
+
},
|
|
101
|
+
"publishConfig": {
|
|
102
|
+
"access": "public"
|
|
73
103
|
},
|
|
74
104
|
"keywords": [
|
|
75
105
|
"barikoi",
|
|
106
|
+
"bkoi",
|
|
76
107
|
"bkoi-gl",
|
|
77
108
|
"react",
|
|
78
109
|
"react-bkoi-gl",
|
|
79
|
-
"react bkoi"
|
|
110
|
+
"react bkoi",
|
|
111
|
+
"react-bkoi",
|
|
112
|
+
"barikoi maps",
|
|
113
|
+
"barikoi-gl",
|
|
114
|
+
"maplibre",
|
|
115
|
+
"maplibre-gl",
|
|
116
|
+
"react-map",
|
|
117
|
+
"react-maplibre",
|
|
118
|
+
"maps",
|
|
119
|
+
"mapping",
|
|
120
|
+
"bangladesh",
|
|
121
|
+
"bangladesh maps",
|
|
122
|
+
"interactive maps",
|
|
123
|
+
"map components",
|
|
124
|
+
"markers",
|
|
125
|
+
"popups",
|
|
126
|
+
"navigation",
|
|
127
|
+
"geolocation",
|
|
128
|
+
"map controls"
|
|
80
129
|
],
|
|
81
130
|
"repository": {
|
|
82
131
|
"type": "git",
|
|
83
|
-
"url": "https://github.com/barikoi/react-bkoi-gl.git"
|
|
132
|
+
"url": "git+https://github.com/barikoi/react-bkoi-gl.git"
|
|
133
|
+
},
|
|
134
|
+
"bugs": {
|
|
135
|
+
"url": "https://github.com/barikoi/react-bkoi-gl/issues"
|
|
84
136
|
},
|
|
85
137
|
"overrides": {
|
|
86
138
|
"@testing-library/react-hooks": {
|
|
@@ -89,4 +141,4 @@
|
|
|
89
141
|
"react-test-renderer": "$react-test-renderer"
|
|
90
142
|
}
|
|
91
143
|
}
|
|
92
|
-
}
|
|
144
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { ControlPosition, AttributionControlOptions } from "../types/lib";
|
|
3
|
-
export type AttributionControlProps = AttributionControlOptions & {
|
|
4
|
-
/** Placement of the control relative to the map. */
|
|
5
|
-
position?: ControlPosition;
|
|
6
|
-
/** CSS style override, applied to the control's container */
|
|
7
|
-
style?: React.CSSProperties;
|
|
8
|
-
};
|
|
9
|
-
export declare const AttributionControl: React.FC<AttributionControlProps>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useEffect, memo } from "react";
|
|
2
|
-
import { applyReactStyle } from "../utils/apply-react-style.js";
|
|
3
|
-
import { useControl } from "./use-control.js";
|
|
4
|
-
function _AttributionControl(props) {
|
|
5
|
-
const ctrl = useControl(_ref => {
|
|
6
|
-
let {
|
|
7
|
-
mapLib
|
|
8
|
-
} = _ref;
|
|
9
|
-
return new mapLib.AttributionControl(props);
|
|
10
|
-
}, {
|
|
11
|
-
position: props.position
|
|
12
|
-
});
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
applyReactStyle(ctrl._container, props.style);
|
|
15
|
-
if (!ctrl._container) return;
|
|
16
|
-
}, [props.style, ctrl._container]);
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
export const AttributionControl = memo(_AttributionControl);
|
|
20
|
-
//# sourceMappingURL=attribution-control.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attribution-control.js","names":["useEffect","memo","applyReactStyle","useControl","_AttributionControl","props","ctrl","_ref","mapLib","AttributionControl","position","_container","style"],"sources":["../../src/components/attribution-control.ts"],"sourcesContent":["/* eslint-disable max-statements */\n/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\nimport * as React from \"react\";\nimport { useEffect, memo } from \"react\";\nimport { applyReactStyle } from \"../utils/apply-react-style\";\nimport { useControl } from \"./use-control\";\n\nimport type { ControlPosition, AttributionControlOptions } from \"../types/lib\";\n\nexport type AttributionControlProps = AttributionControlOptions & {\n /** Placement of the control relative to the map. */\n position?: ControlPosition;\n /** CSS style override, applied to the control's container */\n style?: React.CSSProperties;\n};\n\nfunction _AttributionControl(props: AttributionControlProps) {\n const ctrl = useControl(\n ({ mapLib }) => new mapLib.AttributionControl(props),\n { position: props.position },\n );\n\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n\n // Ensure the container is available\n if (!ctrl._container) return;\n\n // Create and append the custom attribution control\n // const customAttribution = document.createElement('details');\n // customAttribution.className = 'maplibregl-ctrl maplibregl-ctrl-attrib maplibregl-compact maplibregl-compact-show';\n // customAttribution.setAttribute('open', '');\n\n // const summary = document.createElement('summary');\n // summary.className = 'maplibregl-ctrl-attrib-button';\n // summary.setAttribute('title', 'Toggle attribution');\n // summary.setAttribute('aria-label', 'Toggle attribution');\n // customAttribution.appendChild(summary);\n\n // const innerDiv = document.createElement('div');\n // innerDiv.className = 'maplibregl-ctrl-attrib-inner';\n // innerDiv.innerHTML = `\n // <a href=\"https://barikoi.com/\" target=\"_blank\">© Barikoi</a> |\n // <a href=\"https://www.openmaptiles.org/\" target=\"_blank\">© OpenMapTiles</a> |\n // <a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">© OpenStreetMap contributors</a>\n // `;\n // customAttribution.appendChild(innerDiv);\n\n // ctrl._container.appendChild(customAttribution);\n }, [props.style, ctrl._container]);\n\n return null;\n}\n\nexport const AttributionControl: React.FC<AttributionControlProps> =\n memo(_AttributionControl);\n"],"mappings":"AAGA,SAASA,SAAS,EAAEC,IAAI,QAAQ,OAAO;AAAC,SAC/BC,eAAe;AAAA,SACfC,UAAU;AAWnB,SAASC,mBAAmBA,CAACC,KAA8B,EAAE;EAC3D,MAAMC,IAAI,GAAGH,UAAU,CACrBI,IAAA;IAAA,IAAC;MAAEC;IAAO,CAAC,GAAAD,IAAA;IAAA,OAAK,IAAIC,MAAM,CAACC,kBAAkB,CAACJ,KAAK,CAAC;EAAA,GACpD;IAAEK,QAAQ,EAAEL,KAAK,CAACK;EAAS,CAC7B,CAAC;EAEDV,SAAS,CAAC,MAAM;IACdE,eAAe,CAACI,IAAI,CAACK,UAAU,EAAEN,KAAK,CAACO,KAAK,CAAC;IAG7C,IAAI,CAACN,IAAI,CAACK,UAAU,EAAE;EAuBxB,CAAC,EAAE,CAACN,KAAK,CAACO,KAAK,EAAEN,IAAI,CAACK,UAAU,CAAC,CAAC;EAElC,OAAO,IAAI;AACb;AAEA,OAAO,MAAMF,kBAAqD,GAChER,IAAI,CAACG,mBAAmB,CAAC","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { ControlPosition, FullscreenControlOptions } from "../types/lib";
|
|
3
|
-
export type FullscreenControlProps = Omit<FullscreenControlOptions, "container"> & {
|
|
4
|
-
/** Id of the DOM element which should be made full screen. By default, the map container
|
|
5
|
-
* element will be made full screen. */
|
|
6
|
-
containerId?: string;
|
|
7
|
-
/** Placement of the control relative to the map. */
|
|
8
|
-
position?: ControlPosition;
|
|
9
|
-
/** CSS style override, applied to the control's container */
|
|
10
|
-
style?: React.CSSProperties;
|
|
11
|
-
};
|
|
12
|
-
export declare const FullscreenControl: React.FC<FullscreenControlProps>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { useEffect, memo } from "react";
|
|
2
|
-
import { applyReactStyle } from "../utils/apply-react-style.js";
|
|
3
|
-
import { useControl } from "./use-control.js";
|
|
4
|
-
function _FullscreenControl(props) {
|
|
5
|
-
const ctrl = useControl(_ref => {
|
|
6
|
-
let {
|
|
7
|
-
mapLib
|
|
8
|
-
} = _ref;
|
|
9
|
-
return new mapLib.FullscreenControl({
|
|
10
|
-
container: props.containerId && document.getElementById(props.containerId)
|
|
11
|
-
});
|
|
12
|
-
}, {
|
|
13
|
-
position: props.position
|
|
14
|
-
});
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
applyReactStyle(ctrl._controlContainer, props.style);
|
|
17
|
-
}, [props.style]);
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
export const FullscreenControl = memo(_FullscreenControl);
|
|
21
|
-
//# sourceMappingURL=fullscreen-control.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fullscreen-control.js","names":["useEffect","memo","applyReactStyle","useControl","_FullscreenControl","props","ctrl","_ref","mapLib","FullscreenControl","container","containerId","document","getElementById","position","_controlContainer","style"],"sources":["../../src/components/fullscreen-control.ts"],"sourcesContent":["/* global document */\nimport * as React from \"react\";\nimport { useEffect, memo } from \"react\";\nimport { applyReactStyle } from \"../utils/apply-react-style\";\nimport { useControl } from \"./use-control\";\n\nimport type { ControlPosition, FullscreenControlOptions } from \"../types/lib\";\n\nexport type FullscreenControlProps = Omit<\n FullscreenControlOptions,\n \"container\"\n> & {\n /** Id of the DOM element which should be made full screen. By default, the map container\n * element will be made full screen. */\n containerId?: string;\n /** Placement of the control relative to the map. */\n position?: ControlPosition;\n /** CSS style override, applied to the control's container */\n style?: React.CSSProperties;\n};\n\nfunction _FullscreenControl(props: FullscreenControlProps) {\n const ctrl = useControl(\n ({ mapLib }) =>\n new mapLib.FullscreenControl({\n container:\n props.containerId && document.getElementById(props.containerId),\n }),\n { position: props.position },\n );\n\n useEffect(() => {\n applyReactStyle(ctrl._controlContainer, props.style);\n }, [props.style]);\n\n return null;\n}\n\nexport const FullscreenControl: React.FC<FullscreenControlProps> =\n memo(_FullscreenControl);\n"],"mappings":"AAEA,SAASA,SAAS,EAAEC,IAAI,QAAQ,OAAO;AAAC,SAC/BC,eAAe;AAAA,SACfC,UAAU;AAiBnB,SAASC,kBAAkBA,CAACC,KAA6B,EAAE;EACzD,MAAMC,IAAI,GAAGH,UAAU,CACrBI,IAAA;IAAA,IAAC;MAAEC;IAAO,CAAC,GAAAD,IAAA;IAAA,OACT,IAAIC,MAAM,CAACC,iBAAiB,CAAC;MAC3BC,SAAS,EACPL,KAAK,CAACM,WAAW,IAAIC,QAAQ,CAACC,cAAc,CAACR,KAAK,CAACM,WAAW;IAClE,CAAC,CAAC;EAAA,GACJ;IAAEG,QAAQ,EAAET,KAAK,CAACS;EAAS,CAC7B,CAAC;EAEDd,SAAS,CAAC,MAAM;IACdE,eAAe,CAACI,IAAI,CAACS,iBAAiB,EAAEV,KAAK,CAACW,KAAK,CAAC;EACtD,CAAC,EAAE,CAACX,KAAK,CAACW,KAAK,CAAC,CAAC;EAEjB,OAAO,IAAI;AACb;AAEA,OAAO,MAAMP,iBAAmD,GAC9DR,IAAI,CAACG,kBAAkB,CAAC","ignoreList":[]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { ControlPosition, GeolocateControlOptions } from "../types/lib";
|
|
3
|
-
import type { GeolocateEvent, GeolocateResultEvent, GeolocateErrorEvent } from "../types/events";
|
|
4
|
-
export type GeolocateControlProps = GeolocateControlOptions & {
|
|
5
|
-
/** Placement of the control relative to the map. */
|
|
6
|
-
position?: ControlPosition;
|
|
7
|
-
/** CSS style override, applied to the control's container */
|
|
8
|
-
style?: React.CSSProperties;
|
|
9
|
-
/** Called on each Geolocation API position update that returned as success. */
|
|
10
|
-
onGeolocate?: (e: GeolocateResultEvent) => void;
|
|
11
|
-
/** Called on each Geolocation API position update that returned as an error. */
|
|
12
|
-
onError?: (e: GeolocateErrorEvent) => void;
|
|
13
|
-
/** Called on each Geolocation API position update that returned as success but user position
|
|
14
|
-
* is out of map `maxBounds`. */
|
|
15
|
-
onOutOfMaxBounds?: (e: GeolocateResultEvent) => void;
|
|
16
|
-
/** Called when the GeolocateControl changes to the active lock state. */
|
|
17
|
-
onTrackUserLocationStart?: (e: GeolocateEvent) => void;
|
|
18
|
-
/** Called when the GeolocateControl changes to the background state. */
|
|
19
|
-
onTrackUserLocationEnd?: (e: GeolocateEvent) => void;
|
|
20
|
-
};
|
|
21
|
-
export declare const GeolocateControl: React.FC<GeolocateControlProps>;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useImperativeHandle, useRef, useEffect, forwardRef, memo } from "react";
|
|
2
|
-
import { applyReactStyle } from "../utils/apply-react-style.js";
|
|
3
|
-
import { useControl } from "./use-control.js";
|
|
4
|
-
function _GeolocateControl(props, ref) {
|
|
5
|
-
const thisRef = useRef({
|
|
6
|
-
props
|
|
7
|
-
});
|
|
8
|
-
const ctrl = useControl(_ref => {
|
|
9
|
-
let {
|
|
10
|
-
mapLib
|
|
11
|
-
} = _ref;
|
|
12
|
-
const gc = new mapLib.GeolocateControl(props);
|
|
13
|
-
const setupUI = gc._setupUI;
|
|
14
|
-
gc._setupUI = () => {
|
|
15
|
-
if (!gc._container.hasChildNodes()) {
|
|
16
|
-
setupUI();
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
gc.on("geolocate", e => {
|
|
20
|
-
thisRef.current.props.onGeolocate?.(e);
|
|
21
|
-
});
|
|
22
|
-
gc.on("error", e => {
|
|
23
|
-
thisRef.current.props.onError?.(e);
|
|
24
|
-
});
|
|
25
|
-
gc.on("outofmaxbounds", e => {
|
|
26
|
-
thisRef.current.props.onOutOfMaxBounds?.(e);
|
|
27
|
-
});
|
|
28
|
-
gc.on("trackuserlocationstart", e => {
|
|
29
|
-
thisRef.current.props.onTrackUserLocationStart?.(e);
|
|
30
|
-
});
|
|
31
|
-
gc.on("trackuserlocationend", e => {
|
|
32
|
-
thisRef.current.props.onTrackUserLocationEnd?.(e);
|
|
33
|
-
});
|
|
34
|
-
return gc;
|
|
35
|
-
}, {
|
|
36
|
-
position: props.position
|
|
37
|
-
});
|
|
38
|
-
thisRef.current.props = props;
|
|
39
|
-
useImperativeHandle(ref, () => ctrl, []);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
applyReactStyle(ctrl._container, props.style);
|
|
42
|
-
}, [props.style]);
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
export const GeolocateControl = memo(forwardRef(_GeolocateControl));
|
|
46
|
-
//# sourceMappingURL=geolocate-control.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geolocate-control.js","names":["useImperativeHandle","useRef","useEffect","forwardRef","memo","applyReactStyle","useControl","_GeolocateControl","props","ref","thisRef","ctrl","_ref","mapLib","gc","GeolocateControl","setupUI","_setupUI","_container","hasChildNodes","on","e","current","onGeolocate","onError","onOutOfMaxBounds","onTrackUserLocationStart","onTrackUserLocationEnd","position","style"],"sources":["../../src/components/geolocate-control.ts"],"sourcesContent":["import * as React from \"react\";\nimport {\n useImperativeHandle,\n useRef,\n useEffect,\n forwardRef,\n memo,\n} from \"react\";\nimport { applyReactStyle } from \"../utils/apply-react-style\";\nimport { useControl } from \"./use-control\";\n\nimport type {\n ControlPosition,\n GeolocateControl as GeolocateControlInstance,\n GeolocateControlOptions,\n} from \"../types/lib\";\nimport type {\n GeolocateEvent,\n GeolocateResultEvent,\n GeolocateErrorEvent,\n} from \"../types/events\";\n\nexport type GeolocateControlProps = GeolocateControlOptions & {\n /** Placement of the control relative to the map. */\n position?: ControlPosition;\n /** CSS style override, applied to the control's container */\n style?: React.CSSProperties;\n\n /** Called on each Geolocation API position update that returned as success. */\n onGeolocate?: (e: GeolocateResultEvent) => void;\n /** Called on each Geolocation API position update that returned as an error. */\n onError?: (e: GeolocateErrorEvent) => void;\n /** Called on each Geolocation API position update that returned as success but user position\n * is out of map `maxBounds`. */\n onOutOfMaxBounds?: (e: GeolocateResultEvent) => void;\n /** Called when the GeolocateControl changes to the active lock state. */\n onTrackUserLocationStart?: (e: GeolocateEvent) => void;\n /** Called when the GeolocateControl changes to the background state. */\n onTrackUserLocationEnd?: (e: GeolocateEvent) => void;\n};\n\nfunction _GeolocateControl(\n props: GeolocateControlProps,\n ref: React.Ref<GeolocateControlInstance>,\n) {\n const thisRef = useRef({ props });\n\n const ctrl = useControl(\n ({ mapLib }) => {\n const gc = new mapLib.GeolocateControl(props);\n\n // Hack: fix GeolocateControl reuse\n // When using React strict mode, the component is mounted twice.\n // GeolocateControl's UI creation is asynchronous. Removing and adding it back causes the UI to be initialized twice.\n const setupUI = gc._setupUI;\n gc._setupUI = () => {\n if (!gc._container.hasChildNodes()) {\n setupUI();\n }\n };\n\n gc.on(\"geolocate\", (e) => {\n thisRef.current.props.onGeolocate?.(e as GeolocateResultEvent);\n });\n gc.on(\"error\", (e) => {\n thisRef.current.props.onError?.(e as GeolocateErrorEvent);\n });\n gc.on(\"outofmaxbounds\", (e) => {\n thisRef.current.props.onOutOfMaxBounds?.(e as GeolocateResultEvent);\n });\n gc.on(\"trackuserlocationstart\", (e) => {\n thisRef.current.props.onTrackUserLocationStart?.(e as GeolocateEvent);\n });\n gc.on(\"trackuserlocationend\", (e) => {\n thisRef.current.props.onTrackUserLocationEnd?.(e as GeolocateEvent);\n });\n\n return gc;\n },\n { position: props.position },\n );\n\n thisRef.current.props = props;\n\n useImperativeHandle(ref, () => ctrl, []);\n\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n }, [props.style]);\n\n return null;\n}\n\nexport const GeolocateContro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;IACvE,CAAC,CAAC;IACFP,EAAE,CAACM,EAAE,CAAC,sBAAsB,EAAGC,CAAC,IAAK;MACnCX,OAAO,CAACY,OAAO,CAACd,KAAK,CAACmB,sBAAsB,GAAGN,CAAmB,CAAC;IACrE,CAAC,CAAC;IAEF,OAAOP,EAAE;EACX,CAAC,EACD;IAAEc,QAAQ,EAAEpB,KAAK,CAACoB;EAAS,CAC7B,CAAC;EAEDlB,OAAO,CAACY,OAAO,CAACd,KAAK,GAAGA,KAAK;EAE7BR,mBAAmB,CAACS,GAAG,EAAE,MAAME,IAAI,EAAE,EAAE,CAAC;EAExCT,SAAS,CAAC,MAAM;IACdG,eAAe,CAACM,IAAI,CAACO,UAAU,EAAEV,KAAK,CAACqB,KAAK,CAAC;EAC/C,CAAC,EAAE,CAACrB,KAAK,CAACqB,KAAK,CAAC,CAAC;EAEjB,OAAO,IAAI;AACb;AAEA,OAAO,MAAMd,gBAAiD,GAAGX,IAAI,CACnED,UAAU,CAACI,iBAAiB,CAC9B,CAAC","ignoreList":[]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CustomLayerInterface } from "../types/lib";
|
|
2
|
-
import type { LayerSpecification } from "../types/style-spec";
|
|
3
|
-
type OptionalId<T> = T extends {
|
|
4
|
-
id: string;
|
|
5
|
-
} ? Omit<T, "id"> & {
|
|
6
|
-
id?: string;
|
|
7
|
-
} : T;
|
|
8
|
-
type OptionalSource<T> = T extends {
|
|
9
|
-
source: string;
|
|
10
|
-
} ? Omit<T, "source"> & {
|
|
11
|
-
source?: string;
|
|
12
|
-
} : T;
|
|
13
|
-
export type LayerProps = (OptionalSource<OptionalId<LayerSpecification>> | CustomLayerInterface) & {
|
|
14
|
-
/** If set, the layer will be inserted before the specified layer */
|
|
15
|
-
beforeId?: string;
|
|
16
|
-
};
|
|
17
|
-
export declare function Layer(props: LayerProps): any;
|
|
18
|
-
export {};
|
package/dist/components/layer.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useMemo, useState, useRef } from "react";
|
|
2
|
-
import { MapContext } from "./map.js";
|
|
3
|
-
import assert from "../utils/assert.js";
|
|
4
|
-
import { deepEqual } from "../utils/deep-equal.js";
|
|
5
|
-
function updateLayer(map, id, props, prevProps) {
|
|
6
|
-
assert(props.id === prevProps.id, "layer id changed");
|
|
7
|
-
assert(props.type === prevProps.type, "layer type changed");
|
|
8
|
-
if (props.type === "custom" || prevProps.type === "custom") {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const {
|
|
12
|
-
layout = {},
|
|
13
|
-
paint = {},
|
|
14
|
-
filter,
|
|
15
|
-
minzoom,
|
|
16
|
-
maxzoom,
|
|
17
|
-
beforeId
|
|
18
|
-
} = props;
|
|
19
|
-
if (beforeId !== prevProps.beforeId) {
|
|
20
|
-
map.moveLayer(id, beforeId);
|
|
21
|
-
}
|
|
22
|
-
if (layout !== prevProps.layout) {
|
|
23
|
-
const prevLayout = prevProps.layout || {};
|
|
24
|
-
for (const key in layout) {
|
|
25
|
-
if (!deepEqual(layout[key], prevLayout[key])) {
|
|
26
|
-
map.setLayoutProperty(id, key, layout[key]);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
for (const key in prevLayout) {
|
|
30
|
-
if (!layout.hasOwnProperty(key)) {
|
|
31
|
-
map.setLayoutProperty(id, key, undefined);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
if (paint !== prevProps.paint) {
|
|
36
|
-
const prevPaint = prevProps.paint || {};
|
|
37
|
-
for (const key in paint) {
|
|
38
|
-
if (!deepEqual(paint[key], prevPaint[key])) {
|
|
39
|
-
map.setPaintProperty(id, key, paint[key]);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
for (const key in prevPaint) {
|
|
43
|
-
if (!paint.hasOwnProperty(key)) {
|
|
44
|
-
map.setPaintProperty(id, key, undefined);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (!deepEqual(filter, prevProps.filter)) {
|
|
49
|
-
map.setFilter(id, filter);
|
|
50
|
-
}
|
|
51
|
-
if (minzoom !== prevProps.minzoom || maxzoom !== prevProps.maxzoom) {
|
|
52
|
-
map.setLayerZoomRange(id, minzoom, maxzoom);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
function createLayer(map, id, props) {
|
|
56
|
-
if (map.style && map.style._loaded && (!("source" in props) || map.getSource(props.source))) {
|
|
57
|
-
const options = {
|
|
58
|
-
...props,
|
|
59
|
-
id
|
|
60
|
-
};
|
|
61
|
-
delete options.beforeId;
|
|
62
|
-
map.addLayer(options, props.beforeId);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
let layerCounter = 0;
|
|
66
|
-
export function Layer(props) {
|
|
67
|
-
const map = useContext(MapContext).map.getMap();
|
|
68
|
-
const propsRef = useRef(props);
|
|
69
|
-
const [, setStyleLoaded] = useState(0);
|
|
70
|
-
const id = useMemo(() => props.id || `jsx-layer-${layerCounter++}`, []);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (map) {
|
|
73
|
-
const forceUpdate = () => setStyleLoaded(version => version + 1);
|
|
74
|
-
map.on("styledata", forceUpdate);
|
|
75
|
-
forceUpdate();
|
|
76
|
-
return () => {
|
|
77
|
-
map.off("styledata", forceUpdate);
|
|
78
|
-
if (map.style && map.style._loaded && map.getLayer(id)) {
|
|
79
|
-
map.removeLayer(id);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return undefined;
|
|
84
|
-
}, [map]);
|
|
85
|
-
const layer = map && map.style && map.getLayer(id);
|
|
86
|
-
if (layer) {
|
|
87
|
-
try {
|
|
88
|
-
updateLayer(map, id, props, propsRef.current);
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.warn(error);
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
createLayer(map, id, props);
|
|
94
|
-
}
|
|
95
|
-
propsRef.current = props;
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=layer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layer.js","names":["useContext","useEffect","useMemo","useState","useRef","MapContext","assert","deepEqual","updateLayer","map","id","props","prevProps","type","layout","paint","filter","minzoom","maxzoom","beforeId","moveLayer","prevLayout","key","setLayoutProperty","hasOwnProperty","undefined","prevPaint","setPaintProperty","setFilter","setLayerZoomRange","createLayer","style","_loaded","getSource","source","options","addLayer","layerCounter","Layer","getMap","propsRef","setStyleLoaded","forceUpdate","version","on","off","getLayer","removeLayer","layer","current","error","console","warn"],"sources":["../../src/components/layer.ts"],"sourcesContent":["import { useContext, useEffect, useMemo, useState, useRef } from \"react\";\nimport { MapContext } from \"./map\";\nimport assert from \"../utils/assert\";\nimport { deepEqual } from \"../utils/deep-equal\";\n\nimport type { Map as MapInstance, CustomLayerInterface } from \"../types/lib\";\nimport type { LayerSpecification } from \"../types/style-spec\";\n\n// Omiting property from a union type, see\n// https://github.com/microsoft/TypeScript/issues/39556#issuecomment-656925230\ntype OptionalId<T> = T extends { id: string }\n ? Omit<T, \"id\"> & { id?: string }\n : T;\ntype OptionalSource<T> = T extends { source: string }\n ? Omit<T, \"source\"> & { source?: string }\n : T;\n\nexport type LayerProps = (\n | OptionalSource<OptionalId<LayerSpecification>>\n | CustomLayerInterface\n) & {\n /** If set, the layer will be inserted before the specified layer */\n beforeId?: string;\n};\n\n/* eslint-disable complexity, max-statements */\nfunction updateLayer(\n map: MapInstance,\n id: string,\n props: LayerProps,\n prevProps: LayerProps,\n) {\n assert(props.id === prevProps.id, \"layer id changed\");\n assert(props.type === prevProps.type, \"layer type changed\");\n\n if (props.type === \"custom\" || prevProps.type === \"custom\") {\n return;\n }\n\n // @ts-ignore filter does not exist in some Layer types\n const { layout = {}, paint = {}, filter, minzoom, maxzoom, beforeId } = props;\n\n if (beforeId !== prevProps.beforeId) {\n map.moveLayer(id, beforeId);\n }\n if (layout !== prevProps.layout) {\n const prevLayout = prevProps.layout || {};\n for (const key in layout) {\n if (!deepEqual(layout[key], prevLayout[key])) {\n map.setLayoutProperty(id, key, layout[key]);\n }\n }\n for (const key in prevLayout) {\n if (!layout.hasOwnProperty(key)) {\n map.setLayoutProperty(id, key, undefined);\n }\n }\n }\n if (paint !== prevProps.paint) {\n const prevPaint = prevProps.paint || {};\n for (const key in paint) {\n if (!deepEqual(paint[key], prevPaint[key])) {\n map.setPaintProperty(id, key, paint[key]);\n }\n }\n for (const key in prevPaint) {\n if (!paint.hasOwnProperty(key)) {\n map.setPaintProperty(id, key, undefined);\n }\n }\n }\n\n // @ts-ignore filter does not exist in some Layer types\n if (!deepEqual(filter, prevProps.filter)) {\n map.setFilter(id, filter);\n }\n if (minzoom !== prevProps.minzoom || maxzoom !== prevProps.maxzoom) {\n map.setLayerZoomRange(id, minzoom, maxzoom);\n }\n}\n\nfunction createLayer(map: MapInstance, id: string, props: LayerProps) {\n // @ts-ignore\n if (\n map.style &&\n map.style._loaded &&\n (!(\"source\" in props) || map.getSource(props.source))\n ) {\n const options: LayerProps = { ...props, id };\n delete options.beforeId;\n\n // @ts-ignore\n map.addLayer(options, props.beforeId);\n }\n}\n\n/* eslint-enable complexity, max-statements */\n\nlet layerCounter = 0;\n\nexport function Layer(props: LayerProps) {\n const map = useContext(MapContext).map.getMap();\n const propsRef = useRef(props);\n const [, setStyleLoaded] = useState(0);\n\n const id = useMemo(() => props.id || `jsx-layer-${layerCounter++}`, []);\n\n useEffect(() => {\n if (map) {\n const forceUpdate = () => setStyleLoaded((version) => version + 1);\n map.on(\"styledata\", forceUpdate);\n forceUpdate();\n\n return () => {\n map.off(\"styledata\", forceUpdate);\n // @ts-ignore\n if (map.style && map.style._loaded && map.getLayer(id)) {\n map.removeLayer(id);\n }\n };\n }\n return undefined;\n }, [map]);\n\n // @ts-ignore\n const layer = map && map.style && map.getLayer(id);\n if (layer) {\n try {\n updateLayer(map, id, props, propsRef.current);\n } catch (error) {\n console.warn(error); // eslint-disable-line\n }\n } else {\n createLayer(map, id, props);\n }\n\n // Store last rendered props\n propsRef.current = props;\n\n return null;\n}\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,QAAQ,OAAO;AAAC,SAChEC,UAAU;AAAA,OACZC,MAAM;AAAA,SACJC,SAAS;AAuBlB,SAASC,WAAWA,CAClBC,GAAgB,EAChBC,EAAU,EACVC,KAAiB,EACjBC,SAAqB,EACrB;EACAN,MAAM,CAACK,KAAK,CAACD,EAAE,KAAKE,SAAS,CAACF,EAAE,EAAE,kBAAkB,CAAC;EACrDJ,MAAM,CAACK,KAAK,CAACE,IAAI,KAAKD,SAAS,CAACC,IAAI,EAAE,oBAAoB,CAAC;EAE3D,IAAIF,KAAK,CAACE,IAAI,KAAK,QAAQ,IAAID,SAAS,CAACC,IAAI,KAAK,QAAQ,EAAE;IAC1D;EACF;EAGA,MAAM;IAAEC,MAAM,GAAG,CAAC,CAAC;IAAEC,KAAK,GAAG,CAAC,CAAC;IAAEC,MAAM;IAAEC,OAAO;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGR,KAAK;EAE7E,IAAIQ,QAAQ,KAAKP,SAAS,CAACO,QAAQ,EAAE;IACnCV,GAAG,CAACW,SAAS,CAACV,EAAE,EAAES,QAAQ,CAAC;EAC7B;EACA,IAAIL,MAAM,KAAKF,SAAS,CAACE,MAAM,EAAE;IAC/B,MAAMO,UAAU,GAAGT,SAAS,CAACE,MAAM,IAAI,CAAC,CAAC;IACzC,KAAK,MAAMQ,GAAG,IAAIR,MAAM,EAAE;MACxB,IAAI,CAACP,SAAS,CAACO,MAAM,CAACQ,GAAG,CAAC,EAAED,UAAU,CAACC,GAAG,CAAC,CAAC,EAAE;QAC5Cb,GAAG,CAACc,iBAAiB,CAACb,EAAE,EAAEY,GAAG,EAAER,MAAM,CAACQ,GAAG,CAAC,CAAC;MAC7C;IACF;IACA,KAA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EAGT,MAAMuC,KAAK,GAAGvC,GAAG,IAAIA,GAAG,CAACsB,KAAK,IAAItB,GAAG,CAACqC,QAAQ,CAACpC,EAAE,CAAC;EAClD,IAAIsC,KAAK,EAAE;IACT,IAAI;MACFxC,WAAW,CAACC,GAAG,EAAEC,EAAE,EAAEC,KAAK,EAAE6B,QAAQ,CAACS,OAAO,CAAC;IAC/C,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdC,OAAO,CAACC,IAAI,CAACF,KAAK,CAAC;IACrB;EACF,CAAC,MAAM;IACLpB,WAAW,CAACrB,GAAG,EAAEC,EAAE,EAAEC,KAAK,CAAC;EAC7B;EAGA6B,QAAQ,CAACS,OAAO,GAAGtC,KAAK;EAExB,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import type { ControlPosition, LogoControlOptions } from "../types/lib";
|
|
3
|
-
export type LogoControlProps = LogoControlOptions & {
|
|
4
|
-
/** Placement of the control relative to the map. */
|
|
5
|
-
position?: ControlPosition;
|
|
6
|
-
/** CSS style override, applied to the control's container */
|
|
7
|
-
style?: React.CSSProperties;
|
|
8
|
-
};
|
|
9
|
-
export declare const LogoControl: React.FC<LogoControlProps>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useEffect, memo } from "react";
|
|
2
|
-
import { applyReactStyle } from "../utils/apply-react-style.js";
|
|
3
|
-
import { useControl } from "./use-control.js";
|
|
4
|
-
function _LogoControl(props) {
|
|
5
|
-
const ctrl = useControl(_ref => {
|
|
6
|
-
let {
|
|
7
|
-
mapLib
|
|
8
|
-
} = _ref;
|
|
9
|
-
return new mapLib.LogoControl(props);
|
|
10
|
-
}, {
|
|
11
|
-
position: props.position
|
|
12
|
-
});
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
applyReactStyle(ctrl._container, props.style);
|
|
15
|
-
const logoElement = ctrl._container?.querySelector(".maplibregl-ctrl-logo");
|
|
16
|
-
if (logoElement) {
|
|
17
|
-
logoElement.href = "https://barikoi.com/";
|
|
18
|
-
logoElement.setAttribute("aria-label", "Barikoi logo");
|
|
19
|
-
logoElement.target = "_blank";
|
|
20
|
-
logoElement.rel = "noopener nofollow";
|
|
21
|
-
logoElement.style.cursor = "pointer";
|
|
22
|
-
logoElement.replaceWith(logoElement.cloneNode(true));
|
|
23
|
-
}
|
|
24
|
-
}, [props.style, ctrl._container]);
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
export const LogoControl = memo(_LogoControl);
|
|
28
|
-
//# sourceMappingURL=logo-control.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logo-control.js","names":["useEffect","memo","applyReactStyle","useControl","_LogoControl","props","ctrl","_ref","mapLib","LogoControl","position","_container","style","logoElement","querySelector","href","setAttribute","target","rel","cursor","replaceWith","cloneNode"],"sources":["../../src/components/logo-control.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */\nimport * as React from \"react\";\nimport { useEffect, memo } from \"react\";\nimport { applyReactStyle } from \"../utils/apply-react-style\";\nimport { useControl } from \"./use-control\";\n\nimport type { ControlPosition, LogoControlOptions } from \"../types/lib\";\n\nexport type LogoControlProps = LogoControlOptions & {\n /** Placement of the control relative to the map. */\n position?: ControlPosition;\n /** CSS style override, applied to the control's container */\n style?: React.CSSProperties;\n};\n\nfunction _LogoControl(props: LogoControlProps) {\n const ctrl = useControl(({ mapLib }) => new mapLib.LogoControl(props), {\n position: props.position,\n });\n\n useEffect(() => {\n applyReactStyle(ctrl._container, props.style);\n\n // Update the DOM structure and attributes directly\n const logoElement = ctrl._container?.querySelector(\n \".maplibregl-ctrl-logo\",\n ) as HTMLAnchorElement | null;\n if (logoElement) {\n // Update the link attributes\n logoElement.href = \"https://barikoi.com/\";\n logoElement.setAttribute(\"aria-label\", \"Barikoi logo\");\n logoElement.target = \"_blank\";\n logoElement.rel = \"noopener nofollow\";\n logoElement.style.cursor = \"pointer\";\n\n // Remove any existing click handlers\n logoElement.replaceWith(logoElement.cloneNode(true));\n }\n }, [props.style, ctrl._container]);\n\n return null;\n}\n\nexport const LogoControl: React.FC<LogoControlProps> = memo(_LogoControl);\n"],"mappings":"AAEA,SAASA,SAAS,EAAEC,IAAI,QAAQ,OAAO;AAAC,SAC/BC,eAAe;AAAA,SACfC,UAAU;AAWnB,SAASC,YAAYA,CAACC,KAAuB,EAAE;EAC7C,MAAMC,IAAI,GAAGH,UAAU,CAACI,IAAA;IAAA,IAAC;MAAEC;IAAO,CAAC,GAAAD,IAAA;IAAA,OAAK,IAAIC,MAAM,CAACC,WAAW,CAACJ,KAAK,CAAC;EAAA,GAAE;IACrEK,QAAQ,EAAEL,KAAK,CAACK;EAClB,CAAC,CAAC;EAEFV,SAAS,CAAC,MAAM;IACdE,eAAe,CAACI,IAAI,CAACK,UAAU,EAAEN,KAAK,CAACO,KAAK,CAAC;IAG7C,MAAMC,WAAW,GAAGP,IAAI,CAACK,UAAU,EAAEG,aAAa,CAChD,uBACF,CAA6B;IAC7B,IAAID,WAAW,EAAE;MAEfA,WAAW,CAACE,IAAI,GAAG,sBAAsB;MACzCF,WAAW,CAACG,YAAY,CAAC,YAAY,EAAE,cAAc,CAAC;MACtDH,WAAW,CAACI,MAAM,GAAG,QAAQ;MAC7BJ,WAAW,CAACK,GAAG,GAAG,mBAAmB;MACrCL,WAAW,CAACD,KAAK,CAACO,MAAM,GAAG,SAAS;MAGpCN,WAAW,CAACO,WAAW,CAACP,WAAW,CAACQ,SAAS,CAAC,IAAI,CAAC,CAAC;IACtD;EACF,CAAC,EAAE,CAAChB,KAAK,CAACO,KAAK,EAAEN,IAAI,CAACK,UAAU,CAAC,CAAC;EAElC,OAAO,IAAI;AACb;AAEA,OAAO,MAAMF,WAAuC,GAAGR,IAAI,CAACG,YAAY,CAAC","ignoreList":[]}
|
package/dist/components/map.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { MaplibreProps } from "../maplibre/maplibre";
|
|
3
|
-
import { MapRef } from "../maplibre/create-ref";
|
|
4
|
-
import type { CSSProperties } from "react";
|
|
5
|
-
import { GlobalSettings } from "../utils/set-globals";
|
|
6
|
-
import type { MapLib, MapOptions } from "../types/lib";
|
|
7
|
-
export type MapContextValue = {
|
|
8
|
-
mapLib: MapLib;
|
|
9
|
-
map: MapRef;
|
|
10
|
-
};
|
|
11
|
-
export declare const MapContext: React.Context<MapContextValue>;
|
|
12
|
-
type MapInitOptions = Omit<MapOptions, "style" | "container" | "bounds" | "fitBoundsOptions" | "center">;
|
|
13
|
-
export type MapProps = MapInitOptions & MaplibreProps & GlobalSettings & {
|
|
14
|
-
mapLib?: MapLib | Promise<MapLib>;
|
|
15
|
-
reuseMaps?: boolean;
|
|
16
|
-
/** Map container id */
|
|
17
|
-
id?: string;
|
|
18
|
-
/** Map container CSS style */
|
|
19
|
-
style?: CSSProperties;
|
|
20
|
-
children?: React.ReactNode;
|
|
21
|
-
/** Show Barikoi logo (default: true) */
|
|
22
|
-
showBarikoiLogo?: boolean;
|
|
23
|
-
/** Show Attribution (default: true) */
|
|
24
|
-
showAttribution?: boolean;
|
|
25
|
-
} & React.RefAttributes<MapRef>;
|
|
26
|
-
export declare const Map: React.FC<MapProps>;
|
|
27
|
-
export {};
|