@m4l/components 3.1.6 → 3.1.8

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.
Files changed (203) hide show
  1. package/components/mui_extended/IconButton/index.d.ts +1 -1
  2. package/components/mui_extended/MenuActions/slots/MenuActionsSlots.d.ts +2 -4
  3. package/index.js +183 -339
  4. package/node_modules-CQtkw0uG.js +7350 -0
  5. package/package.json +1 -1
  6. package/vendor-AfIOyqRr.js +24636 -0
  7. package/components/AccountPopover/index-BdnzI23R.js +0 -334
  8. package/components/AppBar/index-Dvrx1jsr.js +0 -93
  9. package/components/BaseModule/index-BQ2UIUCy.js +0 -30
  10. package/components/CommonActions/components/ActionCancel/index-DSVEMl41.js +0 -12
  11. package/components/CommonActions/components/ActionFormCancel/index-DMsGH0wx.js +0 -56
  12. package/components/CommonActions/components/ActionFormIntro/index-C8zb7R3W.js +0 -33
  13. package/components/CommonActions/components/ActionIntro/index-BNIG3KAH.js +0 -25
  14. package/components/CommonActions/components/Actions/index-90JsZTzb.js +0 -70
  15. package/components/DataGrid/constants-8L7QgBKi.js +0 -10
  16. package/components/DataGrid/formatters/ColumnBooleanFormatter/index-ZsSxUL_T.js +0 -26
  17. package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index-D-gZpvcm.js +0 -22
  18. package/components/DataGrid/formatters/ColumnDateFormatter/index-CKg8CJ6A.js +0 -19
  19. package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index-kZGiDU5k.js +0 -23
  20. package/components/DataGrid/formatters/ColumnNestedValueFormatter/index-BslXGK-A.js +0 -14
  21. package/components/DataGrid/formatters/ColumnPointsFormatter/index-BXGW2CsK.js +0 -10
  22. package/components/DataGrid/formatters/ColumnPriceFormatter/index-O11tBykn.js +0 -10
  23. package/components/DataGrid/formatters/ColumnSetCheckFormatter/index-BaCawLr1.js +0 -36
  24. package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index-Cq7a-jnE.js +0 -10
  25. package/components/DataGrid/formatters/index-iKq2iRoa.js +0 -13
  26. package/components/DataGrid/index-DGHnRo8z.js +0 -908
  27. package/components/DataGrid/subcomponents/Actions/index-BhBvobKS.js +0 -549
  28. package/components/DataGrid/subcomponents/editors/TextEditor/index-BIFm8akr.js +0 -80
  29. package/components/DragResizeWindow/index-D2jLYExo.js +0 -505
  30. package/components/DynamicFilter/constants-ByqmFATV.js +0 -31
  31. package/components/DynamicFilter/dictionary-D9Z9YGDb.js +0 -51
  32. package/components/DynamicFilter/index-CRmtRWlr.js +0 -116
  33. package/components/DynamicFilter/slots/SlotsEnum-cawFeNzx.js +0 -34
  34. package/components/DynamicFilter/slots/dynamicFilterSlots-CQiB8TmY.js +0 -151
  35. package/components/DynamicFilter/slots/index-l0sNRNKZ.js +0 -1
  36. package/components/DynamicFilter/store/index-DoIifWTk.js +0 -254
  37. package/components/DynamicFilter/subcomponents/AppliedFilterChip/index-DQESCg04.js +0 -60
  38. package/components/DynamicFilter/subcomponents/AppliedFilters/index-CGmflaoY.js +0 -26
  39. package/components/DynamicFilter/subcomponents/DynamicFilterBase/index-BfH6YHNi.js +0 -40
  40. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index-Dv3KjuYK.js +0 -129
  41. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index-BnhNICK4.js +0 -171
  42. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index-CNN6DeHY.js +0 -153
  43. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index-C2dNPFtM.js +0 -146
  44. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index-B03ahaU6.js +0 -114
  45. package/components/DynamicFilter/subcomponents/FieldTypes/index-EF7A6WnZ.js +0 -38
  46. package/components/DynamicFilter/subcomponents/FilterActions/index-CQtA2ELu.js +0 -88
  47. package/components/DynamicFilter/subcomponents/InputFilter/index-EXbXDSZA.js +0 -188
  48. package/components/DynamicFilter/subcomponents/PopoverFilter/index-BX8YCh9v.js +0 -158
  49. package/components/DynamicFilter/subcomponents/PopoverMenuFields/index-DvAYf5-a.js +0 -63
  50. package/components/FieldLabel/index-C8od8D0w.js +0 -54
  51. package/components/GridLayout/index-EPw3AYiQ.js +0 -1044
  52. package/components/GridLayout/subcomponents/Griditem/index-B8Q7iMhr.js +0 -395
  53. package/components/GridLayout/subcomponents/Responsive/index-D6BbBdVx.js +0 -348
  54. package/components/GridLayout/subcomponents/SizeProvider/index-OhbtnEN4.js +0 -71
  55. package/components/HelperText/index-sLK3dYG0.js +0 -50
  56. package/components/Icon/index-BJF_0F6d.js +0 -176
  57. package/components/Image/index-BxphCFC7.js +0 -175
  58. package/components/LanguagePopover/index-CkKie1Ph.js +0 -179
  59. package/components/LinearProgressIndeterminate/index-CTvXOPRx.js +0 -55
  60. package/components/Loadable/index-BMbi9ISF.js +0 -9
  61. package/components/LoadingError/index-BaaPhmyF.js +0 -89
  62. package/components/MFIsolationApp/index-BfHLGDcN.js +0 -169
  63. package/components/MFLoader/index-B8FmSpE7.js +0 -299
  64. package/components/ModalDialog/index-WSVr5sZr.js +0 -77
  65. package/components/NavLink/index-CKgi5l5M.js +0 -55
  66. package/components/NoItemSelected/index-BKsZKc_f.js +0 -54
  67. package/components/ObjectLogs/index-BJkjYQaa.js +0 -233
  68. package/components/PDFViewer/index-Cnbioqzo.js +0 -51
  69. package/components/Page/index-DSSwuNSp.js +0 -117
  70. package/components/PaperForm/index-C1OKDnuY.js +0 -59
  71. package/components/Period/index-DYE7Bj45.js +0 -238
  72. package/components/PrintingSystem/index-BkfHXcTV.js +0 -187
  73. package/components/PrintingSystem/subcomponents/BodyNode/index-Btg2zXVQ.js +0 -49
  74. package/components/PrintingSystem/subcomponents/ChartNode/index-GLjhqKd2.js +0 -105
  75. package/components/PrintingSystem/subcomponents/DividerNode/index-D9T1MWQd.js +0 -20
  76. package/components/PrintingSystem/subcomponents/FooterNode/index-C3LET1ZY.js +0 -49
  77. package/components/PrintingSystem/subcomponents/GridNode/index-BPz7lGvC.js +0 -74
  78. package/components/PrintingSystem/subcomponents/HeaderNode/index-DY4Yci1r.js +0 -49
  79. package/components/PrintingSystem/subcomponents/PaperNode/index-BYoGJll5.js +0 -30
  80. package/components/PrintingSystem/subcomponents/PropertyValueNode/index-vFZ5Skyl.js +0 -47
  81. package/components/PrintingSystem/subcomponents/SectionNode/index-BNqGWpcj.js +0 -49
  82. package/components/PrintingSystem/subcomponents/TextBoxNode/index-wgdfWbfF.js +0 -24
  83. package/components/PropertyValue/index-dwO3Qo0Y.js +0 -264
  84. package/components/Resizeable/index-CHseEYjL.js +0 -20
  85. package/components/ScrollBar/index-BYMy_qJE.js +0 -35
  86. package/components/ScrollToTop/index-TxORk5dB.js +0 -12
  87. package/components/SideBar/index-DqKD_S9_.js +0 -758
  88. package/components/SplitLayout/index-D4lxi0ig.js +0 -89
  89. package/components/ToastContainer/index-jnQcIcV1.js +0 -191
  90. package/components/WrapperComponent/index-BHV-CsDU.js +0 -14
  91. package/components/animate/LoadingScreen/index-CTGGa4Yt.js +0 -70
  92. package/components/animate/MotionContainer/index-eartnWyO.js +0 -34
  93. package/components/animate/MotionLazyContainer/index-Be8osTiG.js +0 -9
  94. package/components/animate/PropagateLoader/index-Bkq8V2SN.js +0 -23
  95. package/components/animate/features-BbnE33u3.js +0 -5
  96. package/components/animate/index-9dC9NmWv.js +0 -89
  97. package/components/animate/variants/bounce-DanQqHAX.js +0 -101
  98. package/components/animate/variants/container-Dmpr6tg5.js +0 -22
  99. package/components/animate/variants/fade-CAOJNn06.js +0 -65
  100. package/components/animate/variants/index-l0sNRNKZ.js +0 -1
  101. package/components/animate/variants/transition-B9W5SWTa.js +0 -20
  102. package/components/areas/components/AreasAdmin/index-BU9AX60_.js +0 -699
  103. package/components/areas/components/AreasViewer/index-CPlZxIzK.js +0 -805
  104. package/components/areas/components/index-l0sNRNKZ.js +0 -1
  105. package/components/areas/constants-rqODZNZe.js +0 -6
  106. package/components/areas/contexts/AreasContext/index-DGguLxcX.js +0 -1110
  107. package/components/areas/contexts/DynamicMFParmsContext/index-22c6E7vK.js +0 -36
  108. package/components/areas/contexts/WindowToolsMFContext/index-DkE30fhm.js +0 -12
  109. package/components/areas/contexts/index-l0sNRNKZ.js +0 -1
  110. package/components/areas/dictionary-YUsP9beq.js +0 -36
  111. package/components/areas/hooks/index-l0sNRNKZ.js +0 -1
  112. package/components/areas/hooks/useAreas/index-DBXtbtIu.js +0 -11
  113. package/components/areas/hooks/useDynamicMFParameters/index-DhbcZPs9.js +0 -12
  114. package/components/areas/hooks/useSetWindowsTitle/useSetWindowsTitle-BzPD-miW.js +0 -31
  115. package/components/areas/hooks/useWindowToolsMF/index-BECQfhbC.js +0 -10
  116. package/components/areas/icons-CwFr-alN.js +0 -24
  117. package/components/areas/index-B_Odny9h.js +0 -22
  118. package/components/commercial/AppBarCommercial/index-faX1fxjn.js +0 -28
  119. package/components/commercial/SectionCommercial/index-Dspd2Hd7.js +0 -56
  120. package/components/commercial/TopBar/index-zACdM_C0.js +0 -232
  121. package/components/commercial/index-9P0yOdH4.js +0 -81
  122. package/components/formatters/BooleanFormatter/index-PoFZ3r_m.js +0 -44
  123. package/components/formatters/DateFormatter/index-CGcRZ8BA.js +0 -43
  124. package/components/formatters/PointsFormatter/index-C7sR8iqk.js +0 -25
  125. package/components/formatters/PriceFormatter/index-CsvRawmc.js +0 -35
  126. package/components/formatters/UncertaintyFormatter/index-B9ESVEVp.js +0 -29
  127. package/components/formatters/index-CEJ6VCMb.js +0 -109
  128. package/components/hook-form/HelperError/index-DRvAkpwm.js +0 -19
  129. package/components/hook-form/RHFAutocomplete/index-DS57m8AX.js +0 -657
  130. package/components/hook-form/RHFAutocompleteAsync/index-Bu6NYmG_.js +0 -226
  131. package/components/hook-form/RHFCheckbox/index-BsB42rRc.js +0 -132
  132. package/components/hook-form/RHFColorPicker/index-Dox0FPrV.js +0 -191
  133. package/components/hook-form/RHFDateTime/index-ef19Az1N.js +0 -190
  134. package/components/hook-form/RHFMultiCheckbox/index-BARudV1A.js +0 -34
  135. package/components/hook-form/RHFPeriod/index-DyRLTD0w.js +0 -98
  136. package/components/hook-form/RHFRadioGroup/index-pgTLVF9t.js +0 -52
  137. package/components/hook-form/RHFSelect/index-LdwRuFz-.js +0 -29
  138. package/components/hook-form/RHFTextField/index-BgsElxUF.js +0 -337
  139. package/components/hook-form/RHFUpload/index-B6m3ypzh.js +0 -253
  140. package/components/maps/components/GpsTools/index-CeLi75XZ.js +0 -1948
  141. package/components/maps/components/Map/index-D4B8Lfgv.js +0 -2545
  142. package/components/maps/index-Ci-7-FHg.js +0 -7
  143. package/components/modal/WindowBase-CkftshqR.js +0 -44
  144. package/components/modal/WindowConfirm-C5YnzF-B.js +0 -73
  145. package/components/modal/index-CydPIpKZ.js +0 -65
  146. package/components/mui_extended/Accordion/index-jF2uxSmi.js +0 -124
  147. package/components/mui_extended/Avatar/index-CHmsrmfc.js +0 -64
  148. package/components/mui_extended/Badge/index-B_BGIjkQ.js +0 -29
  149. package/components/mui_extended/BoxIcon/index-BUTJ2tKw.js +0 -22
  150. package/components/mui_extended/Breadcrumbs/index-DTS7rOZH.js +0 -86
  151. package/components/mui_extended/Button/index-CgvCim_g.js +0 -222
  152. package/components/mui_extended/CheckBox-H73kpinr.js +0 -76
  153. package/components/mui_extended/CircularProgress/index-Bnnti_G6.js +0 -8
  154. package/components/mui_extended/IconButton/classes/constants-ChY2jKkp.js +0 -4
  155. package/components/mui_extended/IconButton/classes/index-BxjJGAqZ.js +0 -45
  156. package/components/mui_extended/IconButton/index-B8lOMybH.js +0 -117
  157. package/components/mui_extended/IconButton/styledIconButton-fAsbGoFS.js +0 -7
  158. package/components/mui_extended/IconButton/types-l0sNRNKZ.js +0 -1
  159. package/components/mui_extended/LinearProgress/index-CGgW8jq2.js +0 -9
  160. package/components/mui_extended/LinkWithRoute/index-BC2miUjR.js +0 -15
  161. package/components/mui_extended/MenuActions/MenuActions-DA_aS7o5.js +0 -149
  162. package/components/mui_extended/MenuActions/constants-BwsU9chA.js +0 -10
  163. package/components/mui_extended/MenuActions/dictionary-Dj_07puT.js +0 -11
  164. package/components/mui_extended/MenuActions/slots/MenuActionsEnum-Bu-L6eWU.js +0 -13
  165. package/components/mui_extended/MenuActions/slots/MenuActionsSlots-BVp0M8fu.js +0 -47
  166. package/components/mui_extended/Pager/index-Dtk4aUiU.js +0 -257
  167. package/components/mui_extended/Popover/index-Dl1PwIS2.js +0 -153
  168. package/components/mui_extended/Stack/index-CRzpVi2a.js +0 -31
  169. package/components/mui_extended/Tab/index-DmrsMLOq.js +0 -129
  170. package/components/mui_extended/ToggleButton/index-CAnHC1N-.js +0 -18
  171. package/components/mui_extended/Tooltip/index-B8QUytCK.js +0 -42
  172. package/components/mui_extended/Typography/index-DXq1fG8k.js +0 -54
  173. package/components/mui_extended/index-l0sNRNKZ.js +0 -1
  174. package/components/popups/PopupsProvider/index-DhSxmtfJ.js +0 -172
  175. package/components/popups/PopupsViewer/constants-DuyD7aCn.js +0 -4
  176. package/components/popups/PopupsViewer/icons-BUujqqbu.js +0 -7
  177. package/components/popups/PopupsViewer/index-CMI1SK_O.js +0 -172
  178. package/components/popups/PopupsViewer/slots/index-B98CiRLa.js +0 -14
  179. package/components/popups/PopupsViewer/slots/popupsViewerSlots-DOkmuvnx.js +0 -46
  180. package/components/popups/index-l0sNRNKZ.js +0 -1
  181. package/contexts/ModalContext/index-Bp_s1qUm.js +0 -39
  182. package/contexts/RHFormContext/index-BQ0XWrpK.js +0 -78
  183. package/hocs/withToggle/index-C1_DMZD3.js +0 -14
  184. package/hooks/useFormAddEdit/index-dLVQB7hC.js +0 -90
  185. package/hooks/useFormReadyForUpdate/index-B3HygFCM.js +0 -20
  186. package/hooks/useModal/index-69rbrQ0v.js +0 -10
  187. package/hooks/useSizeContainer/index-D4hDjM1P.js +0 -37
  188. package/hooks/useStateRef/index-C3P6ZK3m.js +0 -15
  189. package/hooks/useTab/index-DYRxOmMI.js +0 -12
  190. package/react-data-grid-BfYuZ6AK.js +0 -2606
  191. package/react-draggable-DsCPdgQP.js +0 -811
  192. package/react-json-view-bhqIAaNg.js +0 -2576
  193. package/react-resizable-eBbFl2dX.js +0 -618
  194. package/react-spinners-TpKN9lZg.js +0 -123
  195. package/react-splitter-layout-C-JTsNGs.js +0 -158
  196. package/styles/DynamicFilter-CJFsIegc.js +0 -319
  197. package/styles/MenuActions-lTi-ynPM.js +0 -42
  198. package/styles/index-CqpubQQr.js +0 -1691
  199. package/test/constants_no_mock-CF-669v-.js +0 -4
  200. package/test/getNameDataTestId-BaBTWhBr.js +0 -10
  201. package/utils/index-DiMrtgIu.js +0 -502
  202. /package/components/GridLayout/subcomponents/{Griditem → GridItem}/index.d.ts +0 -0
  203. /package/components/GridLayout/subcomponents/{Griditem → GridItem}/types.d.ts +0 -0
@@ -1,2545 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useMap, LayerGroup, MapContainer, Marker, Polyline, Circle, Polygon } from "react-leaflet";
3
- import { shallow } from "zustand/shallow";
4
- import React__default, { createContext, useRef, useEffect, useContext, useMemo, useState, useCallback } from "react";
5
- import * as L from "leaflet";
6
- import L__default from "leaflet";
7
- import { Loader } from "@googlemaps/js-api-loader";
8
- import { createPortal } from "react-dom";
9
- import { useModuleDictionary, useModuleSkeleton, useEnvironment, useModulePrivileges } from "@m4l/core";
10
- import clsx from "clsx";
11
- import { useFormContext, useWatch } from "react-hook-form";
12
- import { A as Actions } from "../../../CommonActions/components/Actions/index-90JsZTzb.js";
13
- import { B as Button } from "../../../mui_extended/Button/index-CgvCim_g.js";
14
- import * as Yup from "yup";
15
- import { u as useFormReadyForUpdate } from "../../../../hooks/useFormReadyForUpdate/index-B3HygFCM.js";
16
- import { R as RHFAutocompleteAsync } from "../../../hook-form/RHFAutocompleteAsync/index-Bu6NYmG_.js";
17
- import { S as Stack } from "../../../mui_extended/Stack/index-CRzpVi2a.js";
18
- import { R as RHFormProvider } from "../../../../contexts/RHFormContext/index-BQ0XWrpK.js";
19
- import { I as IconButton, T as ToggleIconButton } from "../../../mui_extended/IconButton/index-B8lOMybH.js";
20
- import { u as usePopupsStore, P as PopupsProvider } from "../../../popups/PopupsProvider/index-DhSxmtfJ.js";
21
- import { D as DataGrid } from "../../../DataGrid/index-DGHnRo8z.js";
22
- import { generateUtilityClasses, Tooltip, FormControl, RadioGroup, FormControlLabel, Radio, useTheme } from "@mui/material";
23
- import { C as ColumnSetCheckFormatter } from "../../../DataGrid/formatters/ColumnSetCheckFormatter/index-BaCawLr1.js";
24
- import { I as Icon, M as MarkerIconLabel } from "../../../Icon/index-BJF_0F6d.js";
25
- import { u as useStateRef } from "../../../../hooks/useStateRef/index-C3P6ZK3m.js";
26
- import { C as CheckBox } from "../../../mui_extended/CheckBox-H73kpinr.js";
27
- import { P as Popover } from "../../../mui_extended/Popover/index-Dl1PwIS2.js";
28
- import { P as PopupsViewer } from "../../../popups/PopupsViewer/index-CMI1SK_O.js";
29
- import { createPathComponent } from "@react-leaflet/core";
30
- import "leaflet.markercluster";
31
- import { cloneDeep, throttle } from "lodash";
32
- import { styled } from "@mui/material/styles";
33
- import "leaflet/dist/leaflet.css";
34
- import { createStore, useStore } from "zustand";
35
- import { useResponsiveDesktop, useFirstRender } from "@m4l/graphics";
36
- import { devtools } from "zustand/middleware";
37
- import { immer } from "zustand/middleware/immer";
38
- import { unstable_composeClasses } from "@mui/base";
39
- import { g as getComponentUtilityClass } from "../../../../utils/index-DiMrtgIu.js";
40
- import { b as bearingRawToCSS } from "../../index-Ci-7-FHg.js";
41
- import "leaflet-polylinedecorator";
42
- const COMPONENT_CLASS_NAME = "M4LMap";
43
- const MAP_ZINDEX_DEFAULT = 0;
44
- const MAP_ZINDEX_OVER_MAP = 1100;
45
- const TIME_DOUBLE_CLICK = 250;
46
- const MARKER_COLOR_DEFAULT = "#1E96DC";
47
- const LABEL_BK_COLOR_DEFAULT = "#1E96DC";
48
- const LABEL_COLOR_DEFAULT = "#FFFFFF";
49
- const GPS_TOOLS_POPUP_ID = "gpsTools";
50
- const GPS_TOOLS_POPUP_DEFAULT_POSITION = {
51
- vertical: { top: 50, bottom: 50 },
52
- horizontal: { right: 50, width: 380 }
53
- };
54
- const MESURE_POPUP_DEFAULT_POSITION = {
55
- vertical: { top: 50, height: 250 },
56
- horizontal: { right: 50, width: 300 }
57
- };
58
- const SVG_ICON_DEFAULT = `<svg viewBox="0 0 640 640" height="32" width="32" xmlns="http://www.w3.org/2000/svg">
59
- <g>
60
- <circle
61
- cx="320"
62
- cy="320"
63
- r="280"
64
- fill="#1E96DC"
65
- />
66
- <text
67
- x="320"
68
- y="320"
69
- font-size="320"
70
- font-family="sans-serif"
71
- fill="#FFFFFF"
72
- text-anchor="middle"
73
- alignment-baseline="central"
74
- dominant-baseline="central"
75
- >P</text>
76
- </g>
77
- </svg>`;
78
- const mapClasses = generateUtilityClasses(COMPONENT_CLASS_NAME, [
79
- /* elements */
80
- "root",
81
- //Control tools
82
- "topLeftToolsRoot",
83
- "topRigthToolsRoot",
84
- "zoomButtons",
85
- //Tipos de capas de los features
86
- "markerLayerRoot",
87
- "markerLayerIcon",
88
- "markerLayerLabel",
89
- "markerLayerLabelInner",
90
- //Etiqueta de los features
91
- "featureLabel",
92
- //Measure tool
93
- "meaureToolRoot",
94
- "measureToolFormValue",
95
- "measureToolFormValueDistance",
96
- "measureToolFormValueSymbol",
97
- "measureToolLabel",
98
- "meausureToolLabelDistance",
99
- "meausureToolLabelSymbol",
100
- //Meauser Marcas
101
- "measureMarkerRoot",
102
- "measureMarkerContainer",
103
- "measureMarkerContainerRhomb",
104
- "measureMarkerContainerSlot",
105
- "measureMarkerContainerSlotNumber",
106
- "measureLabelMarkerRoot",
107
- "measureLabelMarkerContainer",
108
- "measureLabelMarkerDistance",
109
- "measureLabelMarkerRemove",
110
- /**
111
- * Map sources
112
- */
113
- "mapSourcesPopoverRoot",
114
- "mapSourcesRoot",
115
- "mapSourcesOption",
116
- "mapSourcesOptionIconLabel",
117
- "mapSourcesOptionRoadOptions",
118
- "mapSourcesOptionRoadOptionsCheck",
119
- /**
120
- * Layers
121
- */
122
- "layersPopoverRoot",
123
- /* states or variants of elements */
124
- "active",
125
- "disabled"
126
- ]);
127
- const useMapUtilityClasses = (_ownerState) => {
128
- const slots = {
129
- root: ["root"],
130
- //Control tools
131
- topLeftToolsRoot: ["topLeftToolsRoot"],
132
- topRigthToolsRoot: ["topRigthToolsRoot"],
133
- zoomButtons: ["zoomButtons"],
134
- markerLayerRoot: ["markerLayerRoot"],
135
- markerLayerIcon: ["markerLayerIcon"],
136
- markerLayerLabel: ["markerLayerLabel"],
137
- markerLayerLabelInner: ["markerLayerLabelInner"],
138
- //Etiqueta de los features
139
- featureLabel: ["featureLabel"],
140
- /**
141
- * Measure Tool
142
- */
143
- //Measure form
144
- meaureToolRoot: ["meaureToolRoot"],
145
- measureToolFormValue: ["measureToolFormValue"],
146
- measureToolFormValueDistance: ["measureToolFormValueDistance"],
147
- measureToolFormValueSymbol: ["measureToolFormValueSymbol"],
148
- measureToolLabel: ["measureToolLabel"],
149
- meausureToolLabelDistance: ["meausureToolLabelDistance"],
150
- meausureToolLabelSymbol: ["meausureToolLabelSymbol"],
151
- //Meauser Marcas
152
- measureMarkerRoot: ["measureMarkerRoot"],
153
- measureMarkerContainer: ["measureMarkerContainer"],
154
- measureMarkerContainerRhomb: ["measureMarkerContainerRhomb"],
155
- measureMarkerContainerSlot: ["measureMarkerContainerSlot"],
156
- measureMarkerContainerSlotNumber: ["measureMarkerContainerSlotNumber"],
157
- measureLabelMarkerRoot: ["measureLabelMarkerRoot"],
158
- measureLabelMarkerContainer: ["measureLabelMarkerContainer"],
159
- measureLabelMarkerDistance: ["measureLabelMarkerDistance"],
160
- measureLabelMarkerRemove: ["measureLabelMarkerRemove"],
161
- /**
162
- * Map sources
163
- */
164
- mapSourcesPopoverRoot: ["mapSourcesPopoverRoot"],
165
- mapSourcesRoot: ["mapSourcesToolRoot"],
166
- mapSourcesOption: ["mapSourcesToolOption"],
167
- mapSourcesOptionIconLabel: ["mapSourcesToolOptionIconLabel"],
168
- mapSourcesOptionRoadOptions: ["mapSourcesToolOptionRoadOptions"],
169
- mapSourcesOptionRoadOptionsCheck: ["mapSourcesToolOptionRoadOptionsCheck"],
170
- /**
171
- * Layers
172
- */
173
- layersPopoverRoot: ["layersPopoverRoot"],
174
- /* states or variants of elements */
175
- active: ["active"],
176
- disabled: ["disabled"]
177
- };
178
- return unstable_composeClasses(slots, getComponentUtilityClass(COMPONENT_CLASS_NAME), {});
179
- };
180
- const MAP_DICCTIONARY = {
181
- /**
182
- * Generales
183
- */
184
- /**
185
- * GPSTools
186
- */
187
- LABEL_GPSTOOLS_NAME: "label_gpstools_name",
188
- LABEL_TAB_GEO: "label_tab_geo",
189
- TAB_GENERAL_CONFIG_TOOLTIP: "tab_general_config_tooltip",
190
- PAPER_GENERAL: "paper_general",
191
- LABEL_ID: "label_id",
192
- LABEL_NAME: "label_name",
193
- LABEL_GEOMETRY_TYPE: "label_geometry_type",
194
- LABEL_GEOMETRY_CIRCLE: "label_geometry_circle",
195
- LABEL_GEOMETRY_RECTANGLE: "label_geometry_rectangle",
196
- LABEL_GEOMETRY_POLYGON: "label_geometry_polygon",
197
- LABEL_DRAW: "label_draw",
198
- LABEL_FINISH: "label_finish",
199
- PAPER_CONFIG: "paper_config",
200
- LABEL_ALIAS: "label_alias",
201
- LABEL_CUSTOMER_ID: "label_customer_id",
202
- LABEL_TIME_MIN_IN_SECONDS: "label_time_min_in_seconds",
203
- LABEL_TIME_MIN_OUT_SECONDS: "label_time_min_out_seconds",
204
- TAB_STYLE_CONFIG_TOOLTIP: "tab_style_tooltip",
205
- PAPER_STROKE: "paper_stroke",
206
- LABEL_COLOR: "label_color",
207
- LABEL_OPACITY: "label_opacity",
208
- LABEL_WEIGHT: "label_weight",
209
- LABEL_DASH_ARRAY: "label_dash_array",
210
- LABEL_DASH_OFFSET: "label_dash_offset",
211
- LABEL_RADIUS: "label_radius",
212
- LABEL_LAT: "label_lat",
213
- LABEL_LON: "label_lon",
214
- LABEL_PLACE_MARKER: "label_place_marker",
215
- LABEL_FIRST_VERTEX: "label_first_vertex",
216
- LABEL_CONTINUE_LINE: "label_continue_line",
217
- LABEL_FINISH_LINE: "label_finish_line",
218
- LABEL_FINISH_POLY: "label_finish_poly",
219
- LABEL_FINISH_RECT: "label_finish_rect",
220
- LABEL_START_CIRCLE: "label_start_circle",
221
- LABEL_FINISH_CIRCLE: "label_finish_circle",
222
- LABEL_PLACE_CIRCLE_MARKER: "label_place_circle_marker",
223
- VALIDATION_GEOMETRY_REQUIRED: "validation_geometry_required",
224
- VALIDATION_FIELD_REQUIRED: "validation_field_required",
225
- VALIDATION_FIELD_TYPE_NUMBER_ERROR: "validation_field_type_number_error",
226
- LABEL_VIEW_TRANSIT_FEATURES: "label_view_crossing_features",
227
- LABEL_VIEW_INTERNAL_FEATURES: "label_view_internal_features",
228
- LABEL_CREATED_AT: "label_created_at",
229
- LABEL_UPDATED_AT: "label_updated_at",
230
- MODAL_DELETE_GEO_TITLE: "modal_delete_geo_title",
231
- MODAL_DELETE_GEO_MESSAGE: "modal_delete_geo_message",
232
- MODAL_DISABLE_GEO_TITLE: "modal_disable_geo_title",
233
- MODAL_DISABLE_MESSAGE: "modal_disable_geo_message",
234
- // Row Actions
235
- ROW_ACTION_GEO_EDIT: "row_action_geo_edit",
236
- ROW_ACTION_GEO_ENABLE: "row_action_geo_enable",
237
- ROW_ACTION_GEO_DISABLE: "row_action_geo_disable",
238
- ROW_ACTION_GEO_DELETE: "row_action_geo_delete",
239
- LABEL_TAB_MEASURE: "label_tab_measure",
240
- PAPER_MEASURE: "paper_measure",
241
- LABEL_MEASURE_START: "label_measure_start",
242
- LABEL_MEASURE_CANCEL: "label_measure_cancel",
243
- LABEL_MEASURE_DISTANCE: "label_measure_distance",
244
- LABEL_MEASURE_AREA: "label_measure_area",
245
- LABEL_MEASURE_UNIT: "label_measure_unit",
246
- LABEL_MEASURE_UNIT_BASE_KILOMETERS: "label_measure_unit_base_kilometers",
247
- LABEL_MEASURE_REMOVE_POINT: "label_measure_remove_point",
248
- /** Layers **/
249
- LABEL_LAYERS: "label_layes",
250
- LABEL_LAYER_NAME: "label_layer_name",
251
- LABEL_LAYER_VISIBLE: "label_layer_visible",
252
- LABEL_LAYER_AUTOFOCUS: "label_layer_autofocus",
253
- LABEL_LAYER_CLUSTER: "label_layer_cluster",
254
- LABEL_LAYER_DELETE: "label_layer_delete",
255
- ROW_ACTION_LAYER_DELETE: "row_action_layer_delete",
256
- /** Map Sources **/
257
- LABEL_MAP_SOURCES: "label_map_sources",
258
- LABEL_TILE_OSM: "label_tile_osm",
259
- LABEL_TILE_GOOGLE: "label_tile_google",
260
- LABEL_TILE_GOOGLE_SATELLITE: "label_tile_google_satellite",
261
- LABEL_TILE_GOOGLE_HYBRID: "label_tile_google_hybrid",
262
- LABEL_TILE_BING: "label_tile_bing"
263
- };
264
- const MAP_ICONS = {
265
- /**
266
- * Map en general
267
- */
268
- MAP_ZOOM_IN: "cmp_map_zoom_in.svg",
269
- MAP_ZOOM_OUT: "cmp_map_zoom_out.svg",
270
- /**
271
- * Map sources
272
- */
273
- MAP_SOURCES_TOOL: "cmp_map_mapsources_tool.svg",
274
- MAP_SOURCE_OSM: "cmp_map_mapsources_osm.svg",
275
- MAP_SOURCE_GOOGLE_ROADS: "cmp_map_mapsources_google.svg",
276
- MAP_SOURCE_GOOGLE_HYBRID: "cmp_map_mapsources_googlehybrid.svg",
277
- MAP_SOURCE_GOOGLE_SATELLITE: "cmp_map_mapsources_googlesatelite.svg",
278
- MAP_SOURCE_BING: "cmp_map_mapsources_bing.svg",
279
- /**
280
- * Map sources road options+
281
- */
282
- MAP_SOURCE_ROAD_TRAFFIC: "cmp_map_mapsources_layer-traffic.svg",
283
- MAP_SOURCE_ROAD_TRANSIT: "cmp_map_mapsources_layer-transit.svg",
284
- MAP_SOURCE_ROAD_BICYCLING: "cmp_map_mapsources_layer-bicycle.svg",
285
- /**
286
- * Layers
287
- */
288
- MAP_LAYERS_TOOL: "cmp_map_layers_tool.svg",
289
- MAP_LAYER_VISIBLE: "cmp_map_layers_view.svg",
290
- MAP_LAYER_AUTOFOCUS: "cmp_map_layers_zoom_fit.svg",
291
- MAP_LAYER_CLUSTER: "cmp_map_layers_cluster.svg",
292
- MAP_LAYER_DELETE: "cmp_map_layers_delete.svg",
293
- ADD: "add.svg",
294
- /** Measure Tool *
295
- *
296
- */
297
- MAP_GPS_TOOLS_TOOL: "cmp_map_gpstools_tool.svg",
298
- MAP_MEASURE_TOOL: "cmp_map_measure_tool.svg",
299
- GENERAL: "general.svg",
300
- CONFIG: "config.svg",
301
- STROKE: "stroke.svg",
302
- FILL: "fill.svg",
303
- // REFRESH: 'refresh.svg',
304
- // ENABLED: 'enabled.svg',
305
- // DISABLED: 'disabled.svg',
306
- EDIT: "edit.svg",
307
- DELETE: "delete.svg",
308
- ACTIVE: "active.svg",
309
- NAME: "name.svg"
310
- // EMAIL: 'email.svg',
311
- // USER: 'users.svg',
312
- // FIRSTNAME: 'first_name.svg',
313
- // LASTNAME: 'last_name.svg',
314
- // MAIN_PHONE: 'fixed_phone.svg',
315
- // SECONDARY_PHONE: 'fixed_phone.svg',
316
- // CREATED_AT: 'created_at.svg',
317
- // UPDATED_AT: 'updated_at.svg',
318
- // VIEW_DETAIL: 'view_detail.svg',
319
- // USERS: 'users.svg',
320
- };
321
- const TILE_LAYER_OSM = {
322
- id: "osm_roadmap",
323
- sourceType: "OSM",
324
- iconUrl: MAP_ICONS.MAP_SOURCE_OSM,
325
- mapTypeTile: "roadmap",
326
- dictionaryId: MAP_DICCTIONARY.LABEL_TILE_OSM,
327
- urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
328
- options: {
329
- minZoom: 0,
330
- maxZoom: 19,
331
- subdomains: ["a", "b", "c"],
332
- attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a>',
333
- tms: false
334
- },
335
- roadSelectedOptions: {
336
- trafficLayer: false,
337
- transitLayer: false,
338
- bicyclingLayer: false
339
- }
340
- };
341
- const TILE_LAYER_GOOGLE = {
342
- id: "google_rodmap",
343
- sourceType: "Google",
344
- iconUrl: MAP_ICONS.MAP_SOURCE_GOOGLE_ROADS,
345
- mapTypeTile: "roadmap",
346
- dictionaryId: MAP_DICCTIONARY.LABEL_TILE_GOOGLE,
347
- urlTemplate: "http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}&key=AIzaSyDfhTK9us4kuqPTeFIm89yB3uvk2_G5AMw",
348
- hasBicyclingLayer: true,
349
- hasTrafficLayer: true,
350
- hasTransitLayer: true,
351
- options: {
352
- minZoom: 0,
353
- maxZoom: 22,
354
- subdomains: ["mt0", "mt1", "mt2", "mt3"],
355
- attribution: "Map data © Google",
356
- tms: false
357
- },
358
- roadSelectedOptions: {
359
- trafficLayer: false,
360
- transitLayer: false,
361
- bicyclingLayer: false
362
- }
363
- };
364
- const TILE_LAYER_GOOGLE_SATELLITE = {
365
- id: "google_satellite",
366
- sourceType: "Google",
367
- iconUrl: MAP_ICONS.MAP_SOURCE_GOOGLE_SATELLITE,
368
- mapTypeTile: "satellite",
369
- dictionaryId: MAP_DICCTIONARY.LABEL_TILE_GOOGLE_SATELLITE,
370
- urlTemplate: "http://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}&key=AIzaSyDfhTK9us4kuqPTeFIm89yB3uvk2_G5AMw",
371
- options: {
372
- minZoom: 0,
373
- maxZoom: 22,
374
- subdomains: ["mt0", "mt1", "mt2", "mt3"],
375
- attribution: "Map data © Google",
376
- tms: false
377
- },
378
- roadSelectedOptions: {
379
- trafficLayer: false,
380
- transitLayer: false,
381
- bicyclingLayer: false
382
- }
383
- };
384
- const TILE_LAYER_GOOGLE_HYBRID = {
385
- id: "google_hybrid",
386
- sourceType: "Google",
387
- iconUrl: MAP_ICONS.MAP_SOURCE_GOOGLE_HYBRID,
388
- mapTypeTile: "hybrid",
389
- dictionaryId: MAP_DICCTIONARY.LABEL_TILE_GOOGLE_HYBRID,
390
- urlTemplate: "http://{s}.google.com/vt/lyrs=y&x={x}&y={y}&z={z}&key=AIzaSyDfhTK9us4kuqPTeFIm89yB3uvk2_G5AMw",
391
- hasBicyclingLayer: true,
392
- hasTrafficLayer: true,
393
- hasTransitLayer: true,
394
- options: {
395
- minZoom: 0,
396
- maxZoom: 22,
397
- subdomains: ["mt0", "mt1", "mt2", "mt3"],
398
- attribution: "Map data © Google",
399
- tms: false
400
- },
401
- roadSelectedOptions: {
402
- trafficLayer: false,
403
- transitLayer: false,
404
- bicyclingLayer: false
405
- }
406
- };
407
- function toQuadKey(x, y, z) {
408
- let quadKey = "";
409
- for (let i = z; i > 0; i--) {
410
- let digit = 0;
411
- const mask = 1 << i - 1;
412
- if ((x & mask) !== 0) {
413
- digit++;
414
- }
415
- if ((y & mask) !== 0) {
416
- digit++;
417
- digit++;
418
- }
419
- quadKey += digit.toString();
420
- }
421
- return quadKey;
422
- }
423
- const BING_URL_TEMPLATE = "https://{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/|QK|?mkt=en-us&it=G,VE,BX,L,LA&shading=hill&og=22&n=z";
424
- const BING_SUB_DOMAINS = ["t2", "t3"];
425
- const TILE_LAYER_BING = {
426
- id: "bing_rodmap",
427
- sourceType: "Bing",
428
- mapTypeTile: "roadmap",
429
- dictionaryId: MAP_DICCTIONARY.LABEL_TILE_BING,
430
- iconUrl: MAP_ICONS.MAP_SOURCE_BING,
431
- urlTemplate: BING_URL_TEMPLATE,
432
- options: {
433
- minZoom: 0,
434
- maxZoom: 21,
435
- subdomains: BING_SUB_DOMAINS,
436
- attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a>',
437
- tms: true
438
- },
439
- roadSelectedOptions: {
440
- trafficLayer: false,
441
- transitLayer: false,
442
- bicyclingLayer: false
443
- },
444
- getTileUrl: (tileCoord) => {
445
- const i = Math.abs(tileCoord.x + tileCoord.y) % BING_SUB_DOMAINS.length;
446
- const z = tileCoord.z;
447
- const x = tileCoord.x;
448
- const y = tileCoord.y;
449
- const gk = toQuadKey(x, y, z);
450
- return BING_URL_TEMPLATE.replace("|QK|", gk).replace("{s}", BING_SUB_DOMAINS[i]);
451
- }
452
- };
453
- const createMapStore = (initProps) => {
454
- const startProps = {
455
- classes: useMapUtilityClasses(initProps.ownerState),
456
- visibleCheckedLayers: /* @__PURE__ */ new Set(),
457
- autoFocusCheckedLayers: /* @__PURE__ */ new Set(),
458
- clusterCheckedLayers: /* @__PURE__ */ new Set(),
459
- currentMapSourceId: "",
460
- hashMapSources: {},
461
- mapSourcesIds: [],
462
- layersIds: [],
463
- hashLayers: {},
464
- ...initProps
465
- };
466
- return createStore(
467
- devtools(
468
- immer((set, get) => ({
469
- ...startProps,
470
- mapActions: {
471
- init: (layersStore) => {
472
- set((state) => {
473
- state.hashMapSources = {
474
- osm_roadmap: TILE_LAYER_OSM,
475
- google_rodmap: TILE_LAYER_GOOGLE,
476
- google_satellite: TILE_LAYER_GOOGLE_SATELLITE,
477
- google_hybrid: TILE_LAYER_GOOGLE_HYBRID,
478
- bing_rodmap: TILE_LAYER_BING
479
- };
480
- state.mapSourcesIds = [
481
- "osm_roadmap",
482
- "google_rodmap",
483
- "google_satellite",
484
- "google_hybrid",
485
- "bing_rodmap"
486
- ];
487
- state.currentMapSourceId = "osm_roadmap";
488
- for (let index = 0; index < layersStore.length; index++) {
489
- state.hashLayers[layersStore[index].layerId] = cloneDeep(layersStore[index]);
490
- state.layersIds.push(layersStore[index].layerId);
491
- if (layersStore[index].visible !== false) {
492
- state.visibleCheckedLayers.add(layersStore[index].layerId);
493
- }
494
- if (state.hashLayers[layersStore[index].layerId].autoFocus !== false) {
495
- state.autoFocusCheckedLayers.add(layersStore[index].layerId);
496
- }
497
- if (state.hashLayers[layersStore[index].layerId].cluster !== false) {
498
- state.clusterCheckedLayers.add(layersStore[index].layerId);
499
- }
500
- }
501
- });
502
- },
503
- setMapState: (status) => {
504
- set((state) => {
505
- state.ownerState.status = status;
506
- });
507
- },
508
- // isEqualsMapProperties: (_newMapProperties: MapProperties) => {
509
- // // if (get().mapProperties === undefined) {
510
- // // return false;
511
- // // }
512
- // // return (
513
- // // JSON.stringify(get().mapProperties) === JSON.stringify(newMapProperties)
514
- // // );
515
- // return false;
516
- // },
517
- // setMapProperties: (newMapProperties: MapProperties) => {
518
- // if (!get().mapActions.isEqualsMapProperties(newMapProperties)) {
519
- // set(state => {
520
- // state.mapProperties = newMapProperties;
521
- // if (state.ownerState.status === 'init') {
522
- // state.ownerState.status = 'ready';
523
- // updateOwnerStateClasses(state);
524
- // }
525
- // });
526
- // }
527
- // },
528
- // setAllFeaturesDataLayer: (layerId: string, value: AllFeaturesDatalLayer) => {
529
- // set(state => {
530
- // // if (
531
- // // value.geometry === 'multipoints' &&
532
- // // state.hashLayers[layerId].geometry === value.geometry
533
- // // ) {
534
- // // (
535
- // // state.hashLayers[layerId] as WritableDraft<LayerMultiPointProps>
536
- // // ).hashFeatures = cloneDeep(value.hashFeatures); // Valor puro
537
- // // }
538
- // // if (
539
- // // value.geometry === 'multilines' &&
540
- // // state.hashLayers[layerId].geometry === value.geometry
541
- // // ) {
542
- // // (
543
- // // state.hashLayers[layerId] as WritableDraft<LayerMultiLineProps>
544
- // // ).hashFeatures = cloneDeep(value.hashFeatures);
545
- // // }
546
- // });
547
- // },
548
- setDataLayer: (layerId, geoJson) => {
549
- if (!get().hashLayers[layerId]) {
550
- throw new Error(`Layer with id ${layerId} not found`);
551
- }
552
- set((state) => {
553
- const layer = state.hashLayers[layerId];
554
- layer.geoJsonObject = geoJson;
555
- });
556
- },
557
- getFeatureIds: (layerId) => {
558
- if (!get().hashLayers[layerId]) {
559
- throw new Error(`Layer with id ${layerId} not found`);
560
- }
561
- const geoJsonObject = get().hashLayers[layerId]?.geoJsonObject;
562
- if (geoJsonObject && geoJsonObject.object.type === "Feature") {
563
- return [geoJsonObject.object.id];
564
- } else if (geoJsonObject && geoJsonObject.object.type === "FeatureCollection") {
565
- return geoJsonObject.object.features.map((feature) => feature.id);
566
- }
567
- return [];
568
- },
569
- setFeatureData: (layerId, featureId, geometry, properties, featureLabel) => {
570
- if (!get().hashLayers[layerId]) {
571
- throw new Error(`Layer with id ${layerId} not found`);
572
- }
573
- set((state) => {
574
- if (state.hashLayers[layerId].geoJsonObject?.object.type === "FeatureCollection") {
575
- const layer = state.hashLayers[layerId].geoJsonObject?.object;
576
- let feature = layer.features.find((f) => f.id === featureId);
577
- if (feature) {
578
- feature.geometry = cloneDeep(geometry);
579
- feature.properties = { ...feature.properties, ...properties };
580
- feature.featureLabel = featureLabel;
581
- } else {
582
- feature = {
583
- type: "Feature",
584
- geometry,
585
- id: featureId,
586
- properties,
587
- featureLabel
588
- };
589
- layer.features.push(feature);
590
- }
591
- } else if (state.hashLayers[layerId].geoJsonObject?.object.type === "Feature") {
592
- const feature = state.hashLayers[layerId].geoJsonObject?.object;
593
- feature.id = featureId;
594
- feature.geometry = cloneDeep(geometry);
595
- feature.properties = cloneDeep(properties);
596
- }
597
- });
598
- },
599
- removeFeature: (layerId, featureId) => {
600
- if (!get().hashLayers[layerId]) {
601
- throw new Error(`Layer with id ${layerId} not found`);
602
- }
603
- set((state) => {
604
- if (state.hashLayers[layerId].geoJsonObject?.object.type === "FeatureCollection") {
605
- const layer = state.hashLayers[layerId].geoJsonObject?.object;
606
- const index = layer.features.findIndex((f) => f.id === featureId);
607
- if (index !== -1) {
608
- layer.features.splice(index, 1);
609
- }
610
- } else if (state.hashLayers[layerId].geoJsonObject?.object.type === "Feature") {
611
- const feature = state.hashLayers[layerId].geoJsonObject?.object;
612
- feature.geometry = { type: "Point", coordinates: [0, 0] };
613
- feature.properties = { subType: "Marker" };
614
- }
615
- });
616
- },
617
- setLayerRenderProp: (layerId, renderProp) => {
618
- set((state) => {
619
- state.hashLayers[layerId].renderFeature = renderProp;
620
- });
621
- },
622
- addLayer: (layer) => {
623
- if (get().hashLayers[layer.layerId]) {
624
- throw new Error(`Layer with id ${layer.layerId} already exists`);
625
- }
626
- set((state) => {
627
- state.hashLayers[layer.layerId] = layer;
628
- state.layersIds.push(layer.layerId);
629
- if (layer.visible !== false) {
630
- state.hashLayers[layer.layerId].visible = true;
631
- state.visibleCheckedLayers.add(layer.layerId);
632
- }
633
- if (layer.autoFocus !== false) {
634
- state.hashLayers[layer.layerId].autoFocus = true;
635
- state.autoFocusCheckedLayers.add(layer.layerId);
636
- }
637
- if (layer.clusterAble && layer.cluster !== false) {
638
- state.hashLayers[layer.layerId].cluster = true;
639
- state.clusterCheckedLayers.add(layer.layerId);
640
- }
641
- });
642
- },
643
- addLayerDataToFeature: (layerId, featureId, layerData) => {
644
- set((state) => {
645
- if (state.hashLayers[layerId]) {
646
- if (state.hashLayers[layerId].geoJsonObject?.object.type === "FeatureCollection") {
647
- const layer = state.hashLayers[layerId].geoJsonObject?.object;
648
- const feature = layer.features.find(
649
- (currentFeature) => currentFeature.id === featureId
650
- );
651
- if (feature) {
652
- feature.layerData = layerData;
653
- }
654
- } else if (state.hashLayers[layerId].geoJsonObject?.object.type === "Feature") {
655
- const feature = state.hashLayers[layerId].geoJsonObject?.object;
656
- if (feature.layerData) {
657
- feature.layerData = layerData;
658
- }
659
- }
660
- }
661
- });
662
- },
663
- removeLayer: (layerId) => {
664
- if (!get().hashLayers[layerId]) {
665
- return;
666
- }
667
- set((state) => {
668
- if (!state.hashLayers[layerId].visible) {
669
- state.visibleCheckedLayers.delete(layerId);
670
- state.autoFocusCheckedLayers.delete(layerId);
671
- }
672
- state.layersIds.splice(state.layersIds.indexOf(layerId), 1);
673
- delete state.hashLayers[layerId];
674
- });
675
- },
676
- // removeLefletLayerToFeature: (layerId, featureId ) => {
677
- // set(state => {
678
- // //se pon si existe, porque cuando se borran las capas, ya no hay forma
679
- // if (state.hashLayers[layerId]){
680
- // if (
681
- // state.hashLayers[layerId].geoJsonObject?.object.type ===
682
- // 'FeatureCollection'
683
- // ) {
684
- // //Remove feature from featureCollection
685
- // const layer = state.hashLayers[layerId].geoJsonObject
686
- // ?.object as FeatureCollection;
687
- // const index = layer.features.findIndex(f => f.id === featureId);
688
- // if (index !== -1) {
689
- // layer.features[index].layerData = undefined;
690
- // }
691
- // } else if (
692
- // state.hashLayers[layerId].geoJsonObject?.object.type === 'Feature'
693
- // ) {
694
- // const feature = state.hashLayers[layerId].geoJsonObject
695
- // ?.object as Feature;
696
- // feature.layerData = undefined;
697
- // }
698
- // }
699
- // });
700
- // },
701
- setCheckedLayers: (checkedNameSet, newCheckedSet) => {
702
- set((state) => {
703
- state[`${checkedNameSet}CheckedLayers`] = new Set(newCheckedSet);
704
- for (const layerId in state.hashLayers) {
705
- state.hashLayers[layerId][checkedNameSet] = newCheckedSet.has(layerId);
706
- }
707
- });
708
- },
709
- setCurrentMapSource: (newId) => {
710
- set((state) => {
711
- if (newId in state.hashMapSources) {
712
- state.currentMapSourceId = newId;
713
- }
714
- });
715
- },
716
- setMapSourceRoadOptions: (partialRoadOptions) => {
717
- set((state) => {
718
- if (!state.hashMapSources[state.currentMapSourceId]) {
719
- return;
720
- }
721
- state.hashMapSources[state.currentMapSourceId].roadSelectedOptions = {
722
- bicyclingLayer: state.hashMapSources[state.currentMapSourceId]?.roadSelectedOptions?.bicyclingLayer || false,
723
- trafficLayer: state.hashMapSources[state.currentMapSourceId]?.roadSelectedOptions?.trafficLayer || false,
724
- transitLayer: state.hashMapSources[state.currentMapSourceId]?.roadSelectedOptions?.transitLayer || false,
725
- ...partialRoadOptions
726
- };
727
- });
728
- },
729
- setHandlerGetLabel: (newHandler) => {
730
- set((state) => {
731
- state.getLabel = newHandler;
732
- });
733
- },
734
- setExternalState: (newExternalState) => {
735
- set((state) => {
736
- state.ownerState = { ...state.ownerState, ...newExternalState };
737
- });
738
- }
739
- }
740
- })),
741
- { name: `Map store` }
742
- )
743
- );
744
- };
745
- const MapContext = createContext(null);
746
- function MapProvider(props) {
747
- const { children, initialLayers, googleApiKey: apiKey, googleMapVersion = "weekly" } = props;
748
- const { getLabel } = useModuleDictionary();
749
- const isDesktop = useResponsiveDesktop();
750
- const isSkeleton = useModuleSkeleton();
751
- const isFirstRender = useFirstRender([getLabel]);
752
- const mapStoreRef = useRef();
753
- if (!mapStoreRef.current) {
754
- mapStoreRef.current = createMapStore({
755
- getLabel,
756
- ownerState: {
757
- status: "init",
758
- isMobile: !isDesktop,
759
- isSkeleton,
760
- focus: false
761
- },
762
- googleApiKey: apiKey,
763
- googleMapVersion
764
- });
765
- mapStoreRef.current?.getState().mapActions.init(initialLayers || []);
766
- }
767
- const { setHandlerGetLabel, setExternalState } = useStore(
768
- mapStoreRef.current,
769
- (state) => state.mapActions,
770
- shallow
771
- );
772
- useEffect(() => {
773
- if (!isFirstRender) {
774
- setHandlerGetLabel(getLabel);
775
- }
776
- }, [getLabel]);
777
- useEffect(() => {
778
- if (isFirstRender) {
779
- return;
780
- }
781
- setExternalState({ isMobile: !isDesktop, isSkeleton });
782
- }, [isDesktop, isSkeleton]);
783
- return /* @__PURE__ */ jsx(MapContext.Provider, { value: mapStoreRef.current, children });
784
- }
785
- function useMapStore(selector, equalityFn) {
786
- const context = useContext(MapContext);
787
- if (!context) throw new Error("useMapStore context must be use inside MapContext");
788
- return useStore(context, selector, equalityFn);
789
- }
790
- const TileLayerOthers = () => {
791
- const map = useMap();
792
- const { urlTemplate, dictionaryId, options, getTileUrl, sourceType } = useMapStore(
793
- (state) => state.hashMapSources[state.currentMapSourceId],
794
- shallow
795
- );
796
- useEffect(() => {
797
- let layer;
798
- if (sourceType === "Google") {
799
- return;
800
- }
801
- layer = L__default.tileLayer(urlTemplate, options);
802
- if (getTileUrl) {
803
- layer.getTileUrl = getTileUrl;
804
- }
805
- map.addLayer(layer);
806
- if (options && options.maxZoom) {
807
- map.setMaxZoom(options.maxZoom);
808
- }
809
- return () => {
810
- if (layer) {
811
- map.removeLayer(layer);
812
- }
813
- };
814
- }, [dictionaryId, urlTemplate, options, getTileUrl, sourceType]);
815
- return null;
816
- };
817
- function TileLayerGoogle() {
818
- const map = useMap();
819
- const mutantRefLayer = React__default.useRef(null);
820
- const { options, sourceType, mapTypeTile } = useMapStore(
821
- (state) => state.hashMapSources[state.currentMapSourceId],
822
- shallow
823
- );
824
- const roadOptions = useMapStore(
825
- (state) => state.hashMapSources[state.currentMapSourceId].roadSelectedOptions,
826
- shallow
827
- );
828
- const [googleApiKey, googleMapVersion] = useMapStore(
829
- (state) => [state.googleApiKey, state.googleMapVersion],
830
- shallow
831
- );
832
- React__default.useEffect(() => {
833
- if (sourceType !== "Google") {
834
- return;
835
- }
836
- let googleMutantLayer;
837
- const loader = new Loader({
838
- apiKey: googleApiKey,
839
- version: googleMapVersion
840
- });
841
- loader.importLibrary("maps").then(() => {
842
- googleMutantLayer = L__default.gridLayer.googleMutant({
843
- type: mapTypeTile,
844
- // map type, can be 'roadmap', 'satellite', etc.
845
- maxZoom: 20,
846
- // styles: [
847
- // // Google Maps styles array, can be generated here: https://mapstyle.withgoogle.coxm/
848
- // ],
849
- ...options
850
- });
851
- mutantRefLayer.current = googleMutantLayer;
852
- if (roadOptions.trafficLayer) {
853
- googleMutantLayer.addGoogleLayer("TrafficLayer");
854
- }
855
- if (roadOptions.transitLayer) {
856
- googleMutantLayer.addGoogleLayer("TransitLayer");
857
- }
858
- if (roadOptions.bicyclingLayer) {
859
- googleMutantLayer.addGoogleLayer("BicyclingLayer");
860
- }
861
- map.addLayer(googleMutantLayer);
862
- });
863
- return () => {
864
- if (googleMutantLayer) {
865
- map.removeLayer(googleMutantLayer);
866
- mutantRefLayer.current = null;
867
- }
868
- };
869
- }, [map, sourceType, mapTypeTile]);
870
- React__default.useEffect(() => {
871
- if (sourceType !== "Google") {
872
- return;
873
- }
874
- if (mutantRefLayer.current && roadOptions) {
875
- if (roadOptions.trafficLayer) {
876
- mutantRefLayer.current.addGoogleLayer("TrafficLayer");
877
- } else if (roadOptions.trafficLayer === false) {
878
- mutantRefLayer.current.removeGoogleLayer("TrafficLayer");
879
- }
880
- }
881
- }, [roadOptions.trafficLayer]);
882
- React__default.useEffect(() => {
883
- if (sourceType !== "Google") {
884
- return;
885
- }
886
- if (mutantRefLayer.current && roadOptions) {
887
- if (roadOptions.transitLayer) {
888
- mutantRefLayer.current.addGoogleLayer("TransitLayer");
889
- } else if (roadOptions.transitLayer === false) {
890
- mutantRefLayer.current.removeGoogleLayer("TransitLayer");
891
- }
892
- }
893
- }, [roadOptions.transitLayer]);
894
- React__default.useEffect(() => {
895
- if (sourceType !== "Google") {
896
- return;
897
- }
898
- if (mutantRefLayer.current && roadOptions) {
899
- if (roadOptions.bicyclingLayer) {
900
- mutantRefLayer.current.addGoogleLayer("BicyclingLayer");
901
- } else if (roadOptions.bicyclingLayer === false) {
902
- mutantRefLayer.current.removeGoogleLayer("BicyclingLayer");
903
- }
904
- }
905
- }, [roadOptions.bicyclingLayer]);
906
- return null;
907
- }
908
- function TileLayers() {
909
- return /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
910
- /* @__PURE__ */ jsx(TileLayerOthers, {}),
911
- /* @__PURE__ */ jsx(TileLayerGoogle, {})
912
- ] });
913
- }
914
- const POSITION_CLASSES = {
915
- bottomleft: "leaflet-bottom leaflet-left",
916
- bottomright: "leaflet-bottom leaflet-right",
917
- topleft: "leaflet-top leaflet-left",
918
- topright: "leaflet-top leaflet-right"
919
- };
920
- const Control = (props) => {
921
- const [portalRoot, setPortalRoot] = React__default.useState(document.createElement("div"));
922
- const positionClass = props.position && POSITION_CLASSES[props.position] || POSITION_CLASSES.topright;
923
- const controlContainerRef = React__default.createRef();
924
- const map = useMap();
925
- React__default.useEffect(() => {
926
- if (controlContainerRef.current !== null) {
927
- L__default.DomEvent.disableClickPropagation(controlContainerRef.current);
928
- L__default.DomEvent.disableScrollPropagation(controlContainerRef.current);
929
- }
930
- }, [controlContainerRef]);
931
- React__default.useEffect(() => {
932
- const mapContainer = map.getContainer();
933
- const targetDiv = mapContainer.getElementsByClassName(positionClass);
934
- setPortalRoot(targetDiv[0]);
935
- }, [positionClass]);
936
- React__default.useEffect(() => {
937
- if (portalRoot !== null) {
938
- if (props.prepend !== void 0 && props.prepend === true) {
939
- portalRoot.prepend(controlContainerRef.current);
940
- } else {
941
- portalRoot.append(controlContainerRef.current);
942
- }
943
- }
944
- }, [portalRoot, props.prepend, controlContainerRef]);
945
- const className = clsx(props.container?.className, "leaflet-control", props.className);
946
- return /* @__PURE__ */ jsx("div", { ...props.container, ref: controlContainerRef, className, children: props.children });
947
- };
948
- function MyActions() {
949
- const { control, setValue } = useFormContext();
950
- const { getLabel } = useModuleDictionary();
951
- const fieldsWatch = useWatch({
952
- control,
953
- name: ["statusEdition", "reInits"]
954
- });
955
- const statusEdition = fieldsWatch[0];
956
- const initCancelDraw = () => {
957
- if (statusEdition === "initial") {
958
- setValue("statusEdition", "draw");
959
- } else if (statusEdition === "draw") {
960
- setValue("statusEdition", "initial");
961
- }
962
- };
963
- return /* @__PURE__ */ jsx(Actions, { children: /* @__PURE__ */ jsx(Button, { onClick: initCancelDraw, children: statusEdition === "initial" ? getLabel(MAP_DICCTIONARY.LABEL_MEASURE_START) : getLabel(MAP_DICCTIONARY.LABEL_MEASURE_CANCEL) }) });
964
- }
965
- function MeasureDataValidation(_getLabel) {
966
- return {};
967
- }
968
- function useValidation() {
969
- const { getLabel } = useModuleDictionary();
970
- const validationSchema = useMemo(
971
- () => Yup.object().shape({
972
- ...MeasureDataValidation()
973
- }),
974
- [getLabel]
975
- );
976
- return { validationSchema };
977
- }
978
- const INITIAL_FORM_VALUES = {
979
- /** General Data */
980
- statusLoad: "ready",
981
- reInits: 0,
982
- value: "0",
983
- measureTypeId: "distance",
984
- magnitudFactor: {
985
- id: "m_kilometers",
986
- name: "Kilometers",
987
- symbol: "k",
988
- factor_x0: 0,
989
- factor_x1: 1,
990
- factor_x2: 0
991
- },
992
- unitArea: null,
993
- /** Config Data */
994
- /** de Apoyo */
995
- statusEdition: "initial"
996
- // geometry: null ,
997
- };
998
- const STYLE_MEASURE_OPTIONS = {
999
- strokeLineColor: "#1E96DC",
1000
- strokeLineWeight: 5,
1001
- markerHeight: 37,
1002
- markerWidth: 26,
1003
- labelMarkerHeight: 0,
1004
- labelMarkerWidth: 0,
1005
- labelMarkerAnchorY: 0,
1006
- labelMarkerAnchorX: 0
1007
- };
1008
- const getMarkerPointIcon = (position) => {
1009
- return L__default.divIcon({
1010
- className: mapClasses.measureMarkerRoot,
1011
- html: `<div class="${mapClasses.measureMarkerContainer}">
1012
- <div class="${mapClasses.measureMarkerContainerRhomb}">
1013
- </div>
1014
- <div class="${mapClasses.measureMarkerContainerSlot}">
1015
- <div class="${mapClasses.measureMarkerContainerSlotNumber}">
1016
- ${position}
1017
- </div>
1018
- </div>
1019
- </div>
1020
- `,
1021
- iconSize: [STYLE_MEASURE_OPTIONS.markerWidth, STYLE_MEASURE_OPTIONS.markerHeight],
1022
- // tamaño del icono
1023
- iconAnchor: [STYLE_MEASURE_OPTIONS.markerWidth / 2, STYLE_MEASURE_OPTIONS.markerHeight]
1024
- // punto de anclaje, el mismo que el de la imagen
1025
- });
1026
- };
1027
- const getMarkerPointLabel = (distance, getLabel) => {
1028
- return L__default.divIcon({
1029
- className: mapClasses.measureLabelMarkerRoot,
1030
- html: `<div class="${mapClasses.measureLabelMarkerContainer}">
1031
- ${distance ? `<span class="${mapClasses.measureLabelMarkerDistance}">${distance}</span>` : ""}
1032
- <div class="${mapClasses.measureLabelMarkerRemove}">${getLabel(
1033
- MAP_DICCTIONARY.LABEL_MEASURE_REMOVE_POINT
1034
- )}</div>
1035
- </div>`,
1036
- iconSize: [STYLE_MEASURE_OPTIONS.labelMarkerWidth, STYLE_MEASURE_OPTIONS.labelMarkerHeight],
1037
- // tamaño del label
1038
- iconAnchor: [
1039
- STYLE_MEASURE_OPTIONS.labelMarkerAnchorX,
1040
- STYLE_MEASURE_OPTIONS.labelMarkerAnchorY
1041
- ]
1042
- //
1043
- });
1044
- };
1045
- function useMeasure() {
1046
- const { getLabel } = useModuleDictionary();
1047
- const map = useMap();
1048
- const readyToUpdate = useFormReadyForUpdate();
1049
- const { control, setValue } = useFormContext();
1050
- const fieldsWatch = useWatch({
1051
- control,
1052
- name: ["statusEdition", "value", "magnitudFactor"]
1053
- });
1054
- const statusEdition = fieldsWatch[0];
1055
- const value = fieldsWatch[1];
1056
- const magnitudFactor = fieldsWatch[2];
1057
- const [magnitudFactorCached, setMagnitudFactorCached] = useState(magnitudFactor);
1058
- const currentMeasure = useRef({
1059
- measurePoints: [],
1060
- addMarker: false,
1061
- magnitudFactor,
1062
- dragging: false
1063
- });
1064
- const clearMeasure = useCallback(() => {
1065
- currentMeasure.current.measurePoints.forEach((measurePoint) => {
1066
- measurePoint.marker.remove();
1067
- measurePoint.labelMarker.remove();
1068
- });
1069
- currentMeasure.current.measurePoints = [];
1070
- setValue("value", measureDistante());
1071
- }, []);
1072
- const getFormatFactorDistance = useCallback(
1073
- (distance, withSymbol = false) => {
1074
- if (distance === void 0) {
1075
- return void 0;
1076
- }
1077
- const cMagnitudeFactor = currentMeasure.current.magnitudFactor;
1078
- return (cMagnitudeFactor.factor_x0 + distance * cMagnitudeFactor.factor_x1 + (distance ^ 2 * cMagnitudeFactor.factor_x2)).toFixed(2) + (withSymbol ? ` ${cMagnitudeFactor.symbol}` : "");
1079
- },
1080
- []
1081
- );
1082
- const measureDistante = useCallback(() => {
1083
- let totalDistance = 0;
1084
- const measurePoints = currentMeasure.current.measurePoints;
1085
- if (currentMeasure.current.layerLine) {
1086
- if (measurePoints.length < 2) {
1087
- currentMeasure.current.layerLine.remove();
1088
- currentMeasure.current.layerLine = void 0;
1089
- } else {
1090
- currentMeasure.current.layerLine.setLatLngs(
1091
- measurePoints.map((measurePoint) => measurePoint.marker.getLatLng())
1092
- );
1093
- }
1094
- } else {
1095
- if (measurePoints.length > 1) {
1096
- currentMeasure.current.layerLine = L.polyline(
1097
- measurePoints.map((measurePoint) => measurePoint.marker.getLatLng()),
1098
- {
1099
- color: STYLE_MEASURE_OPTIONS.strokeLineColor,
1100
- weight: STYLE_MEASURE_OPTIONS.strokeLineWeight,
1101
- interactive: false
1102
- //No se puede editar
1103
- }
1104
- ).addTo(map);
1105
- }
1106
- }
1107
- for (let i = 0; i < measurePoints.length - 1; i++) {
1108
- totalDistance += measurePoints[i].marker.getLatLng().distanceTo(measurePoints[i + 1].marker.getLatLng());
1109
- }
1110
- if (measurePoints.length > 0 && measurePoints[0].formatDistanceFromPrevious !== void 0) {
1111
- measurePoints[0].formatDistanceFromPrevious = void 0;
1112
- measurePoints[0].labelMarker.setIcon(getMarkerPointLabelMemo(void 0, getLabel));
1113
- addClickListenerForRemove(measurePoints[0].labelMarker);
1114
- }
1115
- for (let i = 1; i < measurePoints.length; i++) {
1116
- const formatDistanceFromPrevious = getFormatFactorDistance(
1117
- measurePoints[i - 1].marker.getLatLng().distanceTo(measurePoints[i].marker.getLatLng()),
1118
- true
1119
- );
1120
- if (measurePoints[i].formatDistanceFromPrevious !== formatDistanceFromPrevious) {
1121
- measurePoints[i].formatDistanceFromPrevious = formatDistanceFromPrevious;
1122
- measurePoints[i].labelMarker.setIcon(
1123
- getMarkerPointLabelMemo(formatDistanceFromPrevious, getLabel)
1124
- );
1125
- addClickListenerForRemove(measurePoints[i].labelMarker);
1126
- }
1127
- }
1128
- return getFormatFactorDistance(totalDistance);
1129
- }, [map, getLabel]);
1130
- const getMarkerPointIconMemo = useCallback(getMarkerPointIcon, []);
1131
- const getMarkerPointLabelMemo = useCallback(getMarkerPointLabel, [getLabel]);
1132
- const onClickRemovePoint = useCallback((labelMarker) => {
1133
- return (e) => {
1134
- e.stopPropagation();
1135
- if (!currentMeasure.current.dragging) {
1136
- const markIndex = currentMeasure.current.measurePoints.findIndex(
1137
- (searchElement) => {
1138
- return searchElement.labelMarker === labelMarker;
1139
- }
1140
- );
1141
- if (markIndex !== -1) {
1142
- const measurePoint = currentMeasure.current.measurePoints[markIndex];
1143
- measurePoint.marker.remove();
1144
- measurePoint.labelMarker.remove();
1145
- currentMeasure.current.measurePoints.splice(markIndex, 1);
1146
- setValue("value", measureDistante());
1147
- currentMeasure.current.addMarker = true;
1148
- }
1149
- currentMeasure.current.measurePoints.forEach((measurePoint, index) => {
1150
- measurePoint.marker.setIcon(getMarkerPointIconMemo(index + 1));
1151
- });
1152
- }
1153
- };
1154
- }, []);
1155
- const addClickListenerForRemove = useCallback((labelMarker) => {
1156
- let element = labelMarker.getElement();
1157
- if (element) {
1158
- const elements = element.getElementsByClassName(
1159
- mapClasses.measureLabelMarkerRemove
1160
- );
1161
- element = elements[0];
1162
- if (element) {
1163
- element.addEventListener("click", onClickRemovePoint(labelMarker));
1164
- }
1165
- }
1166
- }, []);
1167
- const onClickMap = useCallback(
1168
- (e) => {
1169
- const lat = e.latlng.lat;
1170
- const lng = e.latlng.lng;
1171
- let formatDistanceFromPrevious = void 0;
1172
- if (currentMeasure.current.addMarker === false) {
1173
- return;
1174
- }
1175
- if (currentMeasure.current.measurePoints.length > 0) {
1176
- formatDistanceFromPrevious = getFormatFactorDistance(
1177
- currentMeasure.current.measurePoints[currentMeasure.current.measurePoints.length - 1].marker.getLatLng().distanceTo(e.latlng)
1178
- );
1179
- }
1180
- const marker = L.marker([lat, lng], {
1181
- draggable: true,
1182
- riseOnHover: true,
1183
- //Se pone la marca encima de las otras cuando se hace over
1184
- autoPan: true,
1185
- //Se corre el mapa si llega al extremo, solo para las marcas
1186
- icon: getMarkerPointIconMemo(currentMeasure.current.measurePoints.length + 1),
1187
- zIndexOffset: MAP_ZINDEX_DEFAULT
1188
- }).addTo(map);
1189
- marker.on("moveend", function(_e) {
1190
- const latlng = marker.getLatLng();
1191
- labelMarker.setLatLng(latlng);
1192
- setValue("value", measureDistante());
1193
- });
1194
- marker.on("mouseover", function() {
1195
- currentMeasure.current.addMarker = false;
1196
- });
1197
- marker.on("mouseout", function() {
1198
- currentMeasure.current.addMarker = true;
1199
- });
1200
- var labelMarker = L.marker([lat, lng], {
1201
- draggable: true,
1202
- riseOnHover: true,
1203
- //Se pone la marca encima de las otras cuando se hace over
1204
- icon: getMarkerPointLabelMemo(formatDistanceFromPrevious, getLabel),
1205
- zIndexOffset: MAP_ZINDEX_DEFAULT
1206
- }).addTo(map);
1207
- labelMarker.on("moveend", function(_e) {
1208
- const latlng = labelMarker.getLatLng();
1209
- marker.setLatLng(latlng);
1210
- setValue("value", measureDistante());
1211
- });
1212
- labelMarker.on("mouseover", function(_e) {
1213
- currentMeasure.current.addMarker = false;
1214
- });
1215
- labelMarker.on("mouseout", function(_e) {
1216
- currentMeasure.current.addMarker = true;
1217
- });
1218
- labelMarker.on("dragstart", function(_e) {
1219
- currentMeasure.current.dragging = true;
1220
- });
1221
- labelMarker.on("dragend", function(_e) {
1222
- setTimeout(function() {
1223
- currentMeasure.current.dragging = false;
1224
- }, 10);
1225
- });
1226
- addClickListenerForRemove(labelMarker);
1227
- currentMeasure.current.measurePoints.push({
1228
- marker,
1229
- labelMarker,
1230
- formatDistanceFromPrevious
1231
- });
1232
- setValue("value", measureDistante());
1233
- },
1234
- [map, measureDistante, setValue, getLabel]
1235
- );
1236
- const onMouseMoveMap = useCallback(() => {
1237
- map.getContainer().style.cursor = "crosshair";
1238
- }, [map]);
1239
- const onMouseOutMap = useCallback(() => {
1240
- map.getContainer().style.cursor = "default";
1241
- }, [map]);
1242
- useEffect(() => {
1243
- if (map) {
1244
- if (statusEdition === "initial") {
1245
- map.off("click", onClickMap);
1246
- clearMeasure();
1247
- map.getContainer().style.cursor = "default";
1248
- return;
1249
- } else {
1250
- currentMeasure.current.addMarker = true;
1251
- map.getContainer().style.cursor = "crosshair";
1252
- map.on("click", onClickMap);
1253
- }
1254
- }
1255
- }, [map, statusEdition]);
1256
- useEffect(() => {
1257
- if (!readyToUpdate) return;
1258
- if (magnitudFactor.id !== magnitudFactorCached.id) {
1259
- setMagnitudFactorCached({ ...magnitudFactor });
1260
- currentMeasure.current.magnitudFactor = magnitudFactor;
1261
- setValue("value", measureDistante());
1262
- }
1263
- }, [magnitudFactor]);
1264
- useEffect(() => {
1265
- return () => {
1266
- map.off("mousemove", onMouseMoveMap);
1267
- map.off("mouseout", onMouseOutMap);
1268
- map.off("click", onClickMap);
1269
- map.getContainer().style.cursor = "default";
1270
- clearMeasure();
1271
- };
1272
- }, []);
1273
- return { statusEdition, magnitudFactor, value };
1274
- }
1275
- function MeasureData() {
1276
- const { getLabel } = useModuleDictionary();
1277
- const { value, magnitudFactor } = useMeasure();
1278
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1279
- /* @__PURE__ */ jsx(
1280
- RHFAutocompleteAsync,
1281
- {
1282
- type: "text",
1283
- endPoint: "magnitudes/factors?origin_unit_reference_id=m_kilometers",
1284
- name: "magnitudFactor",
1285
- autoComplete: "off",
1286
- getOptionLabel: (option) => option.name,
1287
- isOptionEqualToValue: (option, measureItemValue) => option.id === measureItemValue.id,
1288
- label: getLabel(MAP_DICCTIONARY.LABEL_MEASURE_UNIT),
1289
- isRemote: false
1290
- }
1291
- ),
1292
- /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 2, className: mapClasses.measureToolFormValue, children: [
1293
- /* @__PURE__ */ jsx("span", { className: mapClasses.measureToolFormValueDistance, children: value }),
1294
- /* @__PURE__ */ jsx("span", { className: mapClasses.measureToolFormValueSymbol, children: magnitudFactor.symbol })
1295
- ] })
1296
- ] });
1297
- }
1298
- function MeasureTool() {
1299
- const { getLabel } = useModuleDictionary();
1300
- const finalInitalValues = {
1301
- ...INITIAL_FORM_VALUES
1302
- };
1303
- if (finalInitalValues?.magnitudFactor?.name) {
1304
- finalInitalValues.magnitudFactor.name = getLabel(
1305
- MAP_DICCTIONARY.LABEL_MEASURE_UNIT_BASE_KILOMETERS
1306
- );
1307
- }
1308
- const { validationSchema } = useValidation();
1309
- const onSubmit = () => {
1310
- };
1311
- return /* @__PURE__ */ jsxs(
1312
- RHFormProvider,
1313
- {
1314
- className: mapClasses.meaureToolRoot,
1315
- statusLoad: INITIAL_FORM_VALUES.statusLoad,
1316
- onSubmit,
1317
- values: finalInitalValues,
1318
- validationSchema,
1319
- children: [
1320
- /* @__PURE__ */ jsx(Stack, { direction: "column", children: /* @__PURE__ */ jsx(MeasureData, {}) }),
1321
- /* @__PURE__ */ jsx(MyActions, {})
1322
- ]
1323
- }
1324
- );
1325
- }
1326
- function ZoomButtons() {
1327
- const map = useMap();
1328
- const { host_static_assets, environment_assets } = useEnvironment();
1329
- const [, setZoomInDisabled] = useState(false);
1330
- const [, setZoomOutDisabled] = useState(false);
1331
- useEffect(() => {
1332
- const updateButtonState = () => {
1333
- const currentZoom = map.getZoom();
1334
- const maxZoom = map.getMaxZoom();
1335
- const minZoom = map.getMinZoom();
1336
- setZoomInDisabled(currentZoom === maxZoom);
1337
- setZoomOutDisabled(currentZoom === minZoom);
1338
- };
1339
- map.on("zoomend", updateButtonState);
1340
- updateButtonState();
1341
- return () => {
1342
- map.off("zoomend", updateButtonState);
1343
- };
1344
- }, [map]);
1345
- const handleZoomIn = () => {
1346
- map.zoomIn();
1347
- };
1348
- const handleZoomOut = () => {
1349
- map.zoomOut();
1350
- };
1351
- return /* @__PURE__ */ jsxs("div", { className: mapClasses.zoomButtons, children: [
1352
- /* @__PURE__ */ jsx(
1353
- IconButton,
1354
- {
1355
- onClick: handleZoomIn,
1356
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_ZOOM_IN}`
1357
- }
1358
- ),
1359
- /* @__PURE__ */ jsx(
1360
- IconButton,
1361
- {
1362
- onClick: handleZoomOut,
1363
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_ZOOM_OUT}`
1364
- }
1365
- )
1366
- ] });
1367
- }
1368
- function TopRightTools(props) {
1369
- const { gpsTools } = props;
1370
- const { addPopup, closePopup } = usePopupsStore((state) => state.popupsActions);
1371
- const { host_static_assets, environment_assets } = useEnvironment();
1372
- const { getLabel } = useModuleDictionary();
1373
- const openPopupsIds = usePopupsStore(
1374
- (state) => state.popupsIds.filter((pId) => {
1375
- return state.hashPopups[pId].status === "init";
1376
- }),
1377
- shallow
1378
- );
1379
- const popupsIds = usePopupsStore((state) => state.popupsIds, shallow);
1380
- const map = useMap();
1381
- const isToggledGpsTools = openPopupsIds.indexOf("gpsTools") > -1;
1382
- const isDisabledGpsTools = popupsIds.indexOf("gpsTools") > -1 && openPopupsIds.indexOf("gpsTools") === -1;
1383
- const isToggledMeasureTool = openPopupsIds.indexOf("measureTool") > -1;
1384
- const isDisabledMeasureTool = popupsIds.indexOf("measureTool") > -1 && openPopupsIds.indexOf("measureTool") === -1;
1385
- const onMouseDown = (e) => {
1386
- map.dragging.disable();
1387
- e.stopPropagation();
1388
- document.addEventListener("mouseup", onMouseUp);
1389
- };
1390
- const onMouseUp = (e) => {
1391
- map.dragging.enable();
1392
- e.stopPropagation();
1393
- document.removeEventListener("mouseup", onMouseUp);
1394
- };
1395
- const onGpsToolsClick = (e) => {
1396
- if (!isToggledGpsTools) {
1397
- addPopup(
1398
- {
1399
- popupId: GPS_TOOLS_POPUP_ID,
1400
- title: getLabel(MAP_DICCTIONARY.LABEL_GPSTOOLS_NAME),
1401
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_ICONS.MAP_GPS_TOOLS_TOOL}`,
1402
- functionComponent: gpsTools,
1403
- onMouseDown,
1404
- defaultPosition: GPS_TOOLS_POPUP_DEFAULT_POSITION
1405
- },
1406
- { closeOthers: true }
1407
- );
1408
- } else {
1409
- closePopup(GPS_TOOLS_POPUP_ID);
1410
- }
1411
- e.stopPropagation();
1412
- };
1413
- const onMeasureToolClick = (e) => {
1414
- if (!isToggledMeasureTool) {
1415
- addPopup(
1416
- {
1417
- popupId: "measureTool",
1418
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_MEASURE_TOOL}`,
1419
- title: "Measure Tool",
1420
- functionComponent: MeasureTool,
1421
- onMouseDown,
1422
- defaultPosition: MESURE_POPUP_DEFAULT_POSITION
1423
- },
1424
- { closeOthers: true }
1425
- );
1426
- } else {
1427
- closePopup("measureTool");
1428
- }
1429
- e.stopPropagation();
1430
- };
1431
- return /* @__PURE__ */ jsxs(Control, { position: "topright", prepend: true, className: mapClasses.topRigthToolsRoot, children: [
1432
- /* @__PURE__ */ jsx(
1433
- ToggleIconButton,
1434
- {
1435
- isToggled: isToggledGpsTools,
1436
- disabled: isDisabledGpsTools,
1437
- onToggle: onGpsToolsClick,
1438
- src: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_ICONS.MAP_GPS_TOOLS_TOOL}`
1439
- }
1440
- ),
1441
- /* @__PURE__ */ jsx(
1442
- ToggleIconButton,
1443
- {
1444
- isToggled: isToggledMeasureTool,
1445
- disabled: isDisabledMeasureTool,
1446
- onToggle: onMeasureToolClick,
1447
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_MEASURE_TOOL}`
1448
- }
1449
- ),
1450
- /* @__PURE__ */ jsx(ZoomButtons, {})
1451
- ] });
1452
- }
1453
- function useColumns(props) {
1454
- const {
1455
- rowKeyGetter,
1456
- visibleLayers,
1457
- setVisibleLayers,
1458
- autoFocusLayers,
1459
- setAutoFocusLayers,
1460
- clusterLayers,
1461
- setClusterLayers
1462
- } = props;
1463
- const { getLabel } = useModuleDictionary();
1464
- const { host_static_assets, environment_assets } = useEnvironment();
1465
- const useHook = useCallback(
1466
- (field) => {
1467
- if (field === "visible") {
1468
- return [visibleLayers, setVisibleLayers];
1469
- } else if (field === "autoFocus") {
1470
- return [autoFocusLayers, setAutoFocusLayers];
1471
- } else {
1472
- return [clusterLayers, setClusterLayers];
1473
- }
1474
- },
1475
- [visibleLayers, autoFocusLayers, clusterLayers]
1476
- );
1477
- const columns = useMemo(
1478
- () => [
1479
- {
1480
- key: "name",
1481
- name: getLabel(MAP_DICCTIONARY.LABEL_NAME),
1482
- type: "string",
1483
- width: 150,
1484
- frozen: true
1485
- },
1486
- {
1487
- key: "visible",
1488
- name: getLabel(MAP_DICCTIONARY.LABEL_LAYER_VISIBLE),
1489
- width: 50,
1490
- minWidth: 20,
1491
- type: "boolean",
1492
- // isDraggable: false,
1493
- formatter: ColumnSetCheckFormatter({
1494
- field: "visible",
1495
- rowKeyGetter,
1496
- useHook
1497
- }),
1498
- cellClass: "rdg-cell-align-center",
1499
- headerRenderer: () => /* @__PURE__ */ jsx(Tooltip, { title: getLabel(MAP_DICCTIONARY.LABEL_LAYER_VISIBLE), children: /* @__PURE__ */ jsx(
1500
- Icon,
1501
- {
1502
- size: "medium",
1503
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_LAYER_VISIBLE}`
1504
- }
1505
- ) })
1506
- },
1507
- {
1508
- key: "autoFocus",
1509
- name: getLabel(MAP_DICCTIONARY.LABEL_LAYER_AUTOFOCUS),
1510
- minWidth: 20,
1511
- width: 50,
1512
- type: "boolean",
1513
- // frozen: true,
1514
- // isDraggable: false,
1515
- formatter: ColumnSetCheckFormatter({
1516
- field: "autoFocus",
1517
- rowKeyGetter,
1518
- useHook
1519
- }),
1520
- cellClass: "rdg-cell-align-center",
1521
- headerRenderer: () => /* @__PURE__ */ jsx(Tooltip, { title: getLabel(MAP_DICCTIONARY.LABEL_LAYER_AUTOFOCUS), children: /* @__PURE__ */ jsx(
1522
- Icon,
1523
- {
1524
- size: "medium",
1525
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_LAYER_AUTOFOCUS}`
1526
- }
1527
- ) })
1528
- },
1529
- {
1530
- key: "cluster",
1531
- name: getLabel(MAP_DICCTIONARY.LABEL_LAYER_CLUSTER),
1532
- minWidth: 20,
1533
- width: 50,
1534
- type: "boolean",
1535
- // frozen: true,
1536
- // isDraggable: false,
1537
- formatter: ColumnSetCheckFormatter({
1538
- field: "cluster",
1539
- disabledGetter: (row) => !row.clusterAble,
1540
- rowKeyGetter,
1541
- useHook
1542
- }),
1543
- cellClass: "rdg-cell-align-center",
1544
- headerRenderer: () => /* @__PURE__ */ jsx(Tooltip, { title: getLabel(MAP_DICCTIONARY.LABEL_LAYER_CLUSTER), children: /* @__PURE__ */ jsx(
1545
- Icon,
1546
- {
1547
- size: "medium",
1548
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_LAYER_CLUSTER}`
1549
- }
1550
- ) })
1551
- }
1552
- // {
1553
- // key: 'checkedInternalFeatures',
1554
- // name: getLabel(DICCTIONARY.LABEL_VIEW_INTERNAL_FEATURES),
1555
- // width: 80,
1556
- // type: 'boolean',
1557
- // // isDraggable: false,
1558
- // // frozen: true,
1559
- // formatter: ColumnSetCheckFormatter({
1560
- // field: 'InternalFeatures',
1561
- // rowKeyGetter,
1562
- // useHook,
1563
- // }),
1564
- // cellClass: 'rdg-cell-align-center',
1565
- // },
1566
- ],
1567
- [getLabel, useHook]
1568
- );
1569
- return { columns };
1570
- }
1571
- function useCheckedLayers(checkedNameSet) {
1572
- const [checkedLayers, setCheckedLayers] = useMapStore(
1573
- (state) => [
1574
- state[`${checkedNameSet}CheckedLayers`],
1575
- (newSet) => {
1576
- state.mapActions.setCheckedLayers(checkedNameSet, newSet);
1577
- }
1578
- ],
1579
- shallow
1580
- );
1581
- return [checkedLayers, setCheckedLayers];
1582
- }
1583
- function useRowActionsGetter() {
1584
- const { getLabel } = useModuleDictionary();
1585
- const { hasPrivilege } = useModulePrivileges();
1586
- const { host_static_assets, environment_assets } = useEnvironment();
1587
- const { removeLayer } = useMapStore((state) => state.mapActions, shallow);
1588
- const [urlIconDelete] = useState(
1589
- `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_LAYER_DELETE}`
1590
- );
1591
- const onDelete = useCallback(
1592
- (row) => {
1593
- removeLayer(row.id);
1594
- },
1595
- [getLabel]
1596
- );
1597
- const rowActionsGetter = useCallback(
1598
- (row) => {
1599
- const conditionalItems = [];
1600
- conditionalItems.push({
1601
- urlIcon: urlIconDelete,
1602
- dictionaryId: MAP_DICCTIONARY.ROW_ACTION_LAYER_DELETE,
1603
- onClick: () => {
1604
- onDelete(row);
1605
- },
1606
- disabled: !row.deleteAble
1607
- });
1608
- return conditionalItems;
1609
- },
1610
- [hasPrivilege, onDelete, urlIconDelete]
1611
- );
1612
- return { rowActionsGetter };
1613
- }
1614
- function useMaster() {
1615
- const [hashLayers, layersIds] = useMapStore(
1616
- (state) => [state.hashLayers, state.layersIds],
1617
- shallow
1618
- );
1619
- const rowKeyGetter = useCallback((row) => row.id, []);
1620
- const [visibleLayers, setVisibleLayers] = useCheckedLayers("visible");
1621
- const [autoFocusLayers, setAutoFocusLayers] = useCheckedLayers("autoFocus");
1622
- const [clusterLayers, setClusterLayers] = useCheckedLayers("cluster");
1623
- const rows = useMemo(() => {
1624
- const rows2 = [];
1625
- layersIds.forEach((layerId) => {
1626
- if (hashLayers[layerId]) {
1627
- rows2.push({
1628
- id: layerId,
1629
- name: hashLayers[layerId].name || `*${layerId}`,
1630
- active: hashLayers[layerId].visible,
1631
- clusterAble: hashLayers[layerId].clusterAble || false,
1632
- deleteAble: hashLayers[layerId].deleteAble || false
1633
- });
1634
- }
1635
- });
1636
- return rows2;
1637
- }, [hashLayers, layersIds]);
1638
- const { rowActionsGetter } = useRowActionsGetter();
1639
- const { columns } = useColumns({
1640
- rowKeyGetter,
1641
- visibleLayers,
1642
- setVisibleLayers,
1643
- autoFocusLayers,
1644
- setAutoFocusLayers,
1645
- clusterLayers,
1646
- setClusterLayers
1647
- });
1648
- return {
1649
- rowKeyGetter,
1650
- columns,
1651
- rows,
1652
- checkedRows: visibleLayers,
1653
- onCheckedRowsChange: setVisibleLayers,
1654
- rowActionsGetter
1655
- };
1656
- }
1657
- function useDisableZoomEvents(node) {
1658
- const map = useMap();
1659
- useEffect(() => {
1660
- if (!map || !node) return;
1661
- node.addEventListener("mouseover", function() {
1662
- map.doubleClickZoom.disable();
1663
- map.scrollWheelZoom.disable();
1664
- });
1665
- node.addEventListener("mouseleave", function() {
1666
- map.scrollWheelZoom.enable();
1667
- map.doubleClickZoom.enable();
1668
- });
1669
- }, [map, node]);
1670
- }
1671
- function LayersTool() {
1672
- const { columns, rows, rowKeyGetter, rowActionsGetter } = useMaster();
1673
- const [divRef, setDivRef] = useStateRef(null);
1674
- useDisableZoomEvents(divRef);
1675
- return /* @__PURE__ */ jsx("div", { ref: setDivRef, style: { position: "relative", height: "100%" }, children: /* @__PURE__ */ jsx(
1676
- DataGrid,
1677
- {
1678
- id: "layers",
1679
- columns,
1680
- rows,
1681
- rowActionsGetter,
1682
- rowKeyGetter,
1683
- withActions: true,
1684
- actionsProps: {
1685
- withRowsCount: false,
1686
- withSettings: false,
1687
- withPager: false,
1688
- withLocalFilters: false
1689
- }
1690
- }
1691
- ) });
1692
- }
1693
- function MapSourcesTool() {
1694
- const { getLabel } = useModuleDictionary();
1695
- const { host_static_assets, environment_assets } = useEnvironment();
1696
- const currentMapSourceId = useMapStore((state) => state.currentMapSourceId, shallow);
1697
- const mapSources = useMapStore((state) => {
1698
- return state.mapSourcesIds.map((id) => ({
1699
- id,
1700
- dictionaryId: state.hashMapSources[id].dictionaryId,
1701
- iconUrl: state.hashMapSources[id].iconUrl,
1702
- hasBicyclingLayer: state.hashMapSources[id].hasBicyclingLayer,
1703
- hasTrafficLayer: state.hashMapSources[id].hasTrafficLayer,
1704
- hasTransitLayer: state.hashMapSources[id].hasTransitLayer,
1705
- roadSeletedOptions: state.hashMapSources[id].roadSelectedOptions
1706
- }));
1707
- }, shallow);
1708
- const { setCurrentMapSource, setMapSourceRoadOptions: setMapSourceRoadMapOptions } = useMapStore(
1709
- (state) => state.mapActions,
1710
- shallow
1711
- );
1712
- const [divRef, setDivRef] = useStateRef(null);
1713
- useDisableZoomEvents(divRef);
1714
- const handleChange = (event) => {
1715
- setCurrentMapSource(event.target.value);
1716
- };
1717
- return /* @__PURE__ */ jsx("div", { className: mapClasses.mapSourcesRoot, ref: setDivRef, children: /* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
1718
- RadioGroup,
1719
- {
1720
- "aria-labelledby": "demo-controlled-radio-buttons-group",
1721
- name: "controlled-radio-buttons-group",
1722
- value: currentMapSourceId,
1723
- onChange: handleChange,
1724
- children: mapSources.map((mapSourceOption) => /* @__PURE__ */ jsxs("div", { className: mapClasses.mapSourcesOption, children: [
1725
- /* @__PURE__ */ jsx(
1726
- FormControlLabel,
1727
- {
1728
- className: "",
1729
- value: mapSourceOption.id,
1730
- control: /* @__PURE__ */ jsx(Radio, {}),
1731
- label: /* @__PURE__ */ jsxs("div", { className: mapClasses.mapSourcesOptionIconLabel, children: [
1732
- /* @__PURE__ */ jsx(
1733
- Icon,
1734
- {
1735
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${mapSourceOption.iconUrl}`
1736
- }
1737
- ),
1738
- /* @__PURE__ */ jsx("span", { children: getLabel(mapSourceOption.dictionaryId) })
1739
- ] })
1740
- }
1741
- ),
1742
- (mapSourceOption.hasBicyclingLayer || mapSourceOption.hasTrafficLayer || mapSourceOption.hasTransitLayer) && /* @__PURE__ */ jsxs(
1743
- "div",
1744
- {
1745
- className: clsx(
1746
- mapClasses.mapSourcesOptionRoadOptions,
1747
- currentMapSourceId !== mapSourceOption.id ? mapClasses.disabled : mapClasses.active
1748
- ),
1749
- children: [
1750
- mapSourceOption.hasTrafficLayer && /* @__PURE__ */ jsxs("div", { className: mapClasses.mapSourcesOptionRoadOptionsCheck, children: [
1751
- /* @__PURE__ */ jsx(
1752
- CheckBox,
1753
- {
1754
- disabled: currentMapSourceId !== mapSourceOption.id,
1755
- checked: mapSourceOption.roadSeletedOptions?.trafficLayer || false,
1756
- onChange: (_e, checked) => {
1757
- setMapSourceRoadMapOptions({ trafficLayer: checked });
1758
- }
1759
- }
1760
- ),
1761
- /* @__PURE__ */ jsx(
1762
- Icon,
1763
- {
1764
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_SOURCE_ROAD_TRAFFIC}`
1765
- }
1766
- )
1767
- ] }),
1768
- mapSourceOption.hasTransitLayer && /* @__PURE__ */ jsxs("div", { className: mapClasses.mapSourcesOptionRoadOptionsCheck, children: [
1769
- /* @__PURE__ */ jsx(
1770
- CheckBox,
1771
- {
1772
- disabled: currentMapSourceId !== mapSourceOption.id,
1773
- checked: mapSourceOption.roadSeletedOptions?.transitLayer || false,
1774
- onChange: (_e, checked) => {
1775
- setMapSourceRoadMapOptions({ transitLayer: checked });
1776
- }
1777
- }
1778
- ),
1779
- /* @__PURE__ */ jsx(
1780
- Icon,
1781
- {
1782
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_SOURCE_ROAD_TRANSIT}`
1783
- }
1784
- )
1785
- ] }),
1786
- mapSourceOption.hasBicyclingLayer && /* @__PURE__ */ jsxs("div", { className: mapClasses.mapSourcesOptionRoadOptionsCheck, children: [
1787
- /* @__PURE__ */ jsx(
1788
- CheckBox,
1789
- {
1790
- disabled: currentMapSourceId !== mapSourceOption.id,
1791
- checked: mapSourceOption.roadSeletedOptions?.bicyclingLayer || false,
1792
- label: "Bycicle",
1793
- onChange: (_e, checked) => {
1794
- setMapSourceRoadMapOptions({ bicyclingLayer: checked });
1795
- }
1796
- }
1797
- ),
1798
- /* @__PURE__ */ jsx(
1799
- Icon,
1800
- {
1801
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${MAP_ICONS.MAP_SOURCE_ROAD_BICYCLING}`
1802
- }
1803
- )
1804
- ] })
1805
- ]
1806
- }
1807
- )
1808
- ] }, mapSourceOption.dictionaryId))
1809
- }
1810
- ) }) });
1811
- }
1812
- function LayersButton(props) {
1813
- const { type } = props;
1814
- const [open, setOpen] = useState(null);
1815
- const { host_static_assets, environment_assets } = useEnvironment();
1816
- const theme = useTheme();
1817
- const handleOpen = (event) => {
1818
- setOpen(event.currentTarget);
1819
- };
1820
- const handleClose = () => {
1821
- setOpen(null);
1822
- };
1823
- return (
1824
- /* LanguagePopoverRoot: Contenedor principal del componente, es usado para aplicar los estilos css de los overrides que
1825
- provienen del objeto del tema. Se usa para garantizar de que estos estilos no se propaguen a otros componentes
1826
- de la plataforna web. */
1827
- /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
1828
- /* @__PURE__ */ jsx(
1829
- IconButton,
1830
- {
1831
- onClick: handleOpen,
1832
- src: `${host_static_assets}/${environment_assets}/frontend/components/map/assets/icons/${type === "MapSources" ? MAP_ICONS.MAP_SOURCES_TOOL : MAP_ICONS.MAP_LAYERS_TOOL}`
1833
- }
1834
- ),
1835
- /* @__PURE__ */ jsx(
1836
- Popover,
1837
- {
1838
- className: type === "MapSources" ? mapClasses.mapSourcesPopoverRoot : mapClasses.layersPopoverRoot,
1839
- arrowType: "no-arrow",
1840
- open: Boolean(open),
1841
- anchorEl: open,
1842
- anchorOrigin: { vertical: "bottom", horizontal: "left" },
1843
- onClose: handleClose,
1844
- sx: {
1845
- ...type === "MapSources" ? theme.components?.M4LMapMapSources?.styleOverrides : theme.components?.M4LMapLayers?.styleOverrides
1846
- // width: 180,
1847
- // '& .MuiMenuItem-root': { px: 1, typography: 'body2', borderRadius: 0.75 },
1848
- },
1849
- disableAutoFocus: true,
1850
- disableRestoreFocus: true,
1851
- disableEnforceFocus: true,
1852
- children: type === "MapSources" ? /* @__PURE__ */ jsx(MapSourcesTool, {}) : /* @__PURE__ */ jsx(LayersTool, {})
1853
- }
1854
- )
1855
- ] })
1856
- );
1857
- }
1858
- function TopLeftTools() {
1859
- return /* @__PURE__ */ jsxs(Control, { position: "topleft", prepend: true, className: mapClasses.topLeftToolsRoot, children: [
1860
- /* @__PURE__ */ jsx(LayersButton, { type: "MapSources" }),
1861
- /* @__PURE__ */ jsx(LayersButton, { type: "Layers" })
1862
- ] });
1863
- }
1864
- function Controls(props) {
1865
- const { gpsTools } = props;
1866
- const map = useMap();
1867
- const [controlContainer, setControlContainer] = useState(null);
1868
- useEffect(() => {
1869
- const cContainer = map.getContainer().getElementsByClassName("leaflet-control-container")[0];
1870
- if (cContainer !== null) {
1871
- setControlContainer(cContainer);
1872
- L__default.DomEvent.disableClickPropagation(cContainer);
1873
- L__default.DomEvent.disableScrollPropagation(cContainer);
1874
- }
1875
- }, [map]);
1876
- return /* @__PURE__ */ jsxs(
1877
- PopupsProvider,
1878
- {
1879
- baseZindex: MAP_ZINDEX_OVER_MAP,
1880
- containerElement: map.getContainer(),
1881
- initialPopups: [
1882
- {
1883
- popupId: "popup1",
1884
- status: "init",
1885
- iconUrl: "`https://s3.amazonaws.com/static.made4labs/environments/d1/frontend/components/dynamic_filter/assets/icons/edit.svg`,",
1886
- title: "Popup 1",
1887
- subTitle: "Subtitulo",
1888
- zIndex: 1,
1889
- componentProps: {},
1890
- functionComponent: () => /* @__PURE__ */ jsx("div", { children: "MyComponent" })
1891
- }
1892
- ],
1893
- children: [
1894
- /* @__PURE__ */ jsx(TopLeftTools, {}),
1895
- /* @__PURE__ */ jsx(TopRightTools, { gpsTools }),
1896
- controlContainer && createPortal(/* @__PURE__ */ jsx(PopupsViewer, {}), controlContainer)
1897
- ]
1898
- }
1899
- );
1900
- }
1901
- const MarkerClusterGroup = createPathComponent(({ children: _c, ...props }, ctx) => {
1902
- const clusterProps = {};
1903
- const clusterEvents = {};
1904
- Object.entries(props).forEach(([propName, prop]) => {
1905
- if (propName !== void 0 && prop !== "") {
1906
- propName.startsWith("on") ? clusterEvents[propName] = prop : clusterProps[propName] = prop;
1907
- }
1908
- });
1909
- const markerClusterGroup = new L__default.MarkerClusterGroup(clusterProps);
1910
- Object.entries(clusterEvents).forEach(([eventAsProp, callback]) => {
1911
- const clusterEvent = `cluster${eventAsProp.substring(2).toLowerCase()}`;
1912
- markerClusterGroup.on(clusterEvent, callback);
1913
- });
1914
- return {
1915
- instance: markerClusterGroup,
1916
- context: { ...ctx, layerContainer: markerClusterGroup }
1917
- };
1918
- });
1919
- const RenderByEachFeatureComponent = ({
1920
- renderFeature,
1921
- ...props
1922
- }) => {
1923
- const feature = renderFeature(props);
1924
- return feature ? /* @__PURE__ */ jsx(Fragment, { children: feature }) : null;
1925
- };
1926
- const MemonizedRenderByEachFeatureComponent = React__default.memo(RenderByEachFeatureComponent);
1927
- const MyLayer = (props) => {
1928
- const { layerId } = props;
1929
- const map = useMap();
1930
- const popupRef = useRef(null);
1931
- const lefaletLayerRef = useRef({
1932
- clickTimeout: null,
1933
- clickCount: 0,
1934
- handleClickSetted: false
1935
- });
1936
- const featureIdOrCollection = useMapStore((state) => {
1937
- const geoJsonObject = state.hashLayers[layerId]?.geoJsonObject;
1938
- if (geoJsonObject && geoJsonObject.object.type === "Feature") {
1939
- return geoJsonObject.object.id;
1940
- } else if (geoJsonObject && geoJsonObject.object.type === "FeatureCollection") {
1941
- return geoJsonObject && geoJsonObject.object.features.map((feature) => feature.id);
1942
- }
1943
- }, shallow);
1944
- const renderFeature = useMapStore((state) => state.hashLayers[layerId]?.renderFeature, shallow);
1945
- const [visible, cluster = false] = useMapStore(
1946
- (state) => [state.hashLayers[layerId]?.visible, state.hashLayers[layerId]?.cluster],
1947
- shallow
1948
- );
1949
- const markerClusterGroupRef = useRef(null);
1950
- const handleClick = (a) => {
1951
- lefaletLayerRef.current.clickCount++;
1952
- if (lefaletLayerRef.current.clickCount === 1) {
1953
- lefaletLayerRef.current.clickTimeout = setTimeout(() => {
1954
- const cluster2 = a.propagatedFrom;
1955
- if (cluster2 && cluster2 instanceof L__default.MarkerCluster) ;
1956
- if (!popupRef.current) {
1957
- popupRef.current = L__default.popup().setLatLng(a.sourceTarget._cLatLng).setContent("Hello, World!");
1958
- map.addLayer(popupRef.current);
1959
- } else {
1960
- popupRef.current.openOn(map);
1961
- }
1962
- lefaletLayerRef.current.clickCount = 0;
1963
- }, TIME_DOUBLE_CLICK);
1964
- } else if (lefaletLayerRef.current.clickCount === 2) {
1965
- if (lefaletLayerRef.current?.clickTimeout) {
1966
- clearTimeout(lefaletLayerRef.current.clickTimeout);
1967
- }
1968
- lefaletLayerRef.current.clickCount = 0;
1969
- }
1970
- };
1971
- useEffect(() => {
1972
- if (markerClusterGroupRef.current) {
1973
- markerClusterGroupRef.current.on("clusterclick", handleClick);
1974
- }
1975
- }, [markerClusterGroupRef.current]);
1976
- if (!featureIdOrCollection || !renderFeature) {
1977
- return null;
1978
- }
1979
- if (visible === false) {
1980
- return null;
1981
- }
1982
- const isFeaturCollection = Array.isArray(featureIdOrCollection);
1983
- if (!isFeaturCollection) {
1984
- return /* @__PURE__ */ jsx(
1985
- RenderByEachFeatureComponent,
1986
- {
1987
- renderFeature,
1988
- id: featureIdOrCollection,
1989
- layerId
1990
- }
1991
- );
1992
- } else {
1993
- const createClusterCustomIcon = (cluster2) => {
1994
- const childCount = cluster2.getChildCount();
1995
- let c = " marker-cluster-";
1996
- if (childCount < 10) {
1997
- c += "small";
1998
- } else if (childCount < 100) {
1999
- c += "medium";
2000
- } else {
2001
- c += "large";
2002
- }
2003
- const DivIcon2 = new L__default.DivIcon({
2004
- html: "<div><span>" + childCount + "</span></div>",
2005
- className: "marker-cluster" + c,
2006
- iconSize: new L__default.Point(40, 40)
2007
- });
2008
- return DivIcon2;
2009
- };
2010
- if (!cluster) {
2011
- return /* @__PURE__ */ jsx(LayerGroup, { children: featureIdOrCollection.map((featureId) => {
2012
- return /* @__PURE__ */ jsx(
2013
- MemonizedRenderByEachFeatureComponent,
2014
- {
2015
- renderFeature,
2016
- id: featureId,
2017
- layerId
2018
- },
2019
- `k_${featureId}`
2020
- );
2021
- }) });
2022
- } else {
2023
- return /* @__PURE__ */ jsx(
2024
- MarkerClusterGroup,
2025
- {
2026
- disableClusteringAtZoom: 18,
2027
- showCoverageOnHover: false,
2028
- zoomToBoundsOnClick: false,
2029
- spiderfyOnMaxZoom: false,
2030
- iconCreateFunction: createClusterCustomIcon,
2031
- children: featureIdOrCollection.map((featureId) => {
2032
- return /* @__PURE__ */ jsx(
2033
- MemonizedRenderByEachFeatureComponent,
2034
- {
2035
- renderFeature,
2036
- id: featureId,
2037
- layerId
2038
- },
2039
- `k_${featureId}`
2040
- );
2041
- })
2042
- }
2043
- );
2044
- }
2045
- }
2046
- };
2047
- function useAutoFocus() {
2048
- const map = useMap();
2049
- const layerWithAutoFocus = useMapStore((state) => {
2050
- return state.layersIds.filter((lId) => {
2051
- if (state.hashLayers[lId].autoFocus && state.hashLayers[lId].visible) {
2052
- return true;
2053
- }
2054
- return false;
2055
- }).map((layerId) => ({
2056
- layerId,
2057
- features: function() {
2058
- if (state.hashLayers[layerId].geoJsonObject?.object.type === "FeatureCollection") {
2059
- const layer = state.hashLayers[layerId].geoJsonObject?.object;
2060
- return layer.features.filter((feature) => feature.layerData !== void 0).map((feature) => ({ featureId: feature.id, layerData: feature.layerData }));
2061
- } else {
2062
- const feature = state.hashLayers[layerId].geoJsonObject?.object;
2063
- if (feature.layerData !== void 0) {
2064
- return [{ featureId: feature.id, layerData: feature.layerData }];
2065
- }
2066
- }
2067
- return [];
2068
- }()
2069
- }));
2070
- }, shallow);
2071
- useEffect(() => {
2072
- const proccesLayerWithAutoFocus = (layersFoucus) => {
2073
- const layersToFitBounds = [];
2074
- for (const layerWhitFeatures of layersFoucus) {
2075
- const features = layerWhitFeatures?.features;
2076
- for (let i = 0; i < features.length; i++) {
2077
- const feature = features[i];
2078
- if (feature.layerData !== void 0) {
2079
- const featureForBounds = {
2080
- layerId: layerWhitFeatures.layerId,
2081
- featureId: feature.featureId,
2082
- layerData: feature.layerData
2083
- };
2084
- layersToFitBounds.push(featureForBounds);
2085
- } else {
2086
- console.error(`La capa ${layerWhitFeatures.layerId} no tiene un método getBounds`);
2087
- }
2088
- }
2089
- }
2090
- if (layersToFitBounds.length > 0) {
2091
- let featureForBounds = layersToFitBounds[0];
2092
- let bounds = L__default.latLngBounds(
2093
- featureForBounds.layerData.boundsNW,
2094
- featureForBounds.layerData.boundsSE
2095
- );
2096
- for (let i = 1; i < layersToFitBounds.length; i++) {
2097
- featureForBounds = layersToFitBounds[i];
2098
- const newBounds = L__default.latLngBounds(
2099
- featureForBounds.layerData.boundsNW,
2100
- featureForBounds.layerData.boundsSE
2101
- );
2102
- bounds = bounds.extend(newBounds);
2103
- }
2104
- map.fitBounds(bounds, { animate: false, maxZoom: 22, padding: [50, 50] });
2105
- }
2106
- };
2107
- const throttleBounds = throttle(proccesLayerWithAutoFocus, 300, {
2108
- leading: false,
2109
- // No enviar el primer evento de fitBounds
2110
- trailing: true
2111
- // Incluir siempre el ultimo evento en la cola, para que no quede se quedee a la mitad del fitBounds
2112
- });
2113
- throttleBounds(layerWithAutoFocus);
2114
- }, [layerWithAutoFocus]);
2115
- }
2116
- const LayersContainer = () => {
2117
- const layersId = useMapStore((state) => state.layersIds, shallow);
2118
- const isSkeleton = useMapStore((state) => state.ownerState.isSkeleton, shallow);
2119
- const map = useMap();
2120
- useAutoFocus();
2121
- useEffect(() => {
2122
- if (!map) {
2123
- return;
2124
- }
2125
- L__default.control.scale().addTo(map);
2126
- return () => {
2127
- L__default.control.scale().remove();
2128
- };
2129
- }, [map]);
2130
- if (isSkeleton) {
2131
- return null;
2132
- }
2133
- if (!map) {
2134
- return null;
2135
- }
2136
- return /* @__PURE__ */ jsx(React__default.Fragment, { children: layersId.map((l) => /* @__PURE__ */ jsx(MyLayer, { layerId: l }, l)) });
2137
- };
2138
- const MapRootContainer = styled(MapContainer)`
2139
- ${(props) => props.theme.components?.M4LMap?.styleOverrides}
2140
- `;
2141
- function Map$1(props) {
2142
- const {
2143
- gpsTools,
2144
- center = [6.215749485905093, -75.58622905191254],
2145
- initalZoom = 16,
2146
- maxZoom = 22
2147
- } = props;
2148
- return /* @__PURE__ */ jsxs(
2149
- MapRootContainer,
2150
- {
2151
- className: mapClasses.root,
2152
- center,
2153
- zoom: initalZoom,
2154
- maxZoom,
2155
- boxZoom: true,
2156
- preferCanvas: true,
2157
- zoomControl: false,
2158
- children: [
2159
- /* @__PURE__ */ jsx(TileLayers, {}),
2160
- /* @__PURE__ */ jsx(LayersContainer, {}),
2161
- /* @__PURE__ */ jsx(Controls, { gpsTools })
2162
- ]
2163
- }
2164
- );
2165
- }
2166
- function CustomMarker(props) {
2167
- const { position, width, height, iconForm, bearing, ...other } = props;
2168
- const html = useMemo(() => {
2169
- }, [bearing]);
2170
- const customIcon = useMemo(() => {
2171
- return L__default.divIcon({
2172
- className: "custom-icon",
2173
- iconSize: [width, height],
2174
- html: `<div>Hola</div>`
2175
- });
2176
- }, [html]);
2177
- return /* @__PURE__ */ jsx(
2178
- Marker,
2179
- {
2180
- position,
2181
- icon: customIcon,
2182
- ...other
2183
- }
2184
- );
2185
- }
2186
- const MarkerFeatureRender = (props) => {
2187
- const { id, layerId } = props;
2188
- const feature = useMapStore((state) => {
2189
- const gObject = state.hashLayers[layerId].geoJsonObject;
2190
- if (!gObject) {
2191
- return null;
2192
- }
2193
- if (gObject.object.type === "Feature") {
2194
- return {
2195
- id: gObject.object.id,
2196
- geometry: gObject.object.geometry,
2197
- properties: gObject.object.properties
2198
- };
2199
- } else {
2200
- const feat = gObject.object.features.find((f) => f.id === id);
2201
- if (feat) {
2202
- return {
2203
- id: feat.id,
2204
- geometry: feat.geometry,
2205
- properties: feat.properties
2206
- };
2207
- }
2208
- return null;
2209
- }
2210
- }, shallow);
2211
- if (!feature) {
2212
- return null;
2213
- }
2214
- if (feature.geometry.type === "Point") {
2215
- const [lat, lng] = feature.geometry.coordinates;
2216
- const bearing = feature.properties?.iconBearing ?? 0;
2217
- return (
2218
- // <Marker position={{ lat, lng }}>
2219
- // ddd
2220
- // </Marker>
2221
- /* @__PURE__ */ jsx(
2222
- CustomMarker,
2223
- {
2224
- position: { lat, lng },
2225
- width: 32,
2226
- height: 32,
2227
- bearing,
2228
- iconForm: "grua",
2229
- id: feature.id
2230
- }
2231
- )
2232
- );
2233
- }
2234
- return null;
2235
- };
2236
- const PolylineWithArrows = ({
2237
- positions,
2238
- enableEdit,
2239
- ...other
2240
- }) => {
2241
- const map = useMap();
2242
- const polylineRef = useRef(null);
2243
- const decoratorRef = useRef(null);
2244
- useEffect(() => {
2245
- if (polylineRef.current) {
2246
- const decorator = L__default.polylineDecorator(polylineRef.current, {
2247
- patterns: [
2248
- {
2249
- // offset: '20%',
2250
- repeat: 50,
2251
- symbol: L__default.Symbol.arrowHead({
2252
- pixelSize: 4,
2253
- polygon: false,
2254
- pathOptions: {
2255
- stroke: true,
2256
- color: "#ffffff",
2257
- weight: 2
2258
- }
2259
- })
2260
- }
2261
- ]
2262
- }).addTo(map);
2263
- decoratorRef.current = decorator;
2264
- if (enableEdit) {
2265
- polylineRef.current.pm.enable();
2266
- } else {
2267
- polylineRef.current.pm.disable();
2268
- }
2269
- polylineRef.current.on("pm:change", () => {
2270
- if (decoratorRef.current) {
2271
- map.removeLayer(decoratorRef.current);
2272
- }
2273
- if (polylineRef.current) {
2274
- decoratorRef.current = L__default.polylineDecorator(polylineRef.current, {
2275
- patterns: [
2276
- {
2277
- // offset: '20%',
2278
- repeat: 40,
2279
- symbol: L__default.Symbol.arrowHead({
2280
- pixelSize: 4,
2281
- polygon: false,
2282
- pathOptions: {
2283
- stroke: true,
2284
- color: "#cc0000",
2285
- weight: 2
2286
- }
2287
- })
2288
- }
2289
- ]
2290
- }).addTo(map);
2291
- }
2292
- });
2293
- return () => {
2294
- if (decoratorRef.current) {
2295
- map.removeLayer(decoratorRef.current);
2296
- }
2297
- };
2298
- }
2299
- }, [map, enableEdit]);
2300
- return /* @__PURE__ */ jsx(Polyline, { positions, ref: polylineRef, ...other });
2301
- };
2302
- const CommonFeatureRender = (props) => {
2303
- const { id, layerId } = props;
2304
- const feature = useMapStore((state) => {
2305
- const gObject = state.hashLayers[layerId].geoJsonObject;
2306
- if (!gObject) {
2307
- return null;
2308
- }
2309
- if (gObject.object.type === "Feature") {
2310
- return {
2311
- id: gObject.object.id,
2312
- geometry: gObject.object.geometry,
2313
- properties: gObject.object.properties,
2314
- featureLabel: gObject.object.featureLabel
2315
- };
2316
- } else {
2317
- const feat = gObject.object.features.find((f) => f.id === id);
2318
- if (feat) {
2319
- return {
2320
- id: feat.id,
2321
- geometry: feat.geometry,
2322
- properties: feat.properties,
2323
- featureLabel: feat.featureLabel
2324
- };
2325
- }
2326
- return null;
2327
- }
2328
- }, shallow);
2329
- const { addLayerDataToFeature } = useMapStore((state) => state.mapActions, shallow);
2330
- const [svg, setSvg] = useState(null);
2331
- useEffect(() => {
2332
- if (!feature) {
2333
- return;
2334
- }
2335
- if (feature.geometry?.type === "Point" && (feature.properties?.subType === "Marker" || feature.properties?.subType === void 0)) {
2336
- const { iconUrl, markerColor = MARKER_COLOR_DEFAULT } = feature?.properties;
2337
- const fetchData = async () => {
2338
- if (svg && svg.path === iconUrl && svg.color === markerColor) {
2339
- return;
2340
- }
2341
- let data;
2342
- if (iconUrl) {
2343
- data = await fetch(iconUrl).then((i) => i.text());
2344
- }
2345
- if (!data) {
2346
- data = SVG_ICON_DEFAULT;
2347
- }
2348
- data = "data:image/svg+xml;base64," + btoa((data || "").replace(/#1E96DC/g, markerColor));
2349
- setSvg({
2350
- color: markerColor,
2351
- path: iconUrl,
2352
- data
2353
- });
2354
- };
2355
- fetchData();
2356
- }
2357
- }, [feature]);
2358
- if (!feature) {
2359
- return null;
2360
- }
2361
- const propFeature = {
2362
- featureId: feature.id
2363
- };
2364
- const onAddPointLayer = useCallback((e) => {
2365
- const layerData = {
2366
- // visible: true,
2367
- boundsNW: e.target?._latlng,
2368
- boundsSE: e.target?._latlng
2369
- };
2370
- addLayerDataToFeature(layerId, feature.id, layerData);
2371
- }, []);
2372
- const onAddMultipointLayer = useCallback((e) => {
2373
- const layerData = {
2374
- // visible: true,
2375
- boundsNW: e.target.getBounds().getNorthWest(),
2376
- boundsSE: e.target.getBounds().getSouthEast()
2377
- };
2378
- addLayerDataToFeature(layerId, feature.id, layerData);
2379
- }, []);
2380
- if (feature.geometry?.type === "Point") {
2381
- const [lng, lat] = feature.geometry.coordinates;
2382
- if (feature.properties?.subType === "Marker" || feature.properties?.subType === void 0) {
2383
- const {
2384
- iconUrl: urlIcon,
2385
- iconBearing = 0,
2386
- iconOffsetRotate = 0,
2387
- scaleIcon = 1,
2388
- iconHeight,
2389
- iconWidth,
2390
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2391
- className,
2392
- label,
2393
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2394
- markerColor = MARKER_COLOR_DEFAULT,
2395
- labelBkColor = LABEL_BK_COLOR_DEFAULT,
2396
- labelColor = LABEL_COLOR_DEFAULT,
2397
- offsetLeftTop = [42, 0],
2398
- ...styleProperties
2399
- } = feature.properties;
2400
- if (urlIcon && !svg) {
2401
- return null;
2402
- }
2403
- return /* @__PURE__ */ jsx(
2404
- MarkerIconLabel,
2405
- {
2406
- position: { lat, lng },
2407
- ...{
2408
- label,
2409
- iconSrc: svg?.data,
2410
- iconScale: scaleIcon,
2411
- iconRotate: bearingRawToCSS(iconBearing, iconOffsetRotate),
2412
- iconWidth,
2413
- iconHeight,
2414
- labelBkColor,
2415
- labelColor,
2416
- offsetLeftTop
2417
- },
2418
- draggable: false,
2419
- eventHandlers: {
2420
- add: onAddPointLayer
2421
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
2422
- // click: _e => {
2423
- // },
2424
- },
2425
- ...styleProperties,
2426
- ...propFeature
2427
- },
2428
- Math.random()
2429
- );
2430
- } else if (feature.properties?.subType === "Circle" && feature.properties?.radius) {
2431
- const { subType, radius, ...styleProperties } = feature.properties;
2432
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2433
- /* @__PURE__ */ jsx(
2434
- Circle,
2435
- {
2436
- center: { lat, lng },
2437
- radius: feature.properties?.radius,
2438
- eventHandlers: {
2439
- add: onAddMultipointLayer
2440
- // remove: () => {
2441
- // removeLefletLayerToFeature(layerId, feature.id)
2442
- // },
2443
- },
2444
- ...styleProperties,
2445
- ...propFeature
2446
- },
2447
- Math.random()
2448
- ),
2449
- feature?.featureLabel && /* @__PURE__ */ jsx(
2450
- MarkerIconLabel,
2451
- {
2452
- position: [lat + feature.properties.radius / 111319, lng],
2453
- ...feature?.featureLabel
2454
- }
2455
- )
2456
- ] });
2457
- }
2458
- } else if (feature.geometry?.type === "LineString") {
2459
- const polylinePositions = feature.geometry.coordinates.map(
2460
- (coord) => [coord[1], coord[0]]
2461
- );
2462
- if (feature.properties?.subType === "PolylineWithArrows") {
2463
- return /* @__PURE__ */ jsx(
2464
- PolylineWithArrows,
2465
- {
2466
- positions: polylinePositions,
2467
- stroke: true,
2468
- weight: 10,
2469
- eventHandlers: {
2470
- add: onAddMultipointLayer
2471
- // remove: () => {;
2472
- // removeLefletLayerToFeature(layerId, feature.id)
2473
- // },
2474
- },
2475
- dashArray: "20 30",
2476
- ...feature.properties,
2477
- ...propFeature
2478
- },
2479
- Math.random()
2480
- );
2481
- } else {
2482
- return /* @__PURE__ */ jsx(
2483
- Polyline,
2484
- {
2485
- positions: polylinePositions,
2486
- stroke: true,
2487
- weight: 10,
2488
- eventHandlers: {
2489
- add: onAddMultipointLayer
2490
- // remove: () => {
2491
- // removeLefletLayerToFeature(layerId, feature.id)
2492
- // },
2493
- },
2494
- dashArray: "20 30",
2495
- ...feature.properties,
2496
- ...propFeature
2497
- },
2498
- Math.random()
2499
- );
2500
- }
2501
- } else if (feature.geometry?.type === "Polygon") {
2502
- const polygonPositions = feature.geometry.coordinates.map(
2503
- (ring) => ring.map(([lng, lat]) => [lat, lng])
2504
- );
2505
- let topRightPoint = null;
2506
- polygonPositions[0].forEach((coord) => {
2507
- const [lat, lng] = coord;
2508
- if (!topRightPoint || lat >= topRightPoint[0] && lng >= topRightPoint[1]) {
2509
- topRightPoint = coord;
2510
- }
2511
- });
2512
- topRightPoint = topRightPoint || polygonPositions[0][0];
2513
- return /* @__PURE__ */ jsxs(React__default.Fragment, { children: [
2514
- /* @__PURE__ */ jsx(
2515
- Polygon,
2516
- {
2517
- positions: polygonPositions,
2518
- opacity: 1,
2519
- eventHandlers: {
2520
- add: onAddMultipointLayer
2521
- // remove: () => {
2522
- // removeLefletLayerToFeature(layerId, feature.id)
2523
- // },
2524
- },
2525
- ...feature.properties,
2526
- ...propFeature
2527
- }
2528
- ),
2529
- feature?.featureLabel && /* @__PURE__ */ jsx(MarkerIconLabel, { position: topRightPoint, ...feature?.featureLabel })
2530
- ] });
2531
- }
2532
- return null;
2533
- };
2534
- export {
2535
- CommonFeatureRender as C,
2536
- GPS_TOOLS_POPUP_ID as G,
2537
- LABEL_BK_COLOR_DEFAULT as L,
2538
- Map$1 as M,
2539
- LABEL_COLOR_DEFAULT as a,
2540
- MapProvider as b,
2541
- MapContext as c,
2542
- MarkerFeatureRender as d,
2543
- mapClasses as m,
2544
- useMapStore as u
2545
- };