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