@biodiv-platform/naksha-maplibre-layers 5.0.2 → 5.0.3
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 +17 -6
- package/dist/index.js +17 -6
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -482,13 +482,14 @@ var LayersContext = createContext(
|
|
|
482
482
|
{}
|
|
483
483
|
);
|
|
484
484
|
var LayersProvider = ({ mp: _mp, children }) => {
|
|
485
|
-
var _a;
|
|
485
|
+
var _a, _b;
|
|
486
486
|
const [mp, setMP] = useState(_mp);
|
|
487
487
|
const { mapl } = useMap();
|
|
488
488
|
const [queryTerm, setQueryTerm] = useState("");
|
|
489
489
|
const queryTermDebounced = useDebounce(queryTerm, 500);
|
|
490
490
|
const styles = mp.mapStyles && mp.mapStyles.length > 0 ? mp.mapStyles : defaultMapStyles;
|
|
491
491
|
const [mapStyle, setMapStyle] = useState((_a = styles[(mp == null ? void 0 : mp.mapStyle) || 0]) == null ? void 0 : _a.style);
|
|
492
|
+
const [maxZoom, setMaxZoom] = useState((_b = styles[(mp == null ? void 0 : mp.mapStyle) || 0]) == null ? void 0 : _b.maxZoom);
|
|
492
493
|
const [selectionStyle, setSelectionStyle] = useState(
|
|
493
494
|
SELECTION_STYLE.TOP
|
|
494
495
|
);
|
|
@@ -549,7 +550,7 @@ var LayersProvider = ({ mp: _mp, children }) => {
|
|
|
549
550
|
toggleVectorLayer(layerIndex, styleIndex, false);
|
|
550
551
|
});
|
|
551
552
|
const onMapHover = (e) => __async(void 0, null, function* () {
|
|
552
|
-
var _a2,
|
|
553
|
+
var _a2, _b2, _c, _d;
|
|
553
554
|
if (!selectedLayerIds.length || !mapl)
|
|
554
555
|
return;
|
|
555
556
|
try {
|
|
@@ -558,14 +559,14 @@ var LayersProvider = ({ mp: _mp, children }) => {
|
|
|
558
559
|
layers: [lastLayerId]
|
|
559
560
|
});
|
|
560
561
|
if (feats.length) {
|
|
561
|
-
const fId = ((_a2 = feats[0]) == null ? void 0 : _a2.id) || ((_c = (
|
|
562
|
+
const fId = ((_a2 = feats[0]) == null ? void 0 : _a2.id) || ((_c = (_b2 = feats[0]) == null ? void 0 : _b2.properties) == null ? void 0 : _c[PROPERTY_ID]);
|
|
562
563
|
if (fId === (hoverFeatures == null ? void 0 : hoverFeatures.id))
|
|
563
564
|
return;
|
|
564
565
|
const layer = layers[getLayerIndexById(lastLayerId)];
|
|
565
566
|
const hoverProperties = (_d = layer == null ? void 0 : layer.data) == null ? void 0 : _d.summaryColumn.map((sc) => {
|
|
566
|
-
var _a3,
|
|
567
|
+
var _a3, _b3, _c2;
|
|
567
568
|
return [
|
|
568
|
-
((
|
|
569
|
+
((_b3 = (_a3 = layer.data) == null ? void 0 : _a3.propertyMap) == null ? void 0 : _b3[sc]) || sc,
|
|
569
570
|
(_c2 = feats[0].properties) == null ? void 0 : _c2[sc]
|
|
570
571
|
];
|
|
571
572
|
});
|
|
@@ -689,6 +690,8 @@ var LayersProvider = ({ mp: _mp, children }) => {
|
|
|
689
690
|
mapStyle,
|
|
690
691
|
featuresAtLatLng,
|
|
691
692
|
setMapStyle,
|
|
693
|
+
maxZoom,
|
|
694
|
+
setMaxZoom,
|
|
692
695
|
mapStyles: styles,
|
|
693
696
|
all: layers,
|
|
694
697
|
setAll: setLayers,
|
|
@@ -1954,7 +1957,13 @@ import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
|
1954
1957
|
function SettingsTabPanel() {
|
|
1955
1958
|
const { layer } = useLayers();
|
|
1956
1959
|
const { t } = useT9();
|
|
1957
|
-
const handleOnStyleChange = (e) =>
|
|
1960
|
+
const handleOnStyleChange = (e) => {
|
|
1961
|
+
var _a;
|
|
1962
|
+
layer.setMapStyle(e.target.value);
|
|
1963
|
+
layer.setMaxZoom(
|
|
1964
|
+
(_a = layer.mapStyles.find((ms) => ms.style === e.target.value)) == null ? void 0 : _a.maxZoom
|
|
1965
|
+
);
|
|
1966
|
+
};
|
|
1958
1967
|
return /* @__PURE__ */ jsxs14("div", {
|
|
1959
1968
|
className: tw17`w-full p-4 flex flex-col gap-4`,
|
|
1960
1969
|
children: [
|
|
@@ -2287,6 +2296,7 @@ function Map2() {
|
|
|
2287
2296
|
setCoordinates(event.lngLat);
|
|
2288
2297
|
hover.onHover(event);
|
|
2289
2298
|
};
|
|
2299
|
+
console.info("NakshaMaplibreLayers props");
|
|
2290
2300
|
return /* @__PURE__ */ jsxs18("div", {
|
|
2291
2301
|
className: tw20`h-full w-full relative bg-gray-100`,
|
|
2292
2302
|
children: [
|
|
@@ -2298,6 +2308,7 @@ function Map2() {
|
|
|
2298
2308
|
initialViewState: viewState,
|
|
2299
2309
|
style: { width: "100%", height: "100%" },
|
|
2300
2310
|
mapStyle: layer.mapStyle,
|
|
2311
|
+
maxZoom: layer.maxZoom,
|
|
2301
2312
|
onClick: onMapClick,
|
|
2302
2313
|
onMouseMove: handleOnMouseMove,
|
|
2303
2314
|
children: [
|
package/dist/index.js
CHANGED
|
@@ -503,13 +503,14 @@ var LayersContext = (0, import_react.createContext)(
|
|
|
503
503
|
{}
|
|
504
504
|
);
|
|
505
505
|
var LayersProvider = ({ mp: _mp, children }) => {
|
|
506
|
-
var _a;
|
|
506
|
+
var _a, _b;
|
|
507
507
|
const [mp, setMP] = (0, import_react.useState)(_mp);
|
|
508
508
|
const { mapl } = (0, import_maplibre.useMap)();
|
|
509
509
|
const [queryTerm, setQueryTerm] = (0, import_react.useState)("");
|
|
510
510
|
const queryTermDebounced = (0, import_naksha_commons2.useDebounce)(queryTerm, 500);
|
|
511
511
|
const styles = mp.mapStyles && mp.mapStyles.length > 0 ? mp.mapStyles : import_naksha_commons2.defaultMapStyles;
|
|
512
512
|
const [mapStyle, setMapStyle] = (0, import_react.useState)((_a = styles[(mp == null ? void 0 : mp.mapStyle) || 0]) == null ? void 0 : _a.style);
|
|
513
|
+
const [maxZoom, setMaxZoom] = (0, import_react.useState)((_b = styles[(mp == null ? void 0 : mp.mapStyle) || 0]) == null ? void 0 : _b.maxZoom);
|
|
513
514
|
const [selectionStyle, setSelectionStyle] = (0, import_react.useState)(
|
|
514
515
|
SELECTION_STYLE.TOP
|
|
515
516
|
);
|
|
@@ -570,7 +571,7 @@ var LayersProvider = ({ mp: _mp, children }) => {
|
|
|
570
571
|
toggleVectorLayer(layerIndex, styleIndex, false);
|
|
571
572
|
});
|
|
572
573
|
const onMapHover = (e) => __async(void 0, null, function* () {
|
|
573
|
-
var _a2,
|
|
574
|
+
var _a2, _b2, _c, _d;
|
|
574
575
|
if (!selectedLayerIds.length || !mapl)
|
|
575
576
|
return;
|
|
576
577
|
try {
|
|
@@ -579,14 +580,14 @@ var LayersProvider = ({ mp: _mp, children }) => {
|
|
|
579
580
|
layers: [lastLayerId]
|
|
580
581
|
});
|
|
581
582
|
if (feats.length) {
|
|
582
|
-
const fId = ((_a2 = feats[0]) == null ? void 0 : _a2.id) || ((_c = (
|
|
583
|
+
const fId = ((_a2 = feats[0]) == null ? void 0 : _a2.id) || ((_c = (_b2 = feats[0]) == null ? void 0 : _b2.properties) == null ? void 0 : _c[PROPERTY_ID]);
|
|
583
584
|
if (fId === (hoverFeatures == null ? void 0 : hoverFeatures.id))
|
|
584
585
|
return;
|
|
585
586
|
const layer = layers[getLayerIndexById(lastLayerId)];
|
|
586
587
|
const hoverProperties = (_d = layer == null ? void 0 : layer.data) == null ? void 0 : _d.summaryColumn.map((sc) => {
|
|
587
|
-
var _a3,
|
|
588
|
+
var _a3, _b3, _c2;
|
|
588
589
|
return [
|
|
589
|
-
((
|
|
590
|
+
((_b3 = (_a3 = layer.data) == null ? void 0 : _a3.propertyMap) == null ? void 0 : _b3[sc]) || sc,
|
|
590
591
|
(_c2 = feats[0].properties) == null ? void 0 : _c2[sc]
|
|
591
592
|
];
|
|
592
593
|
});
|
|
@@ -710,6 +711,8 @@ var LayersProvider = ({ mp: _mp, children }) => {
|
|
|
710
711
|
mapStyle,
|
|
711
712
|
featuresAtLatLng,
|
|
712
713
|
setMapStyle,
|
|
714
|
+
maxZoom,
|
|
715
|
+
setMaxZoom,
|
|
713
716
|
mapStyles: styles,
|
|
714
717
|
all: layers,
|
|
715
718
|
setAll: setLayers,
|
|
@@ -1975,7 +1978,13 @@ var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
|
1975
1978
|
function SettingsTabPanel() {
|
|
1976
1979
|
const { layer } = useLayers();
|
|
1977
1980
|
const { t } = (0, import_naksha_commons11.useT)();
|
|
1978
|
-
const handleOnStyleChange = (e) =>
|
|
1981
|
+
const handleOnStyleChange = (e) => {
|
|
1982
|
+
var _a;
|
|
1983
|
+
layer.setMapStyle(e.target.value);
|
|
1984
|
+
layer.setMaxZoom(
|
|
1985
|
+
(_a = layer.mapStyles.find((ms) => ms.style === e.target.value)) == null ? void 0 : _a.maxZoom
|
|
1986
|
+
);
|
|
1987
|
+
};
|
|
1979
1988
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", {
|
|
1980
1989
|
className: import_twind17.tw`w-full p-4 flex flex-col gap-4`,
|
|
1981
1990
|
children: [
|
|
@@ -2308,6 +2317,7 @@ function Map2() {
|
|
|
2308
2317
|
setCoordinates(event.lngLat);
|
|
2309
2318
|
hover.onHover(event);
|
|
2310
2319
|
};
|
|
2320
|
+
console.info("NakshaMaplibreLayers props");
|
|
2311
2321
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
|
|
2312
2322
|
className: import_twind20.tw`h-full w-full relative bg-gray-100`,
|
|
2313
2323
|
children: [
|
|
@@ -2319,6 +2329,7 @@ function Map2() {
|
|
|
2319
2329
|
initialViewState: viewState,
|
|
2320
2330
|
style: { width: "100%", height: "100%" },
|
|
2321
2331
|
mapStyle: layer.mapStyle,
|
|
2332
|
+
maxZoom: layer.maxZoom,
|
|
2322
2333
|
onClick: onMapClick,
|
|
2323
2334
|
onMouseMove: handleOnMouseMove,
|
|
2324
2335
|
children: [
|