@geowiki/map 0.16.9-dev.1 → 0.16.9-dev.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/index.js CHANGED
@@ -16681,11 +16681,11 @@ var import_react63 = require("react");
16681
16681
  var import_maplibre_gl = __toESM(require("maplibre-gl"));
16682
16682
  var import_MapPinIcon4 = __toESM(require("@heroicons/react/24/solid/MapPinIcon"));
16683
16683
  var import_server8 = require("react-dom/server");
16684
- var import_design_system = require("@geowiki/design-system");
16685
16684
  var import_jsx_runtime79 = require("react/jsx-runtime");
16686
16685
  var MapLibre = (0, import_react63.forwardRef)(({ baseLayers, customLayers, mapControls, sourceData }, ref) => {
16687
16686
  const mapContainer = ref;
16688
16687
  const mapRef = (0, import_react62.useRef)(null);
16688
+ console.log(customLayers);
16689
16689
  const changeMapProjection = () => {
16690
16690
  var _a;
16691
16691
  if (!mapRef.current)
@@ -16697,110 +16697,6 @@ var MapLibre = (0, import_react63.forwardRef)(({ baseLayers, customLayers, mapCo
16697
16697
  type: newProjection
16698
16698
  });
16699
16699
  };
16700
- const zoomIn = () => {
16701
- if (!mapRef.current)
16702
- return;
16703
- const map = mapRef.current;
16704
- map.zoomIn();
16705
- };
16706
- const zoomOut = () => {
16707
- if (!mapRef.current)
16708
- return;
16709
- const map = mapRef.current;
16710
- map.zoomOut();
16711
- };
16712
- function getLayersByPattern(map, pattern) {
16713
- return map.getStyle().layers.filter((layer) => pattern.test(layer.id)).map((layer) => layer.id);
16714
- }
16715
- const handleToggle = (layerId) => {
16716
- if (!mapRef.current)
16717
- return;
16718
- const map = mapRef.current;
16719
- const layers = getLayersByPattern(map, new RegExp(layerId));
16720
- layers.forEach((id) => {
16721
- const visibility = map.getLayoutProperty(id, "visibility");
16722
- const newVisibility = visibility === "none" ? "visible" : "none";
16723
- map.setLayoutProperty(id, "visibility", newVisibility);
16724
- });
16725
- };
16726
- const buildControls = (controls) => {
16727
- return controls.map((c) => {
16728
- switch (c.type) {
16729
- case "projection":
16730
- return {
16731
- id: "projection",
16732
- title: "Change Projection",
16733
- icon: import_design_system.GlobeIcon,
16734
- onClick: changeMapProjection,
16735
- position: "topright",
16736
- isOpen: true,
16737
- isDisplayOnly: false,
16738
- popoverDirection: "right",
16739
- isMobileFilter: true
16740
- };
16741
- case "zoom":
16742
- return [
16743
- {
16744
- id: "zoomIn",
16745
- icon: import_design_system.PlusIcon,
16746
- onClick: zoomIn,
16747
- position: "topright",
16748
- isOpen: true,
16749
- isDisplayOnly: false,
16750
- popoverDirection: "right",
16751
- isMobileFilter: true
16752
- },
16753
- {
16754
- id: "zoomOut",
16755
- icon: import_design_system.MinusIcon,
16756
- onClick: zoomOut,
16757
- position: "topright",
16758
- isOpen: true,
16759
- isDisplayOnly: false,
16760
- popoverDirection: "right",
16761
- isMobileFilter: true
16762
- }
16763
- ];
16764
- case "toggle_layers":
16765
- let custom_layers = customLayers == null ? void 0 : customLayers.map((l) => __spreadProps(__spreadValues({}, l), {
16766
- ontoggle: () => handleToggle(l.id)
16767
- }));
16768
- return {
16769
- id: "overlay",
16770
- icon: import_design_system.LayerGroupIcon,
16771
- panel: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
16772
- import_design_system.LayerSwitcher,
16773
- {
16774
- mapMenuItems: [
16775
- {
16776
- MapMenuItem: {},
16777
- Layers: [],
16778
- Title: ""
16779
- }
16780
- ],
16781
- customLayers: custom_layers
16782
- }
16783
- ),
16784
- position: "topleft",
16785
- isOpen: false,
16786
- isDisplayOnly: false,
16787
- popoverDirection: "right",
16788
- isMobileFilter: true
16789
- };
16790
- default:
16791
- return null;
16792
- }
16793
- }).flat();
16794
- };
16795
- const [mapControl, setMapControl] = (0, import_react62.useState)(() => buildControls(mapControls));
16796
- const toggleControl = (id) => {
16797
- setMapControl((prevControls) => prevControls.map((control) => {
16798
- if (control.id === id) {
16799
- return __spreadProps(__spreadValues({}, control), { isOpen: !control.isOpen });
16800
- }
16801
- return control;
16802
- }));
16803
- };
16804
16700
  (0, import_react62.useEffect)(() => {
16805
16701
  if (typeof mapContainer === "function")
16806
16702
  return;
@@ -16939,10 +16835,7 @@ var MapLibre = (0, import_react63.forwardRef)(({ baseLayers, customLayers, mapCo
16939
16835
  }, [sourceData, mapControls]);
16940
16836
  if (!sourceData)
16941
16837
  return;
16942
- return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "relative", style: { width: "100%", height: "100vh" }, children: [
16943
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { ref: mapContainer, className: "w-full h-full" }),
16944
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_design_system.MapControlToolbar, { controls: mapControl, onToggleControl: (id) => toggleControl(id) })
16945
- ] });
16838
+ return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "relative", style: { width: "100%", height: "100vh" }, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { ref: mapContainer, className: "w-full h-full" }) });
16946
16839
  });
16947
16840
  // Annotate the CommonJS export names for ESM import in node:
16948
16841
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -16869,16 +16869,16 @@ var WaybackTimelineMap = (props) => {
16869
16869
  };
16870
16870
 
16871
16871
  // src/Components/Map/MapLibre.tsx
16872
- import { useEffect as useEffect34, useRef as useRef16, useState as useState36 } from "react";
16872
+ import { useEffect as useEffect34, useRef as useRef16 } from "react";
16873
16873
  import { forwardRef as forwardRef5 } from "react";
16874
16874
  import maplibregl from "maplibre-gl";
16875
16875
  import MapPinIcon5 from "@heroicons/react/24/solid/MapPinIcon";
16876
16876
  import { renderToStaticMarkup } from "react-dom/server";
16877
- import { MapControlToolbar, GlobeIcon as GlobeIcon2, PlusIcon as PlusIcon3, MinusIcon as MinusIcon3, LayerGroupIcon as LayerGroupIcon5, LayerSwitcher as LayerSwitcher2 } from "@geowiki/design-system";
16878
- import { jsx as jsx79, jsxs as jsxs57 } from "react/jsx-runtime";
16877
+ import { jsx as jsx79 } from "react/jsx-runtime";
16879
16878
  var MapLibre = forwardRef5(({ baseLayers, customLayers, mapControls, sourceData }, ref) => {
16880
16879
  const mapContainer = ref;
16881
16880
  const mapRef = useRef16(null);
16881
+ console.log(customLayers);
16882
16882
  const changeMapProjection = () => {
16883
16883
  var _a;
16884
16884
  if (!mapRef.current)
@@ -16890,110 +16890,6 @@ var MapLibre = forwardRef5(({ baseLayers, customLayers, mapControls, sourceData
16890
16890
  type: newProjection
16891
16891
  });
16892
16892
  };
16893
- const zoomIn = () => {
16894
- if (!mapRef.current)
16895
- return;
16896
- const map = mapRef.current;
16897
- map.zoomIn();
16898
- };
16899
- const zoomOut = () => {
16900
- if (!mapRef.current)
16901
- return;
16902
- const map = mapRef.current;
16903
- map.zoomOut();
16904
- };
16905
- function getLayersByPattern(map, pattern) {
16906
- return map.getStyle().layers.filter((layer) => pattern.test(layer.id)).map((layer) => layer.id);
16907
- }
16908
- const handleToggle = (layerId) => {
16909
- if (!mapRef.current)
16910
- return;
16911
- const map = mapRef.current;
16912
- const layers = getLayersByPattern(map, new RegExp(layerId));
16913
- layers.forEach((id) => {
16914
- const visibility = map.getLayoutProperty(id, "visibility");
16915
- const newVisibility = visibility === "none" ? "visible" : "none";
16916
- map.setLayoutProperty(id, "visibility", newVisibility);
16917
- });
16918
- };
16919
- const buildControls = (controls) => {
16920
- return controls.map((c) => {
16921
- switch (c.type) {
16922
- case "projection":
16923
- return {
16924
- id: "projection",
16925
- title: "Change Projection",
16926
- icon: GlobeIcon2,
16927
- onClick: changeMapProjection,
16928
- position: "topright",
16929
- isOpen: true,
16930
- isDisplayOnly: false,
16931
- popoverDirection: "right",
16932
- isMobileFilter: true
16933
- };
16934
- case "zoom":
16935
- return [
16936
- {
16937
- id: "zoomIn",
16938
- icon: PlusIcon3,
16939
- onClick: zoomIn,
16940
- position: "topright",
16941
- isOpen: true,
16942
- isDisplayOnly: false,
16943
- popoverDirection: "right",
16944
- isMobileFilter: true
16945
- },
16946
- {
16947
- id: "zoomOut",
16948
- icon: MinusIcon3,
16949
- onClick: zoomOut,
16950
- position: "topright",
16951
- isOpen: true,
16952
- isDisplayOnly: false,
16953
- popoverDirection: "right",
16954
- isMobileFilter: true
16955
- }
16956
- ];
16957
- case "toggle_layers":
16958
- let custom_layers = customLayers == null ? void 0 : customLayers.map((l) => __spreadProps(__spreadValues({}, l), {
16959
- ontoggle: () => handleToggle(l.id)
16960
- }));
16961
- return {
16962
- id: "overlay",
16963
- icon: LayerGroupIcon5,
16964
- panel: /* @__PURE__ */ jsx79(
16965
- LayerSwitcher2,
16966
- {
16967
- mapMenuItems: [
16968
- {
16969
- MapMenuItem: {},
16970
- Layers: [],
16971
- Title: ""
16972
- }
16973
- ],
16974
- customLayers: custom_layers
16975
- }
16976
- ),
16977
- position: "topleft",
16978
- isOpen: false,
16979
- isDisplayOnly: false,
16980
- popoverDirection: "right",
16981
- isMobileFilter: true
16982
- };
16983
- default:
16984
- return null;
16985
- }
16986
- }).flat();
16987
- };
16988
- const [mapControl, setMapControl] = useState36(() => buildControls(mapControls));
16989
- const toggleControl = (id) => {
16990
- setMapControl((prevControls) => prevControls.map((control) => {
16991
- if (control.id === id) {
16992
- return __spreadProps(__spreadValues({}, control), { isOpen: !control.isOpen });
16993
- }
16994
- return control;
16995
- }));
16996
- };
16997
16893
  useEffect34(() => {
16998
16894
  if (typeof mapContainer === "function")
16999
16895
  return;
@@ -17132,10 +17028,7 @@ var MapLibre = forwardRef5(({ baseLayers, customLayers, mapControls, sourceData
17132
17028
  }, [sourceData, mapControls]);
17133
17029
  if (!sourceData)
17134
17030
  return;
17135
- return /* @__PURE__ */ jsxs57("div", { className: "relative", style: { width: "100%", height: "100vh" }, children: [
17136
- /* @__PURE__ */ jsx79("div", { ref: mapContainer, className: "w-full h-full" }),
17137
- /* @__PURE__ */ jsx79(MapControlToolbar, { controls: mapControl, onToggleControl: (id) => toggleControl(id) })
17138
- ] });
17031
+ return /* @__PURE__ */ jsx79("div", { className: "relative", style: { width: "100%", height: "100vh" }, children: /* @__PURE__ */ jsx79("div", { ref: mapContainer, className: "w-full h-full" }) });
17139
17032
  });
17140
17033
  export {
17141
17034
  Annotation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geowiki/map",
3
- "version": "0.16.9-dev.1",
3
+ "version": "0.16.9-dev.3",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -25,11 +25,10 @@
25
25
  "react-hotkeys-hook": "^4.5.0",
26
26
  "react-leaflet": "^4.2.1",
27
27
  "zod": "^3.25.7",
28
- "@geowiki/cms-proxy": "0.16.9-dev.1",
29
- "@geowiki/core": "0.16.9-dev.1",
30
- "@geowiki/design-system": "0.16.9-dev.1",
31
- "@geowiki/evoland-api-proxy": "0.16.9-dev.1",
32
- "@geowiki/ui": "0.16.9-dev.1"
28
+ "@geowiki/core": "0.16.9-dev.3",
29
+ "@geowiki/cms-proxy": "0.16.9-dev.3",
30
+ "@geowiki/evoland-api-proxy": "0.16.9-dev.3",
31
+ "@geowiki/ui": "0.16.9-dev.3"
33
32
  },
34
33
  "dependencies": {
35
34
  "@dnd-kit/core": "^6.3.1",
@@ -88,8 +87,8 @@
88
87
  "tailwindcss-animate": "^1.0.7",
89
88
  "tsup": "^8.0.2",
90
89
  "typescript": "5.4.2",
91
- "eslint-config-custom": "0.0.0",
92
90
  "tailwind-config": "0.0.0",
91
+ "eslint-config-custom": "0.0.0",
93
92
  "tsconfig": "0.0.0"
94
93
  },
95
94
  "scripts": {