@terraware/web-components 5.0.27 → 5.1.0
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/components/AntSwitch/index.js +19 -22
- package/components/Autocomplete/Autocomplete.js +106 -130
- package/components/Badge/index.js +28 -29
- package/components/BusySpinner/index.js +40 -45
- package/components/Button/Button.js +41 -47
- package/components/Checkbox.js +64 -63
- package/components/Confirm/index.js +74 -83
- package/components/DatePicker/DatePicker.js +138 -141
- package/components/DialogBox/DialogBox.js +111 -118
- package/components/Divisor.js +18 -18
- package/components/Dropdown.js +66 -94
- package/components/EditableTable/index.js +211 -271
- package/components/ErrorBox/ErrorBox.js +47 -49
- package/components/FileChooser/index.js +117 -135
- package/components/FormBottomBar/index.js +75 -84
- package/components/Icon/Icon.js +12 -20
- package/components/Icon/icons/index.js +256 -256
- package/components/IconTooltip/index.js +49 -60
- package/components/Map/MapBox.js +545 -452
- package/components/Map/MapContainer.js +25 -29
- package/components/Map/MapDateSliderControl.js +64 -64
- package/components/Map/MapDrawer.js +41 -47
- package/components/Map/MapLegend.js +176 -172
- package/components/Map/MapViewStyleControl.js +59 -63
- package/components/Map/ReactMapboxWrapper.js +3 -2
- package/components/Map/index.js +161 -180
- package/components/Map/types.js +12 -17
- package/components/Map/useMaintainLayerOrder.js +16 -26
- package/components/Markdown/index.js +25 -26
- package/components/Message/Message.js +73 -76
- package/components/MultiSelect/index.js +112 -124
- package/components/Navbar/NavFooter.js +9 -13
- package/components/Navbar/NavItem.js +70 -76
- package/components/Navbar/NavSection.js +17 -19
- package/components/Navbar/Navbar.js +39 -46
- package/components/Navbar/SubNavbar.js +9 -13
- package/components/Note.js +18 -22
- package/components/OverlayModal/OverlayModal.js +56 -63
- package/components/PageForm/index.js +33 -41
- package/components/PhotoChooser/index.js +165 -173
- package/components/PhotosCarousel/PhotoSlide.js +32 -35
- package/components/PhotosCarousel/index.js +80 -85
- package/components/PhotosCarousel/usePhotosCarousel.js +69 -76
- package/components/Pill/index.js +41 -45
- package/components/PillList/index.js +17 -24
- package/components/PlacementWrapper/index.js +38 -59
- package/components/PopoverMenu/Popover.js +68 -85
- package/components/PopoverMenu/index.js +51 -56
- package/components/PopoverMultiSelect/index.js +52 -59
- package/components/ProgressCircle/ProgressCircle.js +28 -32
- package/components/RadioButton.js +17 -19
- package/components/Select/Select.js +13 -15
- package/components/Select/SelectT.js +235 -250
- package/components/Separator/index.js +14 -17
- package/components/Size.js +0 -1
- package/components/Slider/index.js +43 -56
- package/components/SummaryBox.js +70 -72
- package/components/Tabs/index.js +133 -135
- package/components/TextTruncated/index.js +117 -130
- package/components/Textfield/Textfield.js +158 -190
- package/components/Textfield/TruncatedTextArea.js +70 -84
- package/components/TimelineSlider/TimelineMarker.js +25 -30
- package/components/TimelineSlider/TimelineRail.js +8 -11
- package/components/TimelineSlider/index.js +64 -66
- package/components/TimelineSliderV2/ClusterBadge.js +25 -29
- package/components/TimelineSliderV2/TimelineDot.js +31 -35
- package/components/TimelineSliderV2/TimelineRail.js +8 -11
- package/components/TimelineSliderV2/index.js +121 -103
- package/components/TimelineSliderV2/layout.js +124 -147
- package/components/TimelineSliderV2/types.js +0 -1
- package/components/Tooltip/Tooltip.js +47 -56
- package/components/ViewPhotosDialog/index.js +28 -35
- package/components/VirtualWalkthrough/Annotation.js +163 -207
- package/components/VirtualWalkthrough/AnnotationEditPane.js +198 -184
- package/components/VirtualWalkthrough/AnnotationPanel.js +187 -199
- package/components/VirtualWalkthrough/Application.js +31 -34
- package/components/VirtualWalkthrough/AutoRotator.js +85 -223
- package/components/VirtualWalkthrough/BlockingSpinner.js +26 -28
- package/components/VirtualWalkthrough/BoundaryRing.js +30 -34
- package/components/VirtualWalkthrough/BoundaryWall.js +32 -36
- package/components/VirtualWalkthrough/CameraInfo.js +100 -89
- package/components/VirtualWalkthrough/ControlsInfoPane.js +254 -195
- package/components/VirtualWalkthrough/GradientSky.js +72 -73
- package/components/VirtualWalkthrough/SplatControls.js +209 -221
- package/components/VirtualWalkthrough/SplatCrop.js +21 -20
- package/components/VirtualWalkthrough/SplatFadeCrop.js +21 -20
- package/components/VirtualWalkthrough/SplatModel.js +65 -85
- package/components/VirtualWalkthrough/SplatRevealRain.js +41 -46
- package/components/VirtualWalkthrough/TfAnnotationManager.js +197 -379
- package/components/VirtualWalkthrough/TfXrNavigation.js +73 -162
- package/components/VirtualWalkthrough/VirtualWalkthroughViewer.js +438 -431
- package/components/VirtualWalkthrough/VrAnnotationPanel.js +18 -22
- package/components/VirtualWalkthrough/XrAnnotationInteraction.js +14 -17
- package/components/VirtualWalkthrough/XrExitButton.js +14 -17
- package/components/VirtualWalkthrough/XrGazeDwell.js +14 -17
- package/components/VirtualWalkthrough/XrPointerRay.js +14 -17
- package/components/VirtualWalkthrough/XrStartPose.js +67 -121
- package/components/VirtualWalkthrough/boundary-ring.js +87 -117
- package/components/VirtualWalkthrough/boundary-wall.js +175 -258
- package/components/VirtualWalkthrough/camera-adoption.js +18 -64
- package/components/VirtualWalkthrough/groundPlane.js +32 -47
- package/components/VirtualWalkthrough/gsplat-fade-crop-effect.js +35 -35
- package/components/VirtualWalkthrough/splatFormat.js +13 -47
- package/components/VirtualWalkthrough/useAdoptedCamera.js +23 -44
- package/components/VirtualWalkthrough/useRestartOnVr.js +26 -37
- package/components/VirtualWalkthrough/useXrRenderTuning.js +33 -54
- package/components/VirtualWalkthrough/vr-annotation-panel-layout.js +67 -99
- package/components/VirtualWalkthrough/vr-annotation-panel.js +403 -433
- package/components/VirtualWalkthrough/vr-annotation-scroll.js +10 -28
- package/components/VirtualWalkthrough/walkthrough-camera.js +204 -329
- package/components/VirtualWalkthrough/xr-annotation-candidate-buffer.js +39 -80
- package/components/VirtualWalkthrough/xr-annotation-candidates.js +6 -18
- package/components/VirtualWalkthrough/xr-annotation-interaction.js +31 -56
- package/components/VirtualWalkthrough/xr-annotation-targeting.js +22 -38
- package/components/VirtualWalkthrough/xr-button-arming.js +7 -17
- package/components/VirtualWalkthrough/xr-button-hold.js +22 -36
- package/components/VirtualWalkthrough/xr-exit-button-mask.js +22 -36
- package/components/VirtualWalkthrough/xr-exit-button.js +148 -207
- package/components/VirtualWalkthrough/xr-face-buttons.js +19 -29
- package/components/VirtualWalkthrough/xr-gaze-dwell-state.js +23 -34
- package/components/VirtualWalkthrough/xr-gaze-dwell.js +107 -144
- package/components/VirtualWalkthrough/xr-interactive-ui.js +12 -24
- package/components/VirtualWalkthrough/xr-pointer-ray.js +13 -20
- package/components/VirtualWalkthrough/xr-progress-pie-material.js +117 -88
- package/components/VirtualWalkthrough/xr-progress-pie.js +1 -10
- package/components/VirtualWalkthrough/xr-ray-quad.js +16 -30
- package/components/VirtualWalkthrough/xr-render-tuning.js +17 -48
- package/components/VirtualWalkthrough/xr-scene-bounds.js +21 -37
- package/components/VirtualWalkthrough/xr-start-pose.js +27 -73
- package/components/VirtualWalkthrough/xr-teleport-gesture.js +16 -42
- package/components/svg/BlobbyGrayIconImage.js +41 -39
- package/components/svg/BlobbyGrayIconImport.js +41 -39
- package/components/svg/BlobbyGrayIconUploadToTheCloud.js +41 -39
- package/components/svg/BlobbyIconCloudChecked.js +202 -164
- package/components/svg/BlobbyIconExportOrUploadPhoto.js +202 -164
- package/components/svg/BlobbyIconFolder.js +202 -164
- package/components/svg/BlobbyIconGraphReport.js +202 -164
- package/components/svg/BlobbyIconHappy.js +202 -164
- package/components/svg/BlobbyIconHeartMonitor.js +202 -164
- package/components/svg/BlobbyIconLeaf.js +202 -164
- package/components/svg/BlobbyIconLibrary.js +202 -164
- package/components/svg/BlobbyIconNursery.js +204 -166
- package/components/svg/BlobbyIconOrganization.js +202 -164
- package/components/svg/BlobbyIconParchment.js +202 -164
- package/components/svg/BlobbyIconPeople.js +202 -164
- package/components/svg/BlobbyIconSeedBank.js +202 -164
- package/components/svg/BlobbyIconSeedling.js +202 -164
- package/components/svg/BlobbyIconSeeds.js +202 -164
- package/components/svg/BlobbyIconSite.js +206 -167
- package/components/svg/BlobbyIconSparkles.js +202 -164
- package/components/svg/BlobbyIconWrench.js +202 -164
- package/components/svg/Bug.js +19 -21
- package/components/svg/Calendar.js +19 -21
- package/components/svg/CaretDown.js +19 -21
- package/components/svg/CaretLeft.js +19 -21
- package/components/svg/CaretRight.js +19 -21
- package/components/svg/CaretUp.js +19 -21
- package/components/svg/ChevronDown.js +19 -21
- package/components/svg/ChevronUp.js +19 -21
- package/components/svg/Close.js +19 -21
- package/components/svg/Critical.js +19 -21
- package/components/svg/Edit.js +202 -164
- package/components/svg/Error.js +19 -21
- package/components/svg/Filter.js +19 -21
- package/components/svg/Folder.js +19 -21
- package/components/svg/Help.js +19 -21
- package/components/svg/Home.js +19 -21
- package/components/svg/IconAdd.js +19 -21
- package/components/svg/IconArrowRight.js +21 -23
- package/components/svg/IconBusinessNetwork.js +19 -21
- package/components/svg/IconCalendar.js +19 -21
- package/components/svg/IconCancel.js +19 -21
- package/components/svg/IconChargingBattery.js +19 -21
- package/components/svg/IconChecklist.js +21 -23
- package/components/svg/IconCheckmark.js +19 -21
- package/components/svg/IconCoinInHand.js +19 -21
- package/components/svg/IconColumns.js +19 -21
- package/components/svg/IconComment.js +20 -22
- package/components/svg/IconDashboard.js +19 -21
- package/components/svg/IconDataMigration.js +19 -21
- package/components/svg/IconDocument.js +21 -23
- package/components/svg/IconDownloadFromTheCloud.js +21 -23
- package/components/svg/IconEdit.js +21 -23
- package/components/svg/IconExpand.js +21 -23
- package/components/svg/IconExport.js +19 -21
- package/components/svg/IconExternalLink.js +19 -21
- package/components/svg/IconEye.js +19 -21
- package/components/svg/IconEyeOff.js +19 -21
- package/components/svg/IconFile.js +19 -21
- package/components/svg/IconFolder.js +19 -21
- package/components/svg/IconFullScreen.js +20 -22
- package/components/svg/IconFutures.js +19 -21
- package/components/svg/IconGraphReport.js +19 -21
- package/components/svg/IconGrid.js +19 -21
- package/components/svg/IconHeartMonitor.js +19 -21
- package/components/svg/IconHelp.js +21 -23
- package/components/svg/IconHistory.js +19 -21
- package/components/svg/IconImport.js +19 -21
- package/components/svg/IconIndex.js +19 -21
- package/components/svg/IconLayers.js +19 -21
- package/components/svg/IconLibrary.js +20 -22
- package/components/svg/IconList.js +19 -21
- package/components/svg/IconLivePlant.js +19 -21
- package/components/svg/IconLocations.js +19 -21
- package/components/svg/IconMail.js +19 -21
- package/components/svg/IconManager.js +19 -21
- package/components/svg/IconMap.js +19 -21
- package/components/svg/IconMarker.js +19 -21
- package/components/svg/IconMenu.js +19 -21
- package/components/svg/IconMenuHorizontal.js +19 -21
- package/components/svg/IconModule.js +19 -21
- package/components/svg/IconMyLocation.js +19 -21
- package/components/svg/IconNote.js +21 -23
- package/components/svg/IconNursery.js +21 -23
- package/components/svg/IconOrg.js +19 -21
- package/components/svg/IconParchment.js +19 -21
- package/components/svg/IconPhoto.js +19 -21
- package/components/svg/IconPlantsFilled.js +19 -21
- package/components/svg/IconRedo.js +19 -21
- package/components/svg/IconRestorationSite.js +19 -21
- package/components/svg/IconSeedBank.js +19 -21
- package/components/svg/IconSeedling.js +19 -21
- package/components/svg/IconSettings.js +19 -21
- package/components/svg/IconSlice.js +19 -21
- package/components/svg/IconSubmit.js +19 -21
- package/components/svg/IconSubtract.js +21 -23
- package/components/svg/IconSynced.js +19 -21
- package/components/svg/IconTrashCan.js +19 -21
- package/components/svg/IconTreasureMap.js +19 -21
- package/components/svg/IconUnavailable.js +19 -21
- package/components/svg/IconUndo.js +19 -21
- package/components/svg/IconVariable.js +19 -21
- package/components/svg/IconVideo.js +30 -31
- package/components/svg/IconWifi.js +19 -21
- package/components/svg/Info.js +19 -21
- package/components/svg/Key.js +19 -21
- package/components/svg/Leaf.js +19 -21
- package/components/svg/Lock.js +19 -21
- package/components/svg/Logo.js +48 -43
- package/components/svg/MenuVertical.js +19 -21
- package/components/svg/Notification.js +19 -21
- package/components/svg/Person.js +19 -21
- package/components/svg/Plus.js +19 -21
- package/components/svg/RestorationSite.js +19 -21
- package/components/svg/Search.js +19 -21
- package/components/svg/Seeds.js +19 -21
- package/components/svg/Site.js +19 -21
- package/components/svg/Sparkles.js +19 -21
- package/components/svg/Species.js +19 -21
- package/components/svg/Species2.js +202 -164
- package/components/svg/Spinner.js +54 -48
- package/components/svg/Star.js +19 -21
- package/components/svg/Success.js +19 -21
- package/components/svg/SuccessFilled.js +19 -21
- package/components/svg/TerrawareLogoDesktop.js +55 -49
- package/components/svg/TerrawareLogoMobile.js +25 -26
- package/components/svg/Touchscreen.js +19 -21
- package/components/svg/UploadCloud.js +202 -164
- package/components/svg/Warning.js +19 -21
- package/components/svg/WelcomeClipboard.js +156 -133
- package/components/svg/index.js +129 -129
- package/components/table/EnhancedTableToolbar.js +68 -74
- package/components/table/EnhancedTableToolbarV2.js +31 -41
- package/components/table/TableCellRenderer.js +196 -231
- package/components/table/TableHeader.js +71 -73
- package/components/table/TableHeaderItem.js +97 -102
- package/components/table/density.js +18 -19
- package/components/table/index.js +350 -369
- package/components/table/sort.js +27 -52
- package/components/table/types.js +0 -1
- package/components/types/index.js +0 -1
- package/hooks/cameraEntityContext.js +2 -13
- package/hooks/useBoolean.js +17 -13
- package/hooks/useCameraPosition.js +56 -56
- package/hooks/useDevicePerformance.js +17 -17
- package/hooks/useXr.js +85 -87
- package/index.js +58 -58
- package/package.json +1 -1
- package/setupTests.js +0 -4
- package/strings/export.js +111 -170
- package/strings/index.js +25 -54
- package/strings/locales.js +21 -41
- package/strings/strings-en.js +49 -51
- package/strings/strings-es.js +49 -51
- package/strings/strings-fr.js +49 -51
- package/strings/strings-gx.js +49 -51
- package/style-dictionary-dist/TerrawareTheme.js +186 -186
- package/theme.js +74 -76
- package/utils/color.js +8 -15
- package/utils/date.js +42 -108
- package/utils/index.js +4 -4
- package/utils/preventDefaultEvent.js +3 -3
- package/utils/text.js +11 -11
- package/utils/useDeviceInfo.js +42 -79
- package/virtualWalkthrough.js +23 -23
package/components/Map/MapBox.js
CHANGED
|
@@ -1,461 +1,554 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { stylesUrl } from
|
|
11
|
-
import { useMaintainLayerOrder } from
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
hideFullScreenControl,
|
|
27
|
-
hideMapViewStyleControl,
|
|
28
|
-
hideZoomControl,
|
|
29
|
-
highlightGroups,
|
|
30
|
-
initialViewState,
|
|
31
|
-
mapId,
|
|
32
|
-
mapImageUrls,
|
|
33
|
-
mapViewStyle,
|
|
34
|
-
markerGroups,
|
|
35
|
-
onClickCanvas,
|
|
36
|
-
setMapViewStyle,
|
|
37
|
-
token
|
|
38
|
-
} = props;
|
|
39
|
-
const theme = useTheme();
|
|
40
|
-
const mapRef = useRef(null);
|
|
41
|
-
const {
|
|
42
|
-
isDesktop
|
|
43
|
-
} = useDeviceInfo();
|
|
44
|
-
const [cursor, setCursor] = useState('auto');
|
|
45
|
-
const [hoverFeatureId, setHoverFeatureId] = useState();
|
|
46
|
-
const [zoom, setZoom] = useState();
|
|
47
|
-
const loadImages = useCallback(map => {
|
|
48
|
-
mapImageUrls?.forEach(url => {
|
|
49
|
-
if (!map.hasImage(url)) {
|
|
50
|
-
map.loadImage(url, (error, image) => {
|
|
51
|
-
if (image) {
|
|
52
|
-
map.addImage(url, image, {
|
|
53
|
-
sdf: true
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { FullscreenControl, Layer, Marker, NavigationControl, Source } from "react-map-gl/mapbox";
|
|
4
|
+
import { Box, useTheme } from "@mui/material";
|
|
5
|
+
import "mapbox-gl/dist/mapbox-gl.css";
|
|
6
|
+
import { useDeviceInfo } from "../../utils/index.js";
|
|
7
|
+
import Icon from "../Icon/Icon.js";
|
|
8
|
+
import MapViewStyleControl from "./MapViewStyleControl.js";
|
|
9
|
+
import ReactMapboxWrapper from "./ReactMapboxWrapper.js";
|
|
10
|
+
import { stylesUrl } from "./types.js";
|
|
11
|
+
import { useMaintainLayerOrder } from "./useMaintainLayerOrder.js";
|
|
12
|
+
const MapBox = (props)=>{
|
|
13
|
+
const { clusterRadius, containerId, controlBottomLeft, controlTopRight, cursorInteract, cursorMap, disableDoubleClickZoom, disableZoom, drawerOpen, layers: featureGroups, hideFullScreenControl, hideMapViewStyleControl, hideZoomControl, highlightGroups, initialViewState, mapId, mapImageUrls, mapViewStyle, markerGroups, onClickCanvas, setMapViewStyle, token } = props;
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
const mapRef = useRef(null);
|
|
16
|
+
const { isDesktop } = useDeviceInfo();
|
|
17
|
+
const [cursor, setCursor] = useState('auto');
|
|
18
|
+
const [hoverFeatureId, setHoverFeatureId] = useState();
|
|
19
|
+
const [zoom, setZoom] = useState();
|
|
20
|
+
const loadImages = useCallback((map)=>{
|
|
21
|
+
mapImageUrls?.forEach((url)=>{
|
|
22
|
+
if (!map.hasImage(url)) map.loadImage(url, (error, image)=>{
|
|
23
|
+
if (image) map.addImage(url, image, {
|
|
24
|
+
sdf: true
|
|
25
|
+
});
|
|
54
26
|
});
|
|
55
|
-
}
|
|
56
27
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
28
|
+
}, [
|
|
29
|
+
mapImageUrls
|
|
30
|
+
]);
|
|
31
|
+
const mapRefCallback = useCallback((map)=>{
|
|
32
|
+
if (null !== map) {
|
|
33
|
+
mapRef.current = map;
|
|
34
|
+
setZoom(map.getZoom());
|
|
35
|
+
loadImages(map);
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
const onMove = useCallback((view)=>{
|
|
39
|
+
setZoom(view.viewState.zoom);
|
|
40
|
+
}, []);
|
|
41
|
+
const clusterMarkers = useCallback((map, markers)=>{
|
|
42
|
+
if (!map || map.getZoom() > 15) return markers.map((marker)=>[
|
|
43
|
+
marker
|
|
44
|
+
]);
|
|
45
|
+
const visited = new Set();
|
|
46
|
+
const markerPixels = {};
|
|
47
|
+
markers.forEach((marker)=>{
|
|
48
|
+
markerPixels[marker.id] = map.project({
|
|
49
|
+
lat: marker.latitude,
|
|
50
|
+
lon: marker.longitude
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
const clusters = [];
|
|
54
|
+
markers.forEach((marker, idx)=>{
|
|
55
|
+
if (!visited.has(marker.id)) {
|
|
56
|
+
const cluster = [
|
|
57
|
+
marker
|
|
58
|
+
];
|
|
59
|
+
markers.slice(idx + 1).forEach((otherMarker)=>{
|
|
60
|
+
if (!visited.has(otherMarker.id)) {
|
|
61
|
+
const dx = markerPixels[marker.id].x - markerPixels[otherMarker.id].x;
|
|
62
|
+
const dy = markerPixels[marker.id].y - markerPixels[otherMarker.id].y;
|
|
63
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
64
|
+
if (dist <= (clusterRadius ?? 40)) {
|
|
65
|
+
cluster.push(otherMarker);
|
|
66
|
+
visited.add(otherMarker.id);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
clusters.push(cluster);
|
|
95
71
|
}
|
|
96
|
-
}
|
|
97
72
|
});
|
|
98
|
-
clusters
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
73
|
+
return clusters;
|
|
74
|
+
}, [
|
|
75
|
+
clusterRadius
|
|
76
|
+
]);
|
|
77
|
+
const interactiveLayerIds = useMemo(()=>featureGroups?.filter((group)=>group.features.some((feature)=>void 0 !== feature.onClick))?.map((group)=>group.layerId), [
|
|
78
|
+
featureGroups
|
|
79
|
+
]);
|
|
80
|
+
const geojson = useMemo(()=>{
|
|
81
|
+
const features = featureGroups?.flatMap((group)=>group.features.map((feature)=>{
|
|
82
|
+
const properties = {
|
|
83
|
+
id: feature.featureId,
|
|
84
|
+
clickable: void 0 !== feature.onClick,
|
|
85
|
+
label: feature.label,
|
|
86
|
+
layerFeatureId: `${group.layerId}/${feature.featureId}`,
|
|
87
|
+
layerId: group.layerId,
|
|
88
|
+
priority: feature.priority ?? 0,
|
|
89
|
+
selected: feature.selected ?? false
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
type: 'Feature',
|
|
93
|
+
geometry: feature.geometry,
|
|
94
|
+
properties
|
|
95
|
+
};
|
|
96
|
+
}));
|
|
97
|
+
return features ? {
|
|
98
|
+
type: 'FeatureCollection',
|
|
99
|
+
features
|
|
100
|
+
} : void 0;
|
|
101
|
+
}, [
|
|
102
|
+
featureGroups
|
|
103
|
+
]);
|
|
104
|
+
const { borderLayers, fillLayers, textLayers } = useMemo(()=>{
|
|
105
|
+
const _borderLayers = featureGroups?.map((group)=>/*#__PURE__*/ jsx(Layer, {
|
|
106
|
+
id: `${group.layerId}-border`,
|
|
107
|
+
source: 'mapData',
|
|
108
|
+
type: "line",
|
|
109
|
+
paint: {
|
|
110
|
+
'line-color': group.style.borderColor,
|
|
111
|
+
'line-width': 2
|
|
112
|
+
},
|
|
113
|
+
filter: [
|
|
114
|
+
'==',
|
|
115
|
+
[
|
|
116
|
+
'get',
|
|
117
|
+
'layerId'
|
|
118
|
+
],
|
|
119
|
+
group.layerId
|
|
120
|
+
]
|
|
121
|
+
}, `${group.layerId}-border`));
|
|
122
|
+
const _fillLayers = featureGroups?.map((group)=>{
|
|
123
|
+
const opacity = Math.min(0.4, group.style.opacity ?? 0.2);
|
|
124
|
+
const selectedOpacity = 2 * opacity;
|
|
125
|
+
const hoverOpacity = 1.5 * opacity;
|
|
126
|
+
const hoverAndSelectedOpacity = 2.5 * opacity;
|
|
127
|
+
const groupFilter = [
|
|
128
|
+
'==',
|
|
129
|
+
[
|
|
130
|
+
'get',
|
|
131
|
+
'layerId'
|
|
132
|
+
],
|
|
133
|
+
group.layerId
|
|
134
|
+
];
|
|
135
|
+
const clickableFilter = [
|
|
136
|
+
'==',
|
|
137
|
+
[
|
|
138
|
+
'get',
|
|
139
|
+
'clickable'
|
|
140
|
+
],
|
|
141
|
+
true
|
|
142
|
+
];
|
|
143
|
+
const selectedFilter = [
|
|
144
|
+
'==',
|
|
145
|
+
[
|
|
146
|
+
'get',
|
|
147
|
+
'selected'
|
|
148
|
+
],
|
|
149
|
+
true
|
|
150
|
+
];
|
|
151
|
+
const notSelectedFilter = [
|
|
152
|
+
'==',
|
|
153
|
+
[
|
|
154
|
+
'get',
|
|
155
|
+
'selected'
|
|
156
|
+
],
|
|
157
|
+
false
|
|
158
|
+
];
|
|
159
|
+
const hoverFilter = [
|
|
160
|
+
'==',
|
|
161
|
+
[
|
|
162
|
+
'get',
|
|
163
|
+
'id'
|
|
164
|
+
],
|
|
165
|
+
hoverFeatureId ?? null
|
|
166
|
+
];
|
|
167
|
+
const notHoverFilter = [
|
|
168
|
+
'!=',
|
|
169
|
+
[
|
|
170
|
+
'get',
|
|
171
|
+
'id'
|
|
172
|
+
],
|
|
173
|
+
hoverFeatureId ?? null
|
|
174
|
+
];
|
|
175
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
176
|
+
children: [
|
|
177
|
+
/*#__PURE__*/ jsx(Layer, {
|
|
178
|
+
id: group.layerId,
|
|
179
|
+
source: 'mapData',
|
|
180
|
+
type: 'fill',
|
|
181
|
+
paint: {
|
|
182
|
+
'fill-opacity': 0
|
|
183
|
+
},
|
|
184
|
+
filter: [
|
|
185
|
+
'all',
|
|
186
|
+
groupFilter,
|
|
187
|
+
clickableFilter
|
|
188
|
+
]
|
|
189
|
+
}, group.layerId),
|
|
190
|
+
/*#__PURE__*/ jsx(Layer, {
|
|
191
|
+
id: `${group.layerId}-unselected`,
|
|
192
|
+
source: 'mapData',
|
|
193
|
+
type: 'fill',
|
|
194
|
+
paint: group.style.fillPatternUrl ? {
|
|
195
|
+
'fill-pattern': group.style.fillPatternUrl,
|
|
196
|
+
'fill-opacity': opacity
|
|
197
|
+
} : {
|
|
198
|
+
'fill-color': group.style.fillColor,
|
|
199
|
+
'fill-opacity': opacity
|
|
200
|
+
},
|
|
201
|
+
filter: [
|
|
202
|
+
'all',
|
|
203
|
+
groupFilter,
|
|
204
|
+
notSelectedFilter,
|
|
205
|
+
notHoverFilter
|
|
206
|
+
]
|
|
207
|
+
}, `${group.layerId}-unselected`),
|
|
208
|
+
/*#__PURE__*/ jsx(Layer, {
|
|
209
|
+
id: `${group.layerId}-selected`,
|
|
210
|
+
slot: 'bottom',
|
|
211
|
+
source: 'mapData',
|
|
212
|
+
type: 'fill',
|
|
213
|
+
paint: group.style.fillPatternUrl ? {
|
|
214
|
+
'fill-pattern': group.style.fillPatternUrl,
|
|
215
|
+
'fill-opacity': selectedOpacity
|
|
216
|
+
} : {
|
|
217
|
+
'fill-color': group.style.fillColor,
|
|
218
|
+
'fill-opacity': selectedOpacity
|
|
219
|
+
},
|
|
220
|
+
filter: [
|
|
221
|
+
'all',
|
|
222
|
+
groupFilter,
|
|
223
|
+
selectedFilter,
|
|
224
|
+
notHoverFilter
|
|
225
|
+
]
|
|
226
|
+
}, `${group.layerId}-selected`),
|
|
227
|
+
/*#__PURE__*/ jsx(Layer, {
|
|
228
|
+
id: `${group.layerId}-hover`,
|
|
229
|
+
source: 'mapData',
|
|
230
|
+
type: 'fill',
|
|
231
|
+
paint: group.style.fillPatternUrl ? {
|
|
232
|
+
'fill-pattern': group.style.fillPatternUrl,
|
|
233
|
+
'fill-opacity': hoverOpacity
|
|
234
|
+
} : {
|
|
235
|
+
'fill-color': group.style.fillColor,
|
|
236
|
+
'fill-opacity': hoverOpacity
|
|
237
|
+
},
|
|
238
|
+
filter: [
|
|
239
|
+
'all',
|
|
240
|
+
groupFilter,
|
|
241
|
+
hoverFilter,
|
|
242
|
+
notSelectedFilter
|
|
243
|
+
]
|
|
244
|
+
}, `${group.layerId}-hover`),
|
|
245
|
+
/*#__PURE__*/ jsx(Layer, {
|
|
246
|
+
id: `${group.layerId}-selected-hover`,
|
|
247
|
+
source: 'mapData',
|
|
248
|
+
type: 'fill',
|
|
249
|
+
paint: group.style.fillPatternUrl ? {
|
|
250
|
+
'fill-pattern': group.style.fillPatternUrl,
|
|
251
|
+
'fill-opacity': hoverAndSelectedOpacity
|
|
252
|
+
} : {
|
|
253
|
+
'fill-color': group.style.fillColor,
|
|
254
|
+
'fill-opacity': hoverAndSelectedOpacity
|
|
255
|
+
},
|
|
256
|
+
filter: [
|
|
257
|
+
'all',
|
|
258
|
+
groupFilter,
|
|
259
|
+
hoverFilter,
|
|
260
|
+
selectedFilter
|
|
261
|
+
]
|
|
262
|
+
}, `${group.layerId}-selected-hover`)
|
|
263
|
+
]
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
const _textLayers = featureGroups?.map((group)=>{
|
|
267
|
+
const groupFilter = [
|
|
268
|
+
'==',
|
|
269
|
+
[
|
|
270
|
+
'get',
|
|
271
|
+
'layerId'
|
|
272
|
+
],
|
|
273
|
+
group.layerId
|
|
274
|
+
];
|
|
275
|
+
const labelFilter = [
|
|
276
|
+
'has',
|
|
277
|
+
'label'
|
|
278
|
+
];
|
|
279
|
+
return /*#__PURE__*/ jsx(Layer, {
|
|
280
|
+
id: `${group.layerId}-label`,
|
|
281
|
+
source: 'mapData',
|
|
282
|
+
type: 'symbol',
|
|
283
|
+
layout: {
|
|
284
|
+
'text-field': [
|
|
285
|
+
'get',
|
|
286
|
+
'label'
|
|
287
|
+
],
|
|
288
|
+
'text-size': 14,
|
|
289
|
+
'text-line-height': 20,
|
|
290
|
+
'text-font': [
|
|
291
|
+
'Open Sans Bold',
|
|
292
|
+
'Arial Unicode MS Regular'
|
|
293
|
+
],
|
|
294
|
+
'text-anchor': 'center',
|
|
295
|
+
'text-justify': 'center'
|
|
296
|
+
},
|
|
297
|
+
paint: {
|
|
298
|
+
'text-color': '#ffffff'
|
|
299
|
+
},
|
|
300
|
+
filter: [
|
|
301
|
+
'all',
|
|
302
|
+
groupFilter,
|
|
303
|
+
labelFilter
|
|
304
|
+
]
|
|
305
|
+
}, `${group.layerId}-label`);
|
|
306
|
+
});
|
|
120
307
|
return {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
308
|
+
borderLayers: _borderLayers ?? [],
|
|
309
|
+
fillLayers: _fillLayers ?? [],
|
|
310
|
+
textLayers: _textLayers ?? []
|
|
124
311
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
},
|
|
239
|
-
filter: ['all', groupFilter, labelFilter]
|
|
240
|
-
}, `${group.layerId}-label`);
|
|
241
|
-
});
|
|
242
|
-
return {
|
|
243
|
-
borderLayers: _borderLayers ?? [],
|
|
244
|
-
fillLayers: _fillLayers ?? [],
|
|
245
|
-
textLayers: _textLayers ?? []
|
|
246
|
-
};
|
|
247
|
-
}, [featureGroups, hoverFeatureId]);
|
|
248
|
-
const highlightLayers = useMemo(() => {
|
|
249
|
-
return highlightGroups?.flatMap(group => {
|
|
250
|
-
return group.highlights.map((highlight, index) => {
|
|
251
|
-
const highlightFeatureIds = highlight.featureIds.map(({
|
|
252
|
-
layerId,
|
|
253
|
-
featureId
|
|
254
|
-
}) => `${layerId}/${featureId}`);
|
|
255
|
-
return /*#__PURE__*/jsx(Layer, {
|
|
256
|
-
id: `highlight-${group.highlightId}-${index}`,
|
|
257
|
-
source: 'mapData',
|
|
258
|
-
type: 'fill',
|
|
259
|
-
paint: highlight.style.fillPatternUrl ? {
|
|
260
|
-
'fill-pattern': highlight.style.fillPatternUrl,
|
|
261
|
-
'fill-opacity': highlight.style.opacity ?? 0.5
|
|
262
|
-
} : {
|
|
263
|
-
'fill-color': highlight.style.fillColor,
|
|
264
|
-
'fill-opacity': highlight.style.opacity ?? 0.5
|
|
265
|
-
},
|
|
266
|
-
filter: ['all', ['has', 'layerFeatureId'], ['match', ['get', 'layerFeatureId'], highlightFeatureIds, true, false]]
|
|
267
|
-
}, `highlight-${group.highlightId}-${index}`);
|
|
268
|
-
});
|
|
269
|
-
}) ?? [];
|
|
270
|
-
}, [highlightGroups]);
|
|
271
|
-
const markersComponents = useMemo(() => {
|
|
272
|
-
return markerGroups?.flatMap(markerGroup => {
|
|
273
|
-
// cluster markers here
|
|
274
|
-
const clusteredMarkers = clusterMarkers(mapRef.current, markerGroup.markers);
|
|
275
|
-
return clusteredMarkers.map((markers, i) => {
|
|
276
|
-
if (markers.length === 1) {
|
|
277
|
-
const marker = markers[0];
|
|
278
|
-
return /*#__PURE__*/jsx(Marker, {
|
|
279
|
-
className: "map-marker",
|
|
280
|
-
longitude: marker.longitude,
|
|
281
|
-
latitude: marker.latitude,
|
|
282
|
-
anchor: "center",
|
|
283
|
-
onClick: event => {
|
|
284
|
-
marker.onClick?.();
|
|
285
|
-
event.originalEvent.stopPropagation();
|
|
286
|
-
},
|
|
287
|
-
style: {
|
|
288
|
-
backgroundColor: marker.selected ? markerGroup.style.iconColor : theme.palette.TwClrBg
|
|
289
|
-
},
|
|
290
|
-
children: /*#__PURE__*/jsx(Icon, {
|
|
291
|
-
fillColor: marker.selected ? theme.palette.TwClrBg : markerGroup.style.iconColor,
|
|
292
|
-
name: markerGroup.style.iconName,
|
|
293
|
-
size: 'small'
|
|
294
|
-
})
|
|
295
|
-
}, `marker-${i}`);
|
|
296
|
-
} else if (markers.length > 1) {
|
|
297
|
-
const latSum = markers.reduce((sum, marker) => sum + marker.latitude, 0);
|
|
298
|
-
const lngSum = markers.reduce((sum, marker) => sum + marker.longitude, 0);
|
|
299
|
-
const latAvg = latSum / markers.length;
|
|
300
|
-
const lngAvg = lngSum / markers.length;
|
|
301
|
-
const selected = markers.some(marker => marker.selected);
|
|
302
|
-
return /*#__PURE__*/jsxs(Marker, {
|
|
303
|
-
className: "map-marker map-marker--cluster",
|
|
304
|
-
longitude: lngAvg,
|
|
305
|
-
latitude: latAvg,
|
|
306
|
-
anchor: "center",
|
|
307
|
-
onClick: event => {
|
|
308
|
-
mapRef.current?.easeTo({
|
|
309
|
-
center: {
|
|
310
|
-
lat: latAvg,
|
|
311
|
-
lon: lngAvg
|
|
312
|
-
},
|
|
313
|
-
zoom: (zoom ?? 10) + 1,
|
|
314
|
-
duration: 500
|
|
315
|
-
});
|
|
316
|
-
event.originalEvent.stopPropagation();
|
|
317
|
-
},
|
|
318
|
-
style: {
|
|
319
|
-
backgroundColor: selected ? markerGroup.style.iconColor : theme.palette.TwClrBg
|
|
320
|
-
},
|
|
321
|
-
children: [/*#__PURE__*/jsx("p", {
|
|
322
|
-
className: "count",
|
|
323
|
-
children: markers.length
|
|
324
|
-
}), /*#__PURE__*/jsx(Icon, {
|
|
325
|
-
fillColor: selected ? theme.palette.TwClrBg : markerGroup.style.iconColor,
|
|
326
|
-
name: markerGroup.style.iconName,
|
|
327
|
-
size: 'small'
|
|
328
|
-
})]
|
|
329
|
-
}, `marker-${i}`);
|
|
312
|
+
}, [
|
|
313
|
+
featureGroups,
|
|
314
|
+
hoverFeatureId
|
|
315
|
+
]);
|
|
316
|
+
const highlightLayers = useMemo(()=>highlightGroups?.flatMap((group)=>group.highlights.map((highlight, index)=>{
|
|
317
|
+
const highlightFeatureIds = highlight.featureIds.map(({ layerId, featureId })=>`${layerId}/${featureId}`);
|
|
318
|
+
return /*#__PURE__*/ jsx(Layer, {
|
|
319
|
+
id: `highlight-${group.highlightId}-${index}`,
|
|
320
|
+
source: 'mapData',
|
|
321
|
+
type: 'fill',
|
|
322
|
+
paint: highlight.style.fillPatternUrl ? {
|
|
323
|
+
'fill-pattern': highlight.style.fillPatternUrl,
|
|
324
|
+
'fill-opacity': highlight.style.opacity ?? 0.5
|
|
325
|
+
} : {
|
|
326
|
+
'fill-color': highlight.style.fillColor,
|
|
327
|
+
'fill-opacity': highlight.style.opacity ?? 0.5
|
|
328
|
+
},
|
|
329
|
+
filter: [
|
|
330
|
+
'all',
|
|
331
|
+
[
|
|
332
|
+
'has',
|
|
333
|
+
'layerFeatureId'
|
|
334
|
+
],
|
|
335
|
+
[
|
|
336
|
+
'match',
|
|
337
|
+
[
|
|
338
|
+
'get',
|
|
339
|
+
'layerFeatureId'
|
|
340
|
+
],
|
|
341
|
+
highlightFeatureIds,
|
|
342
|
+
true,
|
|
343
|
+
false
|
|
344
|
+
]
|
|
345
|
+
]
|
|
346
|
+
}, `highlight-${group.highlightId}-${index}`);
|
|
347
|
+
})) ?? [], [
|
|
348
|
+
highlightGroups
|
|
349
|
+
]);
|
|
350
|
+
const markersComponents = useMemo(()=>markerGroups?.flatMap((markerGroup)=>{
|
|
351
|
+
const clusteredMarkers = clusterMarkers(mapRef.current, markerGroup.markers);
|
|
352
|
+
return clusteredMarkers.map((markers, i)=>{
|
|
353
|
+
if (1 === markers.length) {
|
|
354
|
+
const marker = markers[0];
|
|
355
|
+
return /*#__PURE__*/ jsx(Marker, {
|
|
356
|
+
className: "map-marker",
|
|
357
|
+
longitude: marker.longitude,
|
|
358
|
+
latitude: marker.latitude,
|
|
359
|
+
anchor: "center",
|
|
360
|
+
onClick: (event)=>{
|
|
361
|
+
marker.onClick?.();
|
|
362
|
+
event.originalEvent.stopPropagation();
|
|
363
|
+
},
|
|
364
|
+
style: {
|
|
365
|
+
backgroundColor: marker.selected ? markerGroup.style.iconColor : theme.palette.TwClrBg
|
|
366
|
+
},
|
|
367
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
368
|
+
fillColor: marker.selected ? theme.palette.TwClrBg : markerGroup.style.iconColor,
|
|
369
|
+
name: markerGroup.style.iconName,
|
|
370
|
+
size: 'small'
|
|
371
|
+
})
|
|
372
|
+
}, `marker-${i}`);
|
|
373
|
+
} else if (markers.length > 1) {
|
|
374
|
+
const latSum = markers.reduce((sum, marker)=>sum + marker.latitude, 0);
|
|
375
|
+
const lngSum = markers.reduce((sum, marker)=>sum + marker.longitude, 0);
|
|
376
|
+
const latAvg = latSum / markers.length;
|
|
377
|
+
const lngAvg = lngSum / markers.length;
|
|
378
|
+
const selected = markers.some((marker)=>marker.selected);
|
|
379
|
+
return /*#__PURE__*/ jsxs(Marker, {
|
|
380
|
+
className: "map-marker map-marker--cluster",
|
|
381
|
+
longitude: lngAvg,
|
|
382
|
+
latitude: latAvg,
|
|
383
|
+
anchor: "center",
|
|
384
|
+
onClick: (event)=>{
|
|
385
|
+
mapRef.current?.easeTo({
|
|
386
|
+
center: {
|
|
387
|
+
lat: latAvg,
|
|
388
|
+
lon: lngAvg
|
|
389
|
+
},
|
|
390
|
+
zoom: (zoom ?? 10) + 1,
|
|
391
|
+
duration: 500
|
|
392
|
+
});
|
|
393
|
+
event.originalEvent.stopPropagation();
|
|
394
|
+
},
|
|
395
|
+
style: {
|
|
396
|
+
backgroundColor: selected ? markerGroup.style.iconColor : theme.palette.TwClrBg
|
|
397
|
+
},
|
|
398
|
+
children: [
|
|
399
|
+
/*#__PURE__*/ jsx("p", {
|
|
400
|
+
className: "count",
|
|
401
|
+
children: markers.length
|
|
402
|
+
}),
|
|
403
|
+
/*#__PURE__*/ jsx(Icon, {
|
|
404
|
+
fillColor: selected ? theme.palette.TwClrBg : markerGroup.style.iconColor,
|
|
405
|
+
name: markerGroup.style.iconName,
|
|
406
|
+
size: 'small'
|
|
407
|
+
})
|
|
408
|
+
]
|
|
409
|
+
}, `marker-${i}`);
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}), [
|
|
413
|
+
markerGroups,
|
|
414
|
+
theme,
|
|
415
|
+
zoom
|
|
416
|
+
]);
|
|
417
|
+
const onMouseMove = useCallback((event)=>{
|
|
418
|
+
if (event.features && event.features.length) {
|
|
419
|
+
const properties = event.features.map((feature)=>feature.properties).filter((featureProperties)=>featureProperties && void 0 !== featureProperties.id && void 0 !== featureProperties.priority && featureProperties.clickable);
|
|
420
|
+
if (properties.length) {
|
|
421
|
+
const topPriorityFeature = properties.reduce((top, current)=>current.priority > top.priority ? current : top, properties[0]);
|
|
422
|
+
setHoverFeatureId(topPriorityFeature.id);
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
330
425
|
}
|
|
331
|
-
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
return;
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
// Hovering interactive layers
|
|
365
|
-
const onMouseEnter = useCallback(() => setCursor(cursorInteract ?? 'pointer'), [cursorInteract]);
|
|
366
|
-
const onMouseLeave = useCallback(() => setCursor('auto'), []);
|
|
367
|
-
|
|
368
|
-
// Entering and exiting canvases
|
|
369
|
-
const onMouseOver = useCallback(() => setCursor(cursorMap ?? 'auto'), [cursorMap]);
|
|
370
|
-
const onMouseOut = useCallback(() => setCursor('auto'), []);
|
|
371
|
-
|
|
372
|
-
// On layer click
|
|
373
|
-
const onMapClick = useCallback(event => {
|
|
374
|
-
if (featureGroups && event.features?.length) {
|
|
375
|
-
const properties = event.features.map(feature => feature.properties).filter(featureProperties => featureProperties && featureProperties.id !== undefined && featureProperties.priority !== undefined && featureProperties.clickable);
|
|
376
|
-
if (properties.length) {
|
|
377
|
-
const topPriorityFeature = properties.reduce((top, current) => {
|
|
378
|
-
return current.priority > top.priority ? current : top;
|
|
379
|
-
}, properties[0]);
|
|
380
|
-
const clickedItem = featureGroups.flatMap(group => group.features).find(feature => feature.featureId === topPriorityFeature.id);
|
|
381
|
-
if (clickedItem && clickedItem.onClick) {
|
|
382
|
-
clickedItem.onClick();
|
|
383
|
-
return;
|
|
426
|
+
setHoverFeatureId(void 0);
|
|
427
|
+
}, []);
|
|
428
|
+
useEffect(()=>{
|
|
429
|
+
if (!mapRef.current) return;
|
|
430
|
+
const observer = new ResizeObserver(()=>{
|
|
431
|
+
mapRef.current?.resize();
|
|
432
|
+
});
|
|
433
|
+
observer.observe(mapRef.current.getContainer());
|
|
434
|
+
return ()=>observer.disconnect();
|
|
435
|
+
}, []);
|
|
436
|
+
useEffect(()=>{
|
|
437
|
+
if (!mapRef.current) return;
|
|
438
|
+
mapRef.current.resize();
|
|
439
|
+
}, [
|
|
440
|
+
drawerOpen
|
|
441
|
+
]);
|
|
442
|
+
const onMouseEnter = useCallback(()=>setCursor(cursorInteract ?? 'pointer'), [
|
|
443
|
+
cursorInteract
|
|
444
|
+
]);
|
|
445
|
+
const onMouseLeave = useCallback(()=>setCursor('auto'), []);
|
|
446
|
+
const onMouseOver = useCallback(()=>setCursor(cursorMap ?? 'auto'), [
|
|
447
|
+
cursorMap
|
|
448
|
+
]);
|
|
449
|
+
const onMouseOut = useCallback(()=>setCursor('auto'), []);
|
|
450
|
+
const onMapClick = useCallback((event)=>{
|
|
451
|
+
if (featureGroups && event.features?.length) {
|
|
452
|
+
const properties = event.features.map((feature)=>feature.properties).filter((featureProperties)=>featureProperties && void 0 !== featureProperties.id && void 0 !== featureProperties.priority && featureProperties.clickable);
|
|
453
|
+
if (properties.length) {
|
|
454
|
+
const topPriorityFeature = properties.reduce((top, current)=>current.priority > top.priority ? current : top, properties[0]);
|
|
455
|
+
const clickedItem = featureGroups.flatMap((group)=>group.features).find((feature)=>feature.featureId === topPriorityFeature.id);
|
|
456
|
+
if (clickedItem && clickedItem.onClick) return void clickedItem.onClick();
|
|
457
|
+
}
|
|
384
458
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
+
if (void 0 !== onClickCanvas) onClickCanvas(event);
|
|
460
|
+
}, [
|
|
461
|
+
featureGroups,
|
|
462
|
+
onClickCanvas
|
|
463
|
+
]);
|
|
464
|
+
const orderedLayerIds = useMemo(()=>[
|
|
465
|
+
...fillLayers.map((layer)=>layer.props.id),
|
|
466
|
+
...highlightLayers.map((layer)=>layer.props.id),
|
|
467
|
+
...borderLayers.map((layer)=>layer.props.id),
|
|
468
|
+
...textLayers.map((layer)=>layer.props.id)
|
|
469
|
+
], [
|
|
470
|
+
borderLayers,
|
|
471
|
+
fillLayers,
|
|
472
|
+
highlightLayers,
|
|
473
|
+
textLayers
|
|
474
|
+
]);
|
|
475
|
+
useMaintainLayerOrder(mapRef, orderedLayerIds);
|
|
476
|
+
return /*#__PURE__*/ jsxs(ReactMapboxWrapper, {
|
|
477
|
+
attributionControl: false,
|
|
478
|
+
cursor: cursor,
|
|
479
|
+
doubleClickZoom: !disableZoom && !disableDoubleClickZoom,
|
|
480
|
+
interactiveLayerIds: interactiveLayerIds,
|
|
481
|
+
initialViewState: initialViewState,
|
|
482
|
+
mapboxAccessToken: token,
|
|
483
|
+
mapStyle: stylesUrl[mapViewStyle],
|
|
484
|
+
ref: mapRefCallback,
|
|
485
|
+
scrollZoom: !disableZoom,
|
|
486
|
+
style: {
|
|
487
|
+
width: 'auto',
|
|
488
|
+
height: isDesktop ? 'auto' : '80vh',
|
|
489
|
+
flexGrow: isDesktop ? 1 : void 0
|
|
490
|
+
},
|
|
491
|
+
onClick: onMapClick,
|
|
492
|
+
onMove: onMove,
|
|
493
|
+
onMouseEnter: onMouseEnter,
|
|
494
|
+
onMouseLeave: onMouseLeave,
|
|
495
|
+
onMouseOver: onMouseOver,
|
|
496
|
+
onMouseOut: onMouseOut,
|
|
497
|
+
onMouseMove: onMouseMove,
|
|
498
|
+
children: [
|
|
499
|
+
isDesktop && !hideFullScreenControl && /*#__PURE__*/ jsx(FullscreenControl, {
|
|
500
|
+
position: "top-left",
|
|
501
|
+
containerId: containerId
|
|
502
|
+
}),
|
|
503
|
+
!hideZoomControl && /*#__PURE__*/ jsx(NavigationControl, {
|
|
504
|
+
showCompass: false,
|
|
505
|
+
style: {
|
|
506
|
+
marginRight: theme.spacing(2),
|
|
507
|
+
marginBottom: theme.spacing(2)
|
|
508
|
+
},
|
|
509
|
+
position: "bottom-right"
|
|
510
|
+
}),
|
|
511
|
+
!hideMapViewStyleControl && /*#__PURE__*/ jsx(MapViewStyleControl, {
|
|
512
|
+
containerId: containerId,
|
|
513
|
+
mapViewStyle: mapViewStyle,
|
|
514
|
+
setMapViewStyle: setMapViewStyle
|
|
515
|
+
}),
|
|
516
|
+
controlTopRight && /*#__PURE__*/ jsx(Box, {
|
|
517
|
+
sx: {
|
|
518
|
+
height: 'max-content',
|
|
519
|
+
position: 'absolute',
|
|
520
|
+
right: theme.spacing(2),
|
|
521
|
+
top: theme.spacing(2),
|
|
522
|
+
width: 'max-content',
|
|
523
|
+
zIndex: 1000
|
|
524
|
+
},
|
|
525
|
+
children: controlTopRight
|
|
526
|
+
}),
|
|
527
|
+
controlBottomLeft && /*#__PURE__*/ jsx(Box, {
|
|
528
|
+
style: {
|
|
529
|
+
height: 'max-content',
|
|
530
|
+
position: 'absolute',
|
|
531
|
+
left: theme.spacing(2),
|
|
532
|
+
bottom: theme.spacing(4),
|
|
533
|
+
width: 'max-content',
|
|
534
|
+
zIndex: 1000
|
|
535
|
+
},
|
|
536
|
+
children: controlBottomLeft
|
|
537
|
+
}),
|
|
538
|
+
geojson && /*#__PURE__*/ jsxs(Source, {
|
|
539
|
+
id: "mapData",
|
|
540
|
+
type: "geojson",
|
|
541
|
+
data: geojson,
|
|
542
|
+
children: [
|
|
543
|
+
fillLayers,
|
|
544
|
+
highlightLayers,
|
|
545
|
+
borderLayers,
|
|
546
|
+
textLayers
|
|
547
|
+
]
|
|
548
|
+
}),
|
|
549
|
+
markersComponents
|
|
550
|
+
]
|
|
551
|
+
}, mapId);
|
|
459
552
|
};
|
|
460
|
-
|
|
461
|
-
export
|
|
553
|
+
const Map_MapBox = MapBox;
|
|
554
|
+
export default Map_MapBox;
|