@biodiv-platform/naksha-maplibre-draw 5.0.9 → 5.0.10
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/dist/esm/index.js +24 -14
- package/dist/index.js +24 -14
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -432,7 +432,9 @@ var MapButton = ({
|
|
|
432
432
|
style: __spreadProps(__spreadValues({}, BUTTON_STYLE), {
|
|
433
433
|
backgroundColor: disabled ? "#d3d3d3" : currentMode === mode ? "#02cf87" : "#f0f0f0",
|
|
434
434
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
435
|
-
opacity: disabled ? 0.6 : 1
|
|
435
|
+
opacity: disabled ? 0.6 : 1,
|
|
436
|
+
width: 40,
|
|
437
|
+
height: 40
|
|
436
438
|
}),
|
|
437
439
|
children: icon
|
|
438
440
|
});
|
|
@@ -573,7 +575,8 @@ function MapButtons({
|
|
|
573
575
|
backgroundColor: "rgba(255,255,255,0.9)",
|
|
574
576
|
padding: 8,
|
|
575
577
|
borderRadius: 6,
|
|
576
|
-
boxShadow: "0 2px 6px rgba(0,0,0,0.2)"
|
|
578
|
+
boxShadow: "0 2px 6px rgba(0,0,0,0.2)",
|
|
579
|
+
maxWidth: "90vw"
|
|
577
580
|
},
|
|
578
581
|
children: [
|
|
579
582
|
/* @__PURE__ */ jsx4(IconButton, {
|
|
@@ -582,8 +585,8 @@ function MapButtons({
|
|
|
582
585
|
display: "flex",
|
|
583
586
|
justifyContent: "center",
|
|
584
587
|
alignItems: "center",
|
|
585
|
-
width:
|
|
586
|
-
height:
|
|
588
|
+
width: 40,
|
|
589
|
+
height: 40,
|
|
587
590
|
padding: 0,
|
|
588
591
|
borderRadius: 4,
|
|
589
592
|
backgroundColor: "#d3d3d3"
|
|
@@ -592,7 +595,15 @@ function MapButtons({
|
|
|
592
595
|
children: expanded ? /* @__PURE__ */ jsx4(PencilCloseIcon, {}) : /* @__PURE__ */ jsx4(PencilOpenIcon, {})
|
|
593
596
|
}),
|
|
594
597
|
expanded && /* @__PURE__ */ jsx4("div", {
|
|
595
|
-
style: {
|
|
598
|
+
style: {
|
|
599
|
+
display: "grid",
|
|
600
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(40px, 1fr))",
|
|
601
|
+
gap: 6,
|
|
602
|
+
maxHeight: "200px",
|
|
603
|
+
overflowY: "auto",
|
|
604
|
+
paddingRight: 1
|
|
605
|
+
},
|
|
606
|
+
className: "custom-scrollbar",
|
|
596
607
|
children: buttons.map((btn, i) => /* @__PURE__ */ jsx4(map_button_default, {
|
|
597
608
|
icon: btn.icon,
|
|
598
609
|
mode: btn.mode,
|
|
@@ -612,7 +623,8 @@ import bbox from "@turf/bbox";
|
|
|
612
623
|
import { defaultMapStyles } from "@biodiv-platform/naksha-commons";
|
|
613
624
|
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
614
625
|
var Map = (props) => {
|
|
615
|
-
var _a;
|
|
626
|
+
var _a, _b;
|
|
627
|
+
console.info("draw map");
|
|
616
628
|
const mapRef = useRef(null);
|
|
617
629
|
const [map, setMap] = useState2();
|
|
618
630
|
const [mode, setMode] = useState2("static");
|
|
@@ -622,8 +634,8 @@ var Map = (props) => {
|
|
|
622
634
|
const [selectedMapStyleIdx, setSelectedMapStyleIdx] = useState2(
|
|
623
635
|
(props == null ? void 0 : props.mapStyle) || 0
|
|
624
636
|
);
|
|
625
|
-
const mapTile = props.mapStyles ?
|
|
626
|
-
const mapStyle = (
|
|
637
|
+
const mapTile = (_a = props.mapStyles) != null ? _a : defaultMapStyles;
|
|
638
|
+
const mapStyle = (_b = mapTile[selectedMapStyleIdx]) == null ? void 0 : _b.style;
|
|
627
639
|
const mapStyleConfig = mapTile[selectedMapStyleIdx];
|
|
628
640
|
const storedFeaturesRef = useRef([]);
|
|
629
641
|
const autoFocus = useCallback2(
|
|
@@ -640,13 +652,13 @@ var Map = (props) => {
|
|
|
640
652
|
[map]
|
|
641
653
|
);
|
|
642
654
|
useEffect2(() => {
|
|
643
|
-
var _a2,
|
|
644
|
-
if (features
|
|
655
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
656
|
+
if (features.length > 0) {
|
|
645
657
|
storedFeaturesRef.current = ensureModeProperty(features);
|
|
646
658
|
}
|
|
647
659
|
const maplibreMap = setupMaplibreMap({
|
|
648
660
|
containerId: "maplibre-map",
|
|
649
|
-
latitude: (
|
|
661
|
+
latitude: (_b2 = (_a2 = props.defaultViewState) == null ? void 0 : _a2.latitude) != null ? _b2 : 0,
|
|
650
662
|
longitude: (_d = (_c = props.defaultViewState) == null ? void 0 : _c.longitude) != null ? _d : 0,
|
|
651
663
|
zoom: (_f = (_e = props.defaultViewState) == null ? void 0 : _e.zoom) != null ? _f : 0,
|
|
652
664
|
pitch: (_h = (_g = props.defaultViewState) == null ? void 0 : _g.pitch) != null ? _h : 0,
|
|
@@ -675,7 +687,6 @@ var Map = (props) => {
|
|
|
675
687
|
try {
|
|
676
688
|
drawRef.current.stop();
|
|
677
689
|
} catch (e) {
|
|
678
|
-
console.warn("terraDraw stop failed", e);
|
|
679
690
|
}
|
|
680
691
|
drawRef.current = void 0;
|
|
681
692
|
setDraw(void 0);
|
|
@@ -707,7 +718,6 @@ var Map = (props) => {
|
|
|
707
718
|
try {
|
|
708
719
|
terraDraw.removeFeatures(toRemove);
|
|
709
720
|
} catch (e) {
|
|
710
|
-
console.warn("removeFeatures failed", e);
|
|
711
721
|
}
|
|
712
722
|
}
|
|
713
723
|
userFeatures = [lastFeature];
|
|
@@ -721,7 +731,7 @@ var Map = (props) => {
|
|
|
721
731
|
let featuresToAdd = [];
|
|
722
732
|
if (storedFeaturesRef.current.length > 0) {
|
|
723
733
|
featuresToAdd = storedFeaturesRef.current;
|
|
724
|
-
} else if (features
|
|
734
|
+
} else if (features.length > 0) {
|
|
725
735
|
featuresToAdd = ensureModeProperty(features);
|
|
726
736
|
}
|
|
727
737
|
if (!isMultiple && featuresToAdd.length > 1) {
|
package/dist/index.js
CHANGED
|
@@ -451,7 +451,9 @@ var MapButton = ({
|
|
|
451
451
|
style: __spreadProps(__spreadValues({}, BUTTON_STYLE), {
|
|
452
452
|
backgroundColor: disabled ? "#d3d3d3" : currentMode === mode ? "#02cf87" : "#f0f0f0",
|
|
453
453
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
454
|
-
opacity: disabled ? 0.6 : 1
|
|
454
|
+
opacity: disabled ? 0.6 : 1,
|
|
455
|
+
width: 40,
|
|
456
|
+
height: 40
|
|
455
457
|
}),
|
|
456
458
|
children: icon
|
|
457
459
|
});
|
|
@@ -592,7 +594,8 @@ function MapButtons({
|
|
|
592
594
|
backgroundColor: "rgba(255,255,255,0.9)",
|
|
593
595
|
padding: 8,
|
|
594
596
|
borderRadius: 6,
|
|
595
|
-
boxShadow: "0 2px 6px rgba(0,0,0,0.2)"
|
|
597
|
+
boxShadow: "0 2px 6px rgba(0,0,0,0.2)",
|
|
598
|
+
maxWidth: "90vw"
|
|
596
599
|
},
|
|
597
600
|
children: [
|
|
598
601
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconButton, {
|
|
@@ -601,8 +604,8 @@ function MapButtons({
|
|
|
601
604
|
display: "flex",
|
|
602
605
|
justifyContent: "center",
|
|
603
606
|
alignItems: "center",
|
|
604
|
-
width:
|
|
605
|
-
height:
|
|
607
|
+
width: 40,
|
|
608
|
+
height: 40,
|
|
606
609
|
padding: 0,
|
|
607
610
|
borderRadius: 4,
|
|
608
611
|
backgroundColor: "#d3d3d3"
|
|
@@ -611,7 +614,15 @@ function MapButtons({
|
|
|
611
614
|
children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PencilCloseIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PencilOpenIcon, {})
|
|
612
615
|
}),
|
|
613
616
|
expanded && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", {
|
|
614
|
-
style: {
|
|
617
|
+
style: {
|
|
618
|
+
display: "grid",
|
|
619
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(40px, 1fr))",
|
|
620
|
+
gap: 6,
|
|
621
|
+
maxHeight: "200px",
|
|
622
|
+
overflowY: "auto",
|
|
623
|
+
paddingRight: 1
|
|
624
|
+
},
|
|
625
|
+
className: "custom-scrollbar",
|
|
615
626
|
children: buttons.map((btn, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(map_button_default, {
|
|
616
627
|
icon: btn.icon,
|
|
617
628
|
mode: btn.mode,
|
|
@@ -631,7 +642,8 @@ var import_bbox = __toESM(require("@turf/bbox"));
|
|
|
631
642
|
var import_naksha_commons = require("@biodiv-platform/naksha-commons");
|
|
632
643
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
633
644
|
var Map = (props) => {
|
|
634
|
-
var _a;
|
|
645
|
+
var _a, _b;
|
|
646
|
+
console.info("draw map");
|
|
635
647
|
const mapRef = (0, import_react3.useRef)(null);
|
|
636
648
|
const [map, setMap] = (0, import_react3.useState)();
|
|
637
649
|
const [mode, setMode] = (0, import_react3.useState)("static");
|
|
@@ -641,8 +653,8 @@ var Map = (props) => {
|
|
|
641
653
|
const [selectedMapStyleIdx, setSelectedMapStyleIdx] = (0, import_react3.useState)(
|
|
642
654
|
(props == null ? void 0 : props.mapStyle) || 0
|
|
643
655
|
);
|
|
644
|
-
const mapTile = props.mapStyles ?
|
|
645
|
-
const mapStyle = (
|
|
656
|
+
const mapTile = (_a = props.mapStyles) != null ? _a : import_naksha_commons.defaultMapStyles;
|
|
657
|
+
const mapStyle = (_b = mapTile[selectedMapStyleIdx]) == null ? void 0 : _b.style;
|
|
646
658
|
const mapStyleConfig = mapTile[selectedMapStyleIdx];
|
|
647
659
|
const storedFeaturesRef = (0, import_react3.useRef)([]);
|
|
648
660
|
const autoFocus = (0, import_react3.useCallback)(
|
|
@@ -659,13 +671,13 @@ var Map = (props) => {
|
|
|
659
671
|
[map]
|
|
660
672
|
);
|
|
661
673
|
(0, import_react3.useEffect)(() => {
|
|
662
|
-
var _a2,
|
|
663
|
-
if (features
|
|
674
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
675
|
+
if (features.length > 0) {
|
|
664
676
|
storedFeaturesRef.current = ensureModeProperty(features);
|
|
665
677
|
}
|
|
666
678
|
const maplibreMap = setupMaplibreMap({
|
|
667
679
|
containerId: "maplibre-map",
|
|
668
|
-
latitude: (
|
|
680
|
+
latitude: (_b2 = (_a2 = props.defaultViewState) == null ? void 0 : _a2.latitude) != null ? _b2 : 0,
|
|
669
681
|
longitude: (_d = (_c = props.defaultViewState) == null ? void 0 : _c.longitude) != null ? _d : 0,
|
|
670
682
|
zoom: (_f = (_e = props.defaultViewState) == null ? void 0 : _e.zoom) != null ? _f : 0,
|
|
671
683
|
pitch: (_h = (_g = props.defaultViewState) == null ? void 0 : _g.pitch) != null ? _h : 0,
|
|
@@ -694,7 +706,6 @@ var Map = (props) => {
|
|
|
694
706
|
try {
|
|
695
707
|
drawRef.current.stop();
|
|
696
708
|
} catch (e) {
|
|
697
|
-
console.warn("terraDraw stop failed", e);
|
|
698
709
|
}
|
|
699
710
|
drawRef.current = void 0;
|
|
700
711
|
setDraw(void 0);
|
|
@@ -726,7 +737,6 @@ var Map = (props) => {
|
|
|
726
737
|
try {
|
|
727
738
|
terraDraw.removeFeatures(toRemove);
|
|
728
739
|
} catch (e) {
|
|
729
|
-
console.warn("removeFeatures failed", e);
|
|
730
740
|
}
|
|
731
741
|
}
|
|
732
742
|
userFeatures = [lastFeature];
|
|
@@ -740,7 +750,7 @@ var Map = (props) => {
|
|
|
740
750
|
let featuresToAdd = [];
|
|
741
751
|
if (storedFeaturesRef.current.length > 0) {
|
|
742
752
|
featuresToAdd = storedFeaturesRef.current;
|
|
743
|
-
} else if (features
|
|
753
|
+
} else if (features.length > 0) {
|
|
744
754
|
featuresToAdd = ensureModeProperty(features);
|
|
745
755
|
}
|
|
746
756
|
if (!isMultiple && featuresToAdd.length > 1) {
|