Skip to content

Commit db9f865

Browse files
committed
refactor: ♻️ refactored maplibre with terra draw
1 parent 18b5eaf commit db9f865

File tree

18 files changed

+1020
-181
lines changed

18 files changed

+1020
-181
lines changed

apps/docs/pages/examples/naksha-maplibre-draw.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import "maplibre-gl/dist/maplibre-gl.css";
2-
import "@watergis/maplibre-gl-terradraw/dist/maplibre-gl-terradraw.css";
32

43
import { NakshaMaplibreDraw } from "@biodiv-platform/naksha-maplibre-draw";
54

packages/naksha-commons/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@biodiv-platform/naksha-commons",
3-
"version": "4.4.9",
3+
"version": "5.0.0-beta.1",
44
"author": "harshzalavadiya",
55
"main": "./dist/index.js",
66
"module": "./dist/esm/index.js",

packages/naksha-components-react/package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "naksha-components-react",
3-
"version": "4.6.1-beta.12",
3+
"version": "4.6.1-beta.15",
44
"author": "harshzalavadiya",
55
"main": "./dist/index.js",
66
"module": "./dist/esm/index.js",
@@ -23,12 +23,9 @@
2323
"@biodiv-platform/eslint-preset": "4.4.9",
2424
"@biodiv-platform/naksha-gmaps-draw": "4.5.3",
2525
"@biodiv-platform/naksha-gmaps-view": "4.4.9",
26-
"@biodiv-platform/naksha-mapbox-draw": "4.4.9",
27-
"@biodiv-platform/naksha-mapbox-list": "4.5.0",
28-
"@biodiv-platform/naksha-mapbox-view": "4.4.9",
29-
"@biodiv-platform/naksha-maplibre-draw": "5.0.0",
30-
"@biodiv-platform/naksha-maplibre-layers": "5.0.0",
31-
"@biodiv-platform/naksha-maplibre-view": "5.0.0",
26+
"@biodiv-platform/naksha-maplibre-draw": "5.0.2",
27+
"@biodiv-platform/naksha-maplibre-layers": "5.0.1",
28+
"@biodiv-platform/naksha-maplibre-view": "5.0.1",
3229
"@biodiv-platform/tsconfig": "4.4.9"
3330
},
3431
"devDependencies": {
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
export * from "@biodiv-platform/naksha-commons";
22
export * from "@biodiv-platform/naksha-gmaps-draw";
33
export * from "@biodiv-platform/naksha-gmaps-view";
4-
export * from "@biodiv-platform/naksha-mapbox-draw";
5-
export * from "@biodiv-platform/naksha-mapbox-list";
6-
export * from "@biodiv-platform/naksha-mapbox-view";
74
export * from "@biodiv-platform/naksha-maplibre-draw";
85
export * from "@biodiv-platform/naksha-maplibre-layers";
96
export * from "@biodiv-platform/naksha-maplibre-view";

packages/naksha-maplibre-draw/package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@biodiv-platform/naksha-maplibre-draw",
3-
"version": "5.0.0",
3+
"version": "5.0.2",
44
"author": "harshzalavadiya",
55
"main": "./dist/index.js",
66
"module": "./dist/esm/index.js",
@@ -20,7 +20,8 @@
2020
"peerDependencies": {
2121
"maplibre-gl": "^5.7.0",
2222
"react": ">=18",
23-
"react-map-gl": "^8.0.4"
23+
"react-map-gl": "^8.0.4",
24+
"react-icons": "^5.5.0"
2425
},
2526
"devDependencies": {
2627
"@biodiv-platform/eslint-preset": "*",
@@ -31,13 +32,15 @@
3132
"react": ">=18",
3233
"react-map-gl": "^8.0.4",
3334
"tsup": "^6.1.2",
34-
"typescript": "^4.7.3"
35+
"typescript": "^4.7.3",
36+
"react-icons": "^5.5.0"
3537
},
3638
"dependencies": {
37-
"@biodiv-platform/naksha-commons": "*",
39+
"@biodiv-platform/naksha-commons": "5.0.0-beta.1",
3840
"@turf/bbox": "^6.5.0",
39-
"@watergis/maplibre-gl-terradraw": "^1.7.2",
4041
"boundingbox": "^1.4.0",
41-
"react-gbus": "^1.1.2"
42+
"react-gbus": "^1.1.2",
43+
"terra-draw": "^1.13.0",
44+
"terra-draw-maplibre-gl-adapter": "^1.1.2"
4245
}
4346
}

packages/naksha-maplibre-draw/src/components/delete-panel.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/naksha-maplibre-draw/src/components/draw-control.tsx

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from "react";
2+
import { TerraDraw } from "terra-draw";
3+
import { DeleteIcon } from "./icons";
4+
5+
const ClearButton = ({ draw }: { draw: TerraDraw }) => {
6+
if (!draw) return null;
7+
8+
return (
9+
<button
10+
onClick={() => draw.clear()}
11+
title="Delete"
12+
style={{
13+
display: "flex",
14+
justifyContent: "center",
15+
alignItems: "center",
16+
width: "30px",
17+
height: "30px",
18+
padding: "0",
19+
borderRadius: "4px",
20+
backgroundColor: "#f0f0f0",
21+
cursor: "pointer",
22+
}}
23+
>
24+
<DeleteIcon />
25+
</button>
26+
);
27+
};
28+
29+
export default ClearButton;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
export const SelectIcon = () => (
2+
<svg
3+
xmlns="http://www.w3.org/2000/svg"
4+
width="24"
5+
height="24"
6+
viewBox="0 0 24 24"
7+
fill="none"
8+
stroke="currentColor"
9+
strokeWidth="1.5"
10+
strokeLinecap="round"
11+
strokeLinejoin="round"
12+
>
13+
<path d="M12.586 12.586 19 19" />
14+
<path d="M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z" />
15+
</svg>
16+
);
17+
18+
export const PointIcon = () => (
19+
<svg
20+
xmlns="http://www.w3.org/2000/svg"
21+
width="24"
22+
height="24"
23+
viewBox="0 0 24 24"
24+
fill="none"
25+
stroke="currentColor"
26+
strokeWidth="1.5"
27+
strokeLinecap="round"
28+
strokeLinejoin="round"
29+
>
30+
<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" />
31+
<circle cx="12" cy="10" r="3" />
32+
</svg>
33+
);
34+
35+
export const LineIcon = () => (
36+
<svg
37+
width="16"
38+
height="16"
39+
viewBox="0 0 24 24"
40+
fill="none"
41+
stroke="currentColor"
42+
strokeWidth="2"
43+
>
44+
<line x1="4" y1="20" x2="20" y2="4" />
45+
</svg>
46+
);
47+
48+
export const PolygonIcon = () => (
49+
<svg
50+
width="16"
51+
height="16"
52+
viewBox="0 0 24 24"
53+
fill="none"
54+
stroke="currentColor"
55+
strokeWidth="2"
56+
>
57+
<polygon points="12,2 22,8 18,22 6,22 2,8" />
58+
</svg>
59+
);
60+
61+
export const DeleteIcon = () => (
62+
<svg
63+
width="16"
64+
height="16"
65+
viewBox="0 0 24 24"
66+
fill="none"
67+
stroke="currentColor"
68+
strokeWidth="2"
69+
>
70+
<path d="M3 6h18M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
71+
</svg>
72+
);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from "react";
2+
3+
const MapButton = ({
4+
mode,
5+
currentMode,
6+
changeMode,
7+
icon,
8+
tooltip,
9+
}: {
10+
mode: string;
11+
currentMode: string;
12+
changeMode: (mode: string) => void;
13+
icon: React.ReactNode; // icon is required
14+
tooltip?: string;
15+
}) => {
16+
return (
17+
<button
18+
onClick={() => changeMode(mode)}
19+
title={tooltip}
20+
style={{
21+
display: "flex",
22+
justifyContent: "center",
23+
alignItems: "center",
24+
width: "30px",
25+
height: "30px",
26+
padding: "0",
27+
borderRadius: "4px",
28+
// border: currentMode === mode ? "2px solid #02cf87" : "1px solid #555",
29+
backgroundColor: currentMode === mode ? "#02cf87" : "#f0f0f0",
30+
cursor: "pointer",
31+
}}
32+
>
33+
{icon}
34+
</button>
35+
);
36+
};
37+
38+
export default MapButton;

0 commit comments

Comments
 (0)