@mapcairn/map 0.0.0-stage → 0.1.0-rc.2
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/LICENSE +661 -0
- package/README.md +167 -2
- package/dist/chrome/Attribution/Attribution.js +304 -0
- package/dist/chrome/Attribution/Attribution.js.map +1 -0
- package/dist/chrome/Attribution/Attribution.styles.js +10 -0
- package/dist/chrome/Attribution/Attribution.styles.js.map +1 -0
- package/dist/chrome/Attribution/AttributionSkeleton.js +29 -0
- package/dist/chrome/Attribution/AttributionSkeleton.js.map +1 -0
- package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js +83 -0
- package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js.map +1 -0
- package/dist/chrome/EndStack/EndStack.js +157 -0
- package/dist/chrome/EndStack/EndStack.js.map +1 -0
- package/dist/chrome/EndStack/EndStack.styles.js +12 -0
- package/dist/chrome/EndStack/EndStack.styles.js.map +1 -0
- package/dist/chrome/EndStack/EndStackSkeleton.js +78 -0
- package/dist/chrome/EndStack/EndStackSkeleton.js.map +1 -0
- package/dist/chrome/EndStack/endStackHeight.js +22 -0
- package/dist/chrome/EndStack/endStackHeight.js.map +1 -0
- package/dist/chrome/MapChrome/MapChrome.js +488 -0
- package/dist/chrome/MapChrome/MapChrome.js.map +1 -0
- package/dist/chrome/MapChrome/MapChrome.styles.js +15 -0
- package/dist/chrome/MapChrome/MapChrome.styles.js.map +1 -0
- package/dist/chrome/MapChrome/chromeSurface.js +18 -0
- package/dist/chrome/MapChrome/chromeSurface.js.map +1 -0
- package/dist/chrome/MapChrome/chromeVars.js +71 -0
- package/dist/chrome/MapChrome/chromeVars.js.map +1 -0
- package/dist/chrome/MapChrome/mapKeyPlacement.js +41 -0
- package/dist/chrome/MapChrome/mapKeyPlacement.js.map +1 -0
- package/dist/chrome/MapChrome/sharesWidth.js +13 -0
- package/dist/chrome/MapChrome/sharesWidth.js.map +1 -0
- package/dist/chrome/MapReadout/MapReadout.js +199 -0
- package/dist/chrome/MapReadout/MapReadout.js.map +1 -0
- package/dist/chrome/MapReadout/MapReadout.styles.js +14 -0
- package/dist/chrome/MapReadout/MapReadout.styles.js.map +1 -0
- package/dist/chrome/Sheet/Sheet.js +412 -0
- package/dist/chrome/Sheet/Sheet.js.map +1 -0
- package/dist/chrome/Sheet/Sheet.styles.js +14 -0
- package/dist/chrome/Sheet/Sheet.styles.js.map +1 -0
- package/dist/chrome/focusRegistry.js +76 -0
- package/dist/chrome/focusRegistry.js.map +1 -0
- package/dist/chrome/layoutContext.js +30 -0
- package/dist/chrome/layoutContext.js.map +1 -0
- package/dist/chrome/useScrollEdges.js +53 -0
- package/dist/chrome/useScrollEdges.js.map +1 -0
- package/dist/host/MapContext.js +16 -0
- package/dist/host/MapContext.js.map +1 -0
- package/dist/host/MapView.js +189 -0
- package/dist/host/MapView.js.map +1 -0
- package/dist/host/MapView.styles.js +16 -0
- package/dist/host/MapView.styles.js.map +1 -0
- package/dist/host/overlays/AccuracyCircle.js +36 -0
- package/dist/host/overlays/AccuracyCircle.js.map +1 -0
- package/dist/host/overlays/CentreCrosshair.js +40 -0
- package/dist/host/overlays/CentreCrosshair.js.map +1 -0
- package/dist/host/overlays/DrawOverlay.js +221 -0
- package/dist/host/overlays/DrawOverlay.js.map +1 -0
- package/dist/host/overlays/MapOverlayLayer.js +27 -0
- package/dist/host/overlays/MapOverlayLayer.js.map +1 -0
- package/dist/host/overlays/MeasureOverlay.js +87 -0
- package/dist/host/overlays/MeasureOverlay.js.map +1 -0
- package/dist/host/overlays/PinMarker.js +40 -0
- package/dist/host/overlays/PinMarker.js.map +1 -0
- package/dist/host/overlays/geometry.js +41 -0
- package/dist/host/overlays/geometry.js.map +1 -0
- package/dist/host/overlays/overlays.styles.js +27 -0
- package/dist/host/overlays/overlays.styles.js.map +1 -0
- package/dist/host/pointerTargets.js +22 -0
- package/dist/host/pointerTargets.js.map +1 -0
- package/dist/host/useLongPress.js +102 -0
- package/dist/host/useLongPress.js.map +1 -0
- package/dist/host/useMapEngine.js +352 -0
- package/dist/host/useMapEngine.js.map +1 -0
- package/dist/host/usePointerPosition.js +60 -0
- package/dist/host/usePointerPosition.js.map +1 -0
- package/dist/index.d.ts +3845 -0
- package/dist/index.js +89 -0
- package/dist/layers/CatalogueStatus.js +138 -0
- package/dist/layers/CatalogueStatus.js.map +1 -0
- package/dist/layers/DateTimeControl.js +101 -0
- package/dist/layers/DateTimeControl.js.map +1 -0
- package/dist/layers/FeatureCard.js +147 -0
- package/dist/layers/FeatureCard.js.map +1 -0
- package/dist/layers/FeatureChoices.js +101 -0
- package/dist/layers/FeatureChoices.js.map +1 -0
- package/dist/layers/FeatureGlyph.js +56 -0
- package/dist/layers/FeatureGlyph.js.map +1 -0
- package/dist/layers/IdentifyStatus.js +36 -0
- package/dist/layers/IdentifyStatus.js.map +1 -0
- package/dist/layers/LayerItem.js +321 -0
- package/dist/layers/LayerItem.js.map +1 -0
- package/dist/layers/LayerKey.js +36 -0
- package/dist/layers/LayerKey.js.map +1 -0
- package/dist/layers/Layers.styles.js +50 -0
- package/dist/layers/Layers.styles.js.map +1 -0
- package/dist/layers/LayersSection.js +267 -0
- package/dist/layers/LayersSection.js.map +1 -0
- package/dist/layers/MapDataLayers.js +261 -0
- package/dist/layers/MapDataLayers.js.map +1 -0
- package/dist/layers/MapKey.js +131 -0
- package/dist/layers/MapKey.js.map +1 -0
- package/dist/layers/MapKey.styles.js +16 -0
- package/dist/layers/MapKey.styles.js.map +1 -0
- package/dist/layers/MarkerGlyph.js +84 -0
- package/dist/layers/MarkerGlyph.js.map +1 -0
- package/dist/layers/SelectionProvider.js +27 -0
- package/dist/layers/SelectionProvider.js.map +1 -0
- package/dist/layers/ShapeGlyph.js +122 -0
- package/dist/layers/ShapeGlyph.js.map +1 -0
- package/dist/layers/TurnOffActions.js +147 -0
- package/dist/layers/TurnOffActions.js.map +1 -0
- package/dist/layers/answersTap.js +16 -0
- package/dist/layers/answersTap.js.map +1 -0
- package/dist/layers/catalogueNotice.js +65 -0
- package/dist/layers/catalogueNotice.js.map +1 -0
- package/dist/layers/catalogueReconcile.js +55 -0
- package/dist/layers/catalogueReconcile.js.map +1 -0
- package/dist/layers/catalogueView.js +32 -0
- package/dist/layers/catalogueView.js.map +1 -0
- package/dist/layers/featureTitle.js +14 -0
- package/dist/layers/featureTitle.js.map +1 -0
- package/dist/layers/identifyFeedback.js +30 -0
- package/dist/layers/identifyFeedback.js.map +1 -0
- package/dist/layers/identifyRun.js +148 -0
- package/dist/layers/identifyRun.js.map +1 -0
- package/dist/layers/layerStatus.js +13 -0
- package/dist/layers/layerStatus.js.map +1 -0
- package/dist/layers/loadOutcome.js +107 -0
- package/dist/layers/loadOutcome.js.map +1 -0
- package/dist/layers/loadReport.js +33 -0
- package/dist/layers/loadReport.js.map +1 -0
- package/dist/layers/loadRequests.js +73 -0
- package/dist/layers/loadRequests.js.map +1 -0
- package/dist/layers/mapFeatures.js +307 -0
- package/dist/layers/mapFeatures.js.map +1 -0
- package/dist/layers/mapKeyBlocks.js +24 -0
- package/dist/layers/mapKeyBlocks.js.map +1 -0
- package/dist/layers/reveal.js +119 -0
- package/dist/layers/reveal.js.map +1 -0
- package/dist/layers/selectionMessages.js +53 -0
- package/dist/layers/selectionMessages.js.map +1 -0
- package/dist/layers/selectionResolve.js +111 -0
- package/dist/layers/selectionResolve.js.map +1 -0
- package/dist/layers/useDataLayers.js +940 -0
- package/dist/layers/useDataLayers.js.map +1 -0
- package/dist/layers/useFeatureSelection.js +179 -0
- package/dist/layers/useFeatureSelection.js.map +1 -0
- package/dist/layers/useScrolls.js +37 -0
- package/dist/layers/useScrolls.js.map +1 -0
- package/dist/panels/BasemapPicker/BasemapPicker.js +169 -0
- package/dist/panels/BasemapPicker/BasemapPicker.js.map +1 -0
- package/dist/panels/BasemapPicker/BasemapPicker.styles.js +42 -0
- package/dist/panels/BasemapPicker/BasemapPicker.styles.js.map +1 -0
- package/dist/panels/ExportSection/ExportSection.js +91 -0
- package/dist/panels/ExportSection/ExportSection.js.map +1 -0
- package/dist/panels/HelpSection/HelpSection.js +163 -0
- package/dist/panels/HelpSection/HelpSection.js.map +1 -0
- package/dist/panels/HelpSection/HelpSection.styles.js +9 -0
- package/dist/panels/HelpSection/HelpSection.styles.js.map +1 -0
- package/dist/panels/PinSection/PinSection.js +39 -0
- package/dist/panels/PinSection/PinSection.js.map +1 -0
- package/dist/panels/Section/Section.js +43 -0
- package/dist/panels/Section/Section.js.map +1 -0
- package/dist/panels/Section/Section.styles.js +13 -0
- package/dist/panels/Section/Section.styles.js.map +1 -0
- package/dist/panels/SettingsSection/LanguageField.js +126 -0
- package/dist/panels/SettingsSection/LanguageField.js.map +1 -0
- package/dist/panels/SettingsSection/SettingsSection.js +175 -0
- package/dist/panels/SettingsSection/SettingsSection.js.map +1 -0
- package/dist/panels/SettingsSection/SettingsSection.styles.js +9 -0
- package/dist/panels/SettingsSection/SettingsSection.styles.js.map +1 -0
- package/dist/panels/ShapesSection/ShapesSection.js +229 -0
- package/dist/panels/ShapesSection/ShapesSection.js.map +1 -0
- package/dist/panels/ShapesSection/ShapesSection.styles.js +7 -0
- package/dist/panels/ShapesSection/ShapesSection.styles.js.map +1 -0
- package/dist/panels/SheetContent/SheetContent.js +92 -0
- package/dist/panels/SheetContent/SheetContent.js.map +1 -0
- package/dist/panels/SheetContent/SheetContent.styles.js +6 -0
- package/dist/panels/SheetContent/SheetContent.styles.js.map +1 -0
- package/dist/services/ServicesProvider.js +42 -0
- package/dist/services/ServicesProvider.js.map +1 -0
- package/dist/services/activeMessages.js +140 -0
- package/dist/services/activeMessages.js.map +1 -0
- package/dist/services/basemapAvailability.js +78 -0
- package/dist/services/basemapAvailability.js.map +1 -0
- package/dist/services/englishMessages.js +10 -0
- package/dist/services/englishMessages.js.map +1 -0
- package/dist/services/hooks.js +214 -0
- package/dist/services/hooks.js.map +1 -0
- package/dist/styles.css +2866 -0
- package/dist/styles.css.d.ts +1 -0
- package/dist/tools/Directions/Directions.styles.js +25 -0
- package/dist/tools/Directions/Directions.styles.js.map +1 -0
- package/dist/tools/Directions/DirectionsOverlay.js +46 -0
- package/dist/tools/Directions/DirectionsOverlay.js.map +1 -0
- package/dist/tools/Directions/DirectionsPanel.js +428 -0
- package/dist/tools/Directions/DirectionsPanel.js.map +1 -0
- package/dist/tools/Directions/MapDirections.js +84 -0
- package/dist/tools/Directions/MapDirections.js.map +1 -0
- package/dist/tools/Directions/useDirections.js +226 -0
- package/dist/tools/Directions/useDirections.js.map +1 -0
- package/dist/tools/Directions/useFreeCentre.js +30 -0
- package/dist/tools/Directions/useFreeCentre.js.map +1 -0
- package/dist/tools/DrawToolbar/DrawMapBindings.js +34 -0
- package/dist/tools/DrawToolbar/DrawMapBindings.js.map +1 -0
- package/dist/tools/DrawToolbar/DrawToolbar.js +296 -0
- package/dist/tools/DrawToolbar/DrawToolbar.js.map +1 -0
- package/dist/tools/DrawToolbar/DrawToolbar.styles.js +21 -0
- package/dist/tools/DrawToolbar/DrawToolbar.styles.js.map +1 -0
- package/dist/tools/DrawToolbar/imageDrawing.js +24 -0
- package/dist/tools/DrawToolbar/imageDrawing.js.map +1 -0
- package/dist/tools/DrawToolbar/useDraw.js +543 -0
- package/dist/tools/DrawToolbar/useDraw.js.map +1 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.js +116 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.js.map +1 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js +12 -0
- package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js.map +1 -0
- package/dist/tools/MeasureToolbar/useMeasure.js +75 -0
- package/dist/tools/MeasureToolbar/useMeasure.js.map +1 -0
- package/dist/tools/PinCard/PinCard.js +174 -0
- package/dist/tools/PinCard/PinCard.js.map +1 -0
- package/dist/tools/PinCard/PinCard.styles.js +16 -0
- package/dist/tools/PinCard/PinCard.styles.js.map +1 -0
- package/dist/tools/PinCard/useReverseAddress.js +77 -0
- package/dist/tools/PinCard/useReverseAddress.js.map +1 -0
- package/dist/tools/SearchPill/SearchPill.js +292 -0
- package/dist/tools/SearchPill/SearchPill.js.map +1 -0
- package/dist/tools/SearchPill/SearchPill.styles.js +16 -0
- package/dist/tools/SearchPill/SearchPill.styles.js.map +1 -0
- package/dist/tools/SearchPill/SearchPillSkeleton.js +41 -0
- package/dist/tools/SearchPill/SearchPillSkeleton.js.map +1 -0
- package/dist/tools/SearchPill/useSearch.js +143 -0
- package/dist/tools/SearchPill/useSearch.js.map +1 -0
- package/dist/tools/SearchPill/useSuggestions.js +105 -0
- package/dist/tools/SearchPill/useSuggestions.js.map +1 -0
- package/dist/tools/Tour/TourCard.js +156 -0
- package/dist/tools/Tour/TourCard.js.map +1 -0
- package/dist/tools/Tour/TourCard.styles.js +10 -0
- package/dist/tools/Tour/TourCard.styles.js.map +1 -0
- package/dist/tools/Tour/useTour.js +110 -0
- package/dist/tools/Tour/useTour.js.map +1 -0
- package/dist/tools/locate/useLocate.js +94 -0
- package/dist/tools/locate/useLocate.js.map +1 -0
- package/dist/ui/Button/Button.js +36 -0
- package/dist/ui/Button/Button.js.map +1 -0
- package/dist/ui/Button/Button.styles.js +17 -0
- package/dist/ui/Button/Button.styles.js.map +1 -0
- package/dist/ui/Chip/Chip.js +37 -0
- package/dist/ui/Chip/Chip.js.map +1 -0
- package/dist/ui/Chip/Chip.styles.js +29 -0
- package/dist/ui/Chip/Chip.styles.js.map +1 -0
- package/dist/ui/ControlGroup/ControlGroup.js +23 -0
- package/dist/ui/ControlGroup/ControlGroup.js.map +1 -0
- package/dist/ui/ControlGroup/ControlGroup.styles.js +6 -0
- package/dist/ui/ControlGroup/ControlGroup.styles.js.map +1 -0
- package/dist/ui/EmptyState/EmptyState.js +37 -0
- package/dist/ui/EmptyState/EmptyState.js.map +1 -0
- package/dist/ui/EmptyState/EmptyState.styles.js +10 -0
- package/dist/ui/EmptyState/EmptyState.styles.js.map +1 -0
- package/dist/ui/Icon/Icon.js +28 -0
- package/dist/ui/Icon/Icon.js.map +1 -0
- package/dist/ui/Icon/Icon.styles.js +8 -0
- package/dist/ui/Icon/Icon.styles.js.map +1 -0
- package/dist/ui/IconButton/IconButton.js +47 -0
- package/dist/ui/IconButton/IconButton.js.map +1 -0
- package/dist/ui/IconButton/IconButton.styles.js +27 -0
- package/dist/ui/IconButton/IconButton.styles.js.map +1 -0
- package/dist/ui/Isolate/Isolate.js +26 -0
- package/dist/ui/Isolate/Isolate.js.map +1 -0
- package/dist/ui/Isolate/fillSlots.js +27 -0
- package/dist/ui/Isolate/fillSlots.js.map +1 -0
- package/dist/ui/ListRow/ListRow.js +59 -0
- package/dist/ui/ListRow/ListRow.js.map +1 -0
- package/dist/ui/ListRow/ListRow.styles.js +30 -0
- package/dist/ui/ListRow/ListRow.styles.js.map +1 -0
- package/dist/ui/LiveRegion/LiveRegion.js +88 -0
- package/dist/ui/LiveRegion/LiveRegion.js.map +1 -0
- package/dist/ui/LiveRegion/announcer.js +114 -0
- package/dist/ui/LiveRegion/announcer.js.map +1 -0
- package/dist/ui/SegmentedControl/SegmentedControl.js +55 -0
- package/dist/ui/SegmentedControl/SegmentedControl.js.map +1 -0
- package/dist/ui/SegmentedControl/SegmentedControl.styles.js +9 -0
- package/dist/ui/SegmentedControl/SegmentedControl.styles.js.map +1 -0
- package/dist/ui/SkipLink/SkipLink.js +35 -0
- package/dist/ui/SkipLink/SkipLink.js.map +1 -0
- package/dist/ui/SkipLink/SkipLink.styles.js +6 -0
- package/dist/ui/SkipLink/SkipLink.styles.js.map +1 -0
- package/dist/ui/Slider/Slider.js +68 -0
- package/dist/ui/Slider/Slider.js.map +1 -0
- package/dist/ui/Slider/Slider.styles.js +13 -0
- package/dist/ui/Slider/Slider.styles.js.map +1 -0
- package/dist/ui/StatusMessage/StatusMessage.js +124 -0
- package/dist/ui/StatusMessage/StatusMessage.js.map +1 -0
- package/dist/ui/StatusMessage/StatusMessage.styles.js +28 -0
- package/dist/ui/StatusMessage/StatusMessage.styles.js.map +1 -0
- package/dist/ui/StatusMessage/StatusMessageFocus.js +30 -0
- package/dist/ui/StatusMessage/StatusMessageFocus.js.map +1 -0
- package/dist/ui/Surface/Surface.js +22 -0
- package/dist/ui/Surface/Surface.js.map +1 -0
- package/dist/ui/Surface/Surface.styles.js +27 -0
- package/dist/ui/Surface/Surface.styles.js.map +1 -0
- package/dist/ui/Switch/Switch.js +58 -0
- package/dist/ui/Switch/Switch.js.map +1 -0
- package/dist/ui/Switch/Switch.styles.js +13 -0
- package/dist/ui/Switch/Switch.styles.js.map +1 -0
- package/dist/ui/Tooltip/Tooltip.js +66 -0
- package/dist/ui/Tooltip/Tooltip.js.map +1 -0
- package/dist/ui/Tooltip/Tooltip.styles.js +6 -0
- package/dist/ui/Tooltip/Tooltip.styles.js.map +1 -0
- package/dist/ui/Tooltip/inheritColours.js +27 -0
- package/dist/ui/Tooltip/inheritColours.js.map +1 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.js +16 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.js.map +1 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js +6 -0
- package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js.map +1 -0
- package/package.json +82 -4
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { useChromeLayout } from "../chrome/layoutContext.js";
|
|
2
|
+
import { MapContext } from "../host/MapContext.js";
|
|
3
|
+
import { Section, Subheading, nextHeadingLevel } from "../panels/Section/Section.js";
|
|
4
|
+
import { useMessages, usePreferences, useResolveText } from "../services/hooks.js";
|
|
5
|
+
import { useAnnounce } from "../ui/LiveRegion/LiveRegion.js";
|
|
6
|
+
import { answersTap } from "./answersTap.js";
|
|
7
|
+
import { CatalogueStatus } from "./CatalogueStatus.js";
|
|
8
|
+
import { hidesSection } from "./catalogueView.js";
|
|
9
|
+
import { FeatureCard } from "./FeatureCard.js";
|
|
10
|
+
import { FeatureChoices } from "./FeatureChoices.js";
|
|
11
|
+
import { LayerItem } from "./LayerItem.js";
|
|
12
|
+
import { group, groupHeader, groups, intro, layerList, muted } from "./Layers.styles.js";
|
|
13
|
+
import { featureBounds, featurePosition } from "./mapFeatures.js";
|
|
14
|
+
import { coveredPadding, fitPadding, revealOffset } from "./reveal.js";
|
|
15
|
+
import { TurnOffAll, TurnOffGroup } from "./TurnOffActions.js";
|
|
16
|
+
import "./identifyRun.js";
|
|
17
|
+
import { announceShowingFeature, boundsAroundPoint, cardOf, createFormatterRegistry, formatTemplate, hasCard } from "@mapcairn/core";
|
|
18
|
+
import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
19
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
import { useLatestRef, useReadingDirection } from "@mapcairn/react";
|
|
21
|
+
// src/layers/LayersSection.tsx
|
|
22
|
+
/**
|
|
23
|
+
* The closest "Show on map" zooms out to: far enough to see the region.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
var SHOW_ON_MAP_MIN_ZOOM = 5;
|
|
28
|
+
/** Half the side, in metres, of the box "Show on map" fits around a point. Small enough that the fit always ends at the zoom cap. */
|
|
29
|
+
var SHOW_ON_MAP_RADIUS_METRES = 50;
|
|
30
|
+
/** Whether a box has any width or height, so a single point is not fitted as a shape. */
|
|
31
|
+
function hasExtent(bounds) {
|
|
32
|
+
return bounds.east > bounds.west || bounds.north > bounds.south;
|
|
33
|
+
}
|
|
34
|
+
var DEFAULT_FORMATTERS = createFormatterRegistry();
|
|
35
|
+
/** Sets a ref of either kind, an object or a callback. */
|
|
36
|
+
function setRef(ref, value) {
|
|
37
|
+
if (typeof ref === "function") ref(value);
|
|
38
|
+
else if (ref) ref.current = value;
|
|
39
|
+
}
|
|
40
|
+
/** The ids of the layers that are on. */
|
|
41
|
+
function enabledIds(layers) {
|
|
42
|
+
return layers.filter((layer) => layer.enabled).map((layer) => layer.definition.id);
|
|
43
|
+
}
|
|
44
|
+
/** How many layers answer a tap, to compare with the cap on one tap. */
|
|
45
|
+
function identifiableOn(layers) {
|
|
46
|
+
return layers.filter(answersTap).length;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Layers grouped by the heading their definitions' `group` reads as in the
|
|
50
|
+
* active language, in the order groups first appear. Grouping by the words
|
|
51
|
+
* keeps one heading for layers that name the group with a key, a host text
|
|
52
|
+
* or plain text that read the same.
|
|
53
|
+
*/
|
|
54
|
+
function byGroup(layers, resolve) {
|
|
55
|
+
const groups = /* @__PURE__ */ new Map();
|
|
56
|
+
for (const layer of layers) {
|
|
57
|
+
const heading = resolve(layer.definition.group);
|
|
58
|
+
const group = groups.get(heading) ?? [];
|
|
59
|
+
group.push(layer);
|
|
60
|
+
groups.set(heading, group);
|
|
61
|
+
}
|
|
62
|
+
return [...groups].map(([heading, items]) => ({
|
|
63
|
+
heading,
|
|
64
|
+
key: items[0].definition.id,
|
|
65
|
+
items
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The key of the group whose layers the turn-off Undo would bring back, or
|
|
70
|
+
* undefined for none (or for the action that covered every layer). The
|
|
71
|
+
* first group, in order, that holds any of the offer's layers, so the row
|
|
72
|
+
* stays put when a layer joins the group or the language merges or splits
|
|
73
|
+
* headings.
|
|
74
|
+
*/
|
|
75
|
+
function groupHoldingUndo(groups, turnedOff) {
|
|
76
|
+
if (turnedOff === null || turnedOff.group === null) return;
|
|
77
|
+
const offered = new Set(turnedOff.ids);
|
|
78
|
+
return groups.find(({ items }) => items.some((layer) => offered.has(layer.definition.id)))?.key;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The Layers section of the sheet and side panel, drawn entirely from the
|
|
82
|
+
* layer definitions: a switch per layer with its data cost, and while a layer
|
|
83
|
+
* is on, its status, controls, legend, disclaimer and the list of what
|
|
84
|
+
* loaded. The open feature's card sits at the top. When the catalogue is
|
|
85
|
+
* loading, has failed, is empty or skipped definitions, it says so (see
|
|
86
|
+
* `CatalogueStatus`). Renders nothing for a host whose layers were there from
|
|
87
|
+
* the start and are none.
|
|
88
|
+
*
|
|
89
|
+
* @remarks A tap on the map asks for the card to take focus
|
|
90
|
+
* (`layers.focusPending`); the focus moves after the sheet's own focus
|
|
91
|
+
* effects, so the card heading wins over the section heading.
|
|
92
|
+
*/
|
|
93
|
+
function LayersSection({ layers, headingLevel = 3, headingRef, formatters = DEFAULT_FORMATTERS, onShowOnMap, showTurnOffAll = true, intro: intro$1 }) {
|
|
94
|
+
const messages = useMessages();
|
|
95
|
+
const { t } = messages;
|
|
96
|
+
const resolve = useResolveText();
|
|
97
|
+
const groups$1 = byGroup(layers.layers, resolve);
|
|
98
|
+
const undoGroupKey = groupHoldingUndo(groups$1, layers.turnedOff);
|
|
99
|
+
const adapter = useContext(MapContext)?.adapter ?? null;
|
|
100
|
+
const announce = useAnnounce();
|
|
101
|
+
const cardHeading = useRef(null);
|
|
102
|
+
const { focusPending, consumeFocus } = layers;
|
|
103
|
+
const { reducedMotion } = usePreferences();
|
|
104
|
+
const reducedMotionRef = useLatestRef(reducedMotion);
|
|
105
|
+
const { layout, viewport, panelEdge, mapKeyClearance } = useChromeLayout();
|
|
106
|
+
const direction = useReadingDirection();
|
|
107
|
+
const [cardRequest, setCardRequest] = useState(0);
|
|
108
|
+
const { selected, choices } = layers;
|
|
109
|
+
const choicesHeading = useRef(null);
|
|
110
|
+
const sectionHeading = useRef(null);
|
|
111
|
+
const setHeading = useCallback((element) => {
|
|
112
|
+
sectionHeading.current = element;
|
|
113
|
+
setRef(headingRef, element);
|
|
114
|
+
}, [headingRef]);
|
|
115
|
+
const focusHeading = useCallback(() => sectionHeading.current?.focus({ preventScroll: true }), []);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!focusPending || !selected && !choices || layout === "panel" && panelEdge === null) return;
|
|
118
|
+
consumeFocus();
|
|
119
|
+
queueMicrotask(() => {
|
|
120
|
+
const heading = (selected ? cardHeading : choicesHeading).current;
|
|
121
|
+
heading?.focus({ preventScroll: true });
|
|
122
|
+
heading?.scrollIntoView?.({
|
|
123
|
+
block: "start",
|
|
124
|
+
behavior: reducedMotionRef.current ? "auto" : "smooth"
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
const position = adapter && selected ? featurePosition(selected.feature) : null;
|
|
128
|
+
const offset = adapter && position ? revealOffset(adapter.project(position), {
|
|
129
|
+
layout,
|
|
130
|
+
viewport,
|
|
131
|
+
panelEdge,
|
|
132
|
+
direction
|
|
133
|
+
}) : null;
|
|
134
|
+
if (adapter && offset) adapter.panBy(offset.dx, offset.dy);
|
|
135
|
+
}, [
|
|
136
|
+
adapter,
|
|
137
|
+
selected,
|
|
138
|
+
choices,
|
|
139
|
+
focusPending,
|
|
140
|
+
consumeFocus,
|
|
141
|
+
layout,
|
|
142
|
+
viewport,
|
|
143
|
+
panelEdge,
|
|
144
|
+
direction,
|
|
145
|
+
reducedMotionRef
|
|
146
|
+
]);
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (cardRequest === 0) return;
|
|
149
|
+
cardHeading.current?.scrollIntoView?.({
|
|
150
|
+
block: "start",
|
|
151
|
+
behavior: reducedMotionRef.current ? "auto" : "smooth"
|
|
152
|
+
});
|
|
153
|
+
}, [cardRequest, reducedMotionRef]);
|
|
154
|
+
if (hidesSection(layers.catalogue, layers.layers.length)) return null;
|
|
155
|
+
const show = (layerId, feature) => {
|
|
156
|
+
const position = featurePosition(feature);
|
|
157
|
+
const bounds = featureBounds(feature);
|
|
158
|
+
layers.select(layerId, feature.id);
|
|
159
|
+
if (adapter && bounds && hasExtent(bounds)) adapter.fitBounds(bounds, { padding: fitPadding({
|
|
160
|
+
layout,
|
|
161
|
+
viewport,
|
|
162
|
+
panelEdge,
|
|
163
|
+
direction,
|
|
164
|
+
mapKeyClearance
|
|
165
|
+
}) });
|
|
166
|
+
else if (adapter && position) {
|
|
167
|
+
const zoom = Math.max(adapter.getView().zoom, 5);
|
|
168
|
+
const padding = coveredPadding({
|
|
169
|
+
layout,
|
|
170
|
+
viewport,
|
|
171
|
+
panelEdge,
|
|
172
|
+
direction
|
|
173
|
+
});
|
|
174
|
+
if (padding) adapter.fitBounds(boundsAroundPoint(position, SHOW_ON_MAP_RADIUS_METRES), {
|
|
175
|
+
maxZoom: zoom,
|
|
176
|
+
padding
|
|
177
|
+
});
|
|
178
|
+
else adapter.setView({
|
|
179
|
+
center: position,
|
|
180
|
+
zoom
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
setCardRequest((count) => count + 1);
|
|
184
|
+
const layer = layers.layers.find((item) => item.definition.id === layerId);
|
|
185
|
+
const title = layer && hasCard(layer.definition) ? formatTemplate(cardOf(layer.definition).title, feature.fields, formatters, {
|
|
186
|
+
now: layers.now(),
|
|
187
|
+
catalogue: messages
|
|
188
|
+
}) : null;
|
|
189
|
+
announce(announceShowingFeature(title ?? t("layers.theFeature", {})), { priority: "polite" });
|
|
190
|
+
onShowOnMap?.();
|
|
191
|
+
};
|
|
192
|
+
const groupLevel = nextHeadingLevel(headingLevel);
|
|
193
|
+
const shownIntro = intro$1 ?? t("layers.intro", {});
|
|
194
|
+
return /* @__PURE__ */ jsxs(Section, {
|
|
195
|
+
title: t("layers.title", {}),
|
|
196
|
+
headingLevel,
|
|
197
|
+
headingRef: setHeading,
|
|
198
|
+
"aria-busy": layers.catalogue.status === "loading" || void 0,
|
|
199
|
+
"data-testid": "sheet-section-layers",
|
|
200
|
+
children: [
|
|
201
|
+
selected ? /* @__PURE__ */ jsx(FeatureCard, {
|
|
202
|
+
layers,
|
|
203
|
+
selected,
|
|
204
|
+
formatters,
|
|
205
|
+
headingLevel: groupLevel,
|
|
206
|
+
headingRef: cardHeading,
|
|
207
|
+
onShowOnMap: () => show(selected.layer.definition.id, selected.feature)
|
|
208
|
+
}) : null,
|
|
209
|
+
!selected && choices ? /* @__PURE__ */ jsx(FeatureChoices, {
|
|
210
|
+
layers,
|
|
211
|
+
choices,
|
|
212
|
+
formatters,
|
|
213
|
+
headingLevel: groupLevel,
|
|
214
|
+
headingRef: choicesHeading
|
|
215
|
+
}) : null,
|
|
216
|
+
shownIntro ? /* @__PURE__ */ jsx("p", {
|
|
217
|
+
className: intro,
|
|
218
|
+
children: shownIntro
|
|
219
|
+
}) : null,
|
|
220
|
+
/* @__PURE__ */ jsx(CatalogueStatus, {
|
|
221
|
+
catalogue: layers.catalogue,
|
|
222
|
+
layerCount: layers.layers.length,
|
|
223
|
+
onRetry: layers.retryCatalogue,
|
|
224
|
+
onRecovered: focusHeading
|
|
225
|
+
}),
|
|
226
|
+
showTurnOffAll && layers.layers.length > 0 ? /* @__PURE__ */ jsx(TurnOffAll, {
|
|
227
|
+
layers,
|
|
228
|
+
ids: enabledIds(layers.layers)
|
|
229
|
+
}) : null,
|
|
230
|
+
identifiableOn(layers.layers) > 4 ? /* @__PURE__ */ jsx("p", {
|
|
231
|
+
className: muted,
|
|
232
|
+
"data-testid": "layers-identify-cap",
|
|
233
|
+
children: messages.plural("layers.identify.cap", { count: 4 })
|
|
234
|
+
}) : null,
|
|
235
|
+
/* @__PURE__ */ jsx("div", {
|
|
236
|
+
className: groups,
|
|
237
|
+
children: groups$1.map(({ heading, key, items }) => /* @__PURE__ */ jsxs("div", {
|
|
238
|
+
className: group,
|
|
239
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
240
|
+
className: groupHeader,
|
|
241
|
+
children: [/* @__PURE__ */ jsx(Subheading, {
|
|
242
|
+
level: groupLevel,
|
|
243
|
+
children: heading
|
|
244
|
+
}), showTurnOffAll ? /* @__PURE__ */ jsx(TurnOffGroup, {
|
|
245
|
+
layers,
|
|
246
|
+
group: key,
|
|
247
|
+
heading,
|
|
248
|
+
ids: enabledIds(items),
|
|
249
|
+
holdsUndo: key === undoGroupKey
|
|
250
|
+
}) : null]
|
|
251
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
252
|
+
className: layerList,
|
|
253
|
+
children: items.map((layer) => /* @__PURE__ */ jsx(LayerItem, {
|
|
254
|
+
layer,
|
|
255
|
+
layers,
|
|
256
|
+
formatters,
|
|
257
|
+
onShow: show
|
|
258
|
+
}, layer.definition.id))
|
|
259
|
+
})]
|
|
260
|
+
}, key))
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
export { LayersSection, SHOW_ON_MAP_MIN_ZOOM };
|
|
266
|
+
|
|
267
|
+
//# sourceMappingURL=LayersSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LayersSection.js","names":["groups","intro","styles.intro","styles.muted","styles.groups","styles.group","styles.groupHeader","styles.layerList"],"sources":["../../src/layers/LayersSection.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n announceShowingFeature,\n type Bounds,\n boundsAroundPoint,\n cardOf,\n createFormatterRegistry,\n type DefinitionText,\n type FormatterRegistry,\n formatTemplate,\n hasCard,\n type LayerFeature,\n} from \"@mapcairn/core\";\nimport { useLatestRef, useReadingDirection } from \"@mapcairn/react\";\nimport {\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useChromeLayout } from \"../chrome/layoutContext\";\nimport { MapContext } from \"../host\";\nimport {\n type HeadingLevel,\n nextHeadingLevel,\n Section,\n Subheading,\n} from \"../panels/Section\";\nimport { useMessages, usePreferences, useResolveText } from \"../services\";\nimport { useAnnounce } from \"../ui/LiveRegion\";\nimport { answersTap } from \"./answersTap\";\nimport { CatalogueStatus } from \"./CatalogueStatus\";\nimport { hidesSection } from \"./catalogueView\";\nimport { FeatureCard } from \"./FeatureCard\";\nimport { FeatureChoices } from \"./FeatureChoices\";\nimport { LayerItem } from \"./LayerItem\";\nimport * as styles from \"./Layers.css\";\nimport { featureBounds, featurePosition } from \"./mapFeatures\";\nimport { coveredPadding, fitPadding, revealOffset } from \"./reveal\";\nimport { TurnOffAll, TurnOffGroup } from \"./TurnOffActions\";\nimport {\n type DataLayerState,\n type DataLayers,\n MAX_IDENTIFY_LAYERS,\n} from \"./useDataLayers\";\n\n/**\n * The closest \"Show on map\" zooms out to: far enough to see the region.\n *\n * @internal\n */\nexport const SHOW_ON_MAP_MIN_ZOOM = 5;\n\n/** Half the side, in metres, of the box \"Show on map\" fits around a point. Small enough that the fit always ends at the zoom cap. */\nconst SHOW_ON_MAP_RADIUS_METRES = 50;\n\n/** Whether a box has any width or height, so a single point is not fitted as a shape. */\nfunction hasExtent(bounds: Bounds): boolean {\n return bounds.east > bounds.west || bounds.north > bounds.south;\n}\n\nconst DEFAULT_FORMATTERS = createFormatterRegistry();\n\n/** Props for {@link LayersSection}. */\nexport interface LayersSectionProps {\n readonly layers: DataLayers;\n /** The heading level. Defaults to 3, below the sheet's h2 title. */\n readonly headingLevel?: HeadingLevel;\n readonly headingRef?: Ref<HTMLHeadingElement>;\n /** The formatters card and list templates may name. Defaults to the built-ins. */\n readonly formatters?: FormatterRegistry;\n /**\n * Called after \"Show on map\" has centred a feature, so the host can make\n * room for the map: the section keeps the feature clear of the sheet at\n * `REVEAL_DETENT`, so the host should bring the sheet to that detent.\n */\n readonly onShowOnMap?: () => void;\n /**\n * Whether the section offers \"Turn off all layers\", the action for each\n * group and the Undo that follows. Defaults to true; a host that does not\n * want them passes false.\n */\n readonly showTurnOffAll?: boolean;\n /**\n * The line above the layers, in place of the catalogue's `layers.intro` (\"Open\n * data from public providers. Nothing is requested until you turn a layer\n * on.\"), which is not true of every host (one behind a login serves its own\n * data). An empty string leaves the line out.\n */\n readonly intro?: string;\n}\n\n/** Sets a ref of either kind, an object or a callback. */\nfunction setRef<T>(ref: Ref<T> | undefined, value: T | null): void {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n}\n\n/** The ids of the layers that are on. */\nfunction enabledIds(layers: readonly DataLayerState[]): string[] {\n return layers\n .filter((layer) => layer.enabled)\n .map((layer) => layer.definition.id);\n}\n\n/** How many layers answer a tap, to compare with the cap on one tap. */\nfunction identifiableOn(layers: readonly DataLayerState[]): number {\n return layers.filter(answersTap).length;\n}\n\n/** One heading of the Layers section: the words shown, a key for its element, and the layers under it. */\ninterface LayerGroup {\n readonly heading: string;\n /** The id of the group's first layer: it does not change with the language or when a later layer joins, so the group's element is kept. */\n readonly key: string;\n readonly items: readonly DataLayerState[];\n}\n\n/**\n * Layers grouped by the heading their definitions' `group` reads as in the\n * active language, in the order groups first appear. Grouping by the words\n * keeps one heading for layers that name the group with a key, a host text\n * or plain text that read the same.\n */\nfunction byGroup(\n layers: readonly DataLayerState[],\n resolve: (text: DefinitionText) => string,\n): LayerGroup[] {\n const groups = new Map<string, DataLayerState[]>();\n for (const layer of layers) {\n const heading = resolve(layer.definition.group);\n const group = groups.get(heading) ?? [];\n group.push(layer);\n groups.set(heading, group);\n }\n return [...groups].map(([heading, items]) => ({\n heading,\n key: (items[0] as DataLayerState).definition.id,\n items,\n }));\n}\n\n/**\n * The key of the group whose layers the turn-off Undo would bring back, or\n * undefined for none (or for the action that covered every layer). The\n * first group, in order, that holds any of the offer's layers, so the row\n * stays put when a layer joins the group or the language merges or splits\n * headings.\n */\nfunction groupHoldingUndo(\n groups: readonly LayerGroup[],\n turnedOff: DataLayers[\"turnedOff\"],\n): string | undefined {\n if (turnedOff === null || turnedOff.group === null) {\n return undefined;\n }\n const offered = new Set(turnedOff.ids);\n return groups.find(({ items }) =>\n items.some((layer) => offered.has(layer.definition.id)),\n )?.key;\n}\n\n/**\n * The Layers section of the sheet and side panel, drawn entirely from the\n * layer definitions: a switch per layer with its data cost, and while a layer\n * is on, its status, controls, legend, disclaimer and the list of what\n * loaded. The open feature's card sits at the top. When the catalogue is\n * loading, has failed, is empty or skipped definitions, it says so (see\n * `CatalogueStatus`). Renders nothing for a host whose layers were there from\n * the start and are none.\n *\n * @remarks A tap on the map asks for the card to take focus\n * (`layers.focusPending`); the focus moves after the sheet's own focus\n * effects, so the card heading wins over the section heading.\n */\nexport function LayersSection({\n layers,\n headingLevel = 3,\n headingRef,\n formatters = DEFAULT_FORMATTERS,\n onShowOnMap,\n showTurnOffAll = true,\n intro,\n}: LayersSectionProps) {\n const messages = useMessages();\n const { t } = messages;\n const resolve = useResolveText();\n const groups = byGroup(layers.layers, resolve);\n const undoGroupKey = groupHoldingUndo(groups, layers.turnedOff);\n // Read optionally, so the section also renders outside a map (a test, a guide).\n const adapter = useContext(MapContext)?.adapter ?? null;\n const announce = useAnnounce();\n const cardHeading = useRef<HTMLHeadingElement>(null);\n const { focusPending, consumeFocus } = layers;\n const { reducedMotion } = usePreferences();\n const reducedMotionRef = useLatestRef(reducedMotion);\n const { layout, viewport, panelEdge, mapKeyClearance } = useChromeLayout();\n const direction = useReadingDirection();\n const [cardRequest, setCardRequest] = useState(0);\n const { selected, choices } = layers;\n const choicesHeading = useRef<HTMLHeadingElement>(null);\n // The host's heading ref and this section's own, so focus can return to the\n // heading when Try again has recovered.\n const sectionHeading = useRef<HTMLHeadingElement | null>(null);\n const setHeading = useCallback(\n (element: HTMLHeadingElement | null) => {\n sectionHeading.current = element;\n setRef(headingRef, element);\n },\n [headingRef],\n );\n const focusHeading = useCallback(\n () => sectionHeading.current?.focus({ preventScroll: true }),\n [],\n );\n\n // A tap on the map selected a point and opened its card: the card takes\n // focus, and the sheet or side panel that opened for it must not hide the\n // point (one that shows stays where it is). The side panel publishes its\n // edge after it opens, so wait for that. Acted on once: the section is\n // unmounted when the sheet closes, and reopening must not repeat this.\n useEffect(() => {\n if (\n !focusPending ||\n (!selected && !choices) ||\n (layout === \"panel\" && panelEdge === null)\n ) {\n return;\n }\n consumeFocus();\n // After the sheet's effects, which focus and smoothly scroll to the\n // section heading. The card sits just below it; an instant scroll here\n // would cut the sheet's smooth one short. The card wins over the list it\n // was opened from.\n queueMicrotask(() => {\n const heading = (selected ? cardHeading : choicesHeading).current;\n heading?.focus({ preventScroll: true });\n heading?.scrollIntoView?.({\n block: \"start\",\n behavior: reducedMotionRef.current ? \"auto\" : \"smooth\",\n });\n });\n const position =\n adapter && selected ? featurePosition(selected.feature) : null;\n const offset =\n adapter && position\n ? revealOffset(adapter.project(position), {\n layout,\n viewport,\n panelEdge,\n direction,\n })\n : null;\n if (adapter && offset) {\n adapter.panBy(offset.dx, offset.dy);\n }\n }, [\n adapter,\n selected,\n choices,\n focusPending,\n consumeFocus,\n layout,\n viewport,\n panelEdge,\n direction,\n reducedMotionRef,\n ]);\n\n // \"Show on map\" lowers the sheet to a detent that shows the map as well as\n // the card, but the card sits above wherever the list was scrolled to.\n useEffect(() => {\n if (cardRequest === 0) {\n return;\n }\n cardHeading.current?.scrollIntoView?.({\n block: \"start\",\n behavior: reducedMotionRef.current ? \"auto\" : \"smooth\",\n });\n }, [cardRequest, reducedMotionRef]);\n\n if (hidesSection(layers.catalogue, layers.layers.length)) {\n return null;\n }\n\n const show = (layerId: string, feature: LayerFeature) => {\n const position = featurePosition(feature);\n const bounds = featureBounds(feature);\n layers.select(layerId, feature.id);\n if (adapter && bounds && hasExtent(bounds)) {\n // A polygon or line is shown whole, clear of the sheet or side panel.\n adapter.fitBounds(bounds, {\n padding: fitPadding({\n layout,\n viewport,\n panelEdge,\n direction,\n mapKeyClearance,\n }),\n });\n } else if (adapter && position) {\n const zoom = Math.max(adapter.getView().zoom, SHOW_ON_MAP_MIN_ZOOM);\n const padding = coveredPadding({\n layout,\n viewport,\n panelEdge,\n direction,\n });\n if (padding) {\n // A fit with padding centres the point in what the sheet leaves free.\n adapter.fitBounds(\n boundsAroundPoint(position, SHOW_ON_MAP_RADIUS_METRES),\n { maxZoom: zoom, padding },\n );\n } else {\n adapter.setView({ center: position, zoom });\n }\n }\n setCardRequest((count) => count + 1);\n const layer = layers.layers.find((item) => item.definition.id === layerId);\n const title =\n layer && hasCard(layer.definition)\n ? formatTemplate(\n cardOf(layer.definition).title,\n feature.fields,\n formatters,\n { now: layers.now(), catalogue: messages },\n )\n : null;\n announce(announceShowingFeature(title ?? t(\"layers.theFeature\", {})), {\n priority: \"polite\",\n });\n onShowOnMap?.();\n };\n\n const groupLevel = nextHeadingLevel(headingLevel);\n const shownIntro = intro ?? t(\"layers.intro\", {});\n return (\n <Section\n title={t(\"layers.title\", {})}\n headingLevel={headingLevel}\n headingRef={setHeading}\n aria-busy={layers.catalogue.status === \"loading\" || undefined}\n data-testid=\"sheet-section-layers\"\n >\n {selected ? (\n <FeatureCard\n layers={layers}\n selected={selected}\n formatters={formatters}\n headingLevel={groupLevel as 3 | 4 | 5 | 6}\n headingRef={cardHeading}\n onShowOnMap={() =>\n show(selected.layer.definition.id, selected.feature)\n }\n />\n ) : null}\n {!selected && choices ? (\n <FeatureChoices\n layers={layers}\n choices={choices}\n formatters={formatters}\n headingLevel={groupLevel as 3 | 4 | 5 | 6}\n headingRef={choicesHeading}\n />\n ) : null}\n {shownIntro ? <p className={styles.intro}>{shownIntro}</p> : null}\n <CatalogueStatus\n catalogue={layers.catalogue}\n layerCount={layers.layers.length}\n onRetry={layers.retryCatalogue}\n onRecovered={focusHeading}\n />\n {showTurnOffAll && layers.layers.length > 0 ? (\n <TurnOffAll layers={layers} ids={enabledIds(layers.layers)} />\n ) : null}\n {identifiableOn(layers.layers) > MAX_IDENTIFY_LAYERS ? (\n <p className={styles.muted} data-testid=\"layers-identify-cap\">\n {messages.plural(\"layers.identify.cap\", {\n count: MAX_IDENTIFY_LAYERS,\n })}\n </p>\n ) : null}\n <div className={styles.groups}>\n {groups.map(({ heading, key, items }) => (\n <div key={key} className={styles.group}>\n <div className={styles.groupHeader}>\n <Subheading level={groupLevel}>{heading}</Subheading>\n {showTurnOffAll ? (\n <TurnOffGroup\n layers={layers}\n group={key}\n heading={heading}\n ids={enabledIds(items)}\n holdsUndo={key === undoGroupKey}\n />\n ) : null}\n </div>\n <ul className={styles.layerList}>\n {items.map((layer) => (\n <LayerItem\n key={layer.definition.id}\n layer={layer}\n layers={layers}\n formatters={formatters}\n onShow={show}\n />\n ))}\n </ul>\n </div>\n ))}\n </div>\n </Section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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oBAAC,MAAD;MAAI,WAAWC;MACZ,UAAA,MAAM,KAAK,UACV,oBAAC,WAAD;OAES;OACC;OACI;OACZ,QAAQ;MACT,GALM,MAAM,WAAW,EAKvB,CACF;KACC,CAAA,CACD;IAxBK,GAAA,GAwBL,CACN;GACE,CAAA;EACE;;AAEb"}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { useMap } from "../host/MapContext.js";
|
|
2
|
+
import { roundPixel } from "../host/overlays/geometry.js";
|
|
3
|
+
import { useMessages } from "../services/hooks.js";
|
|
4
|
+
import { selectionHalo, selectionRing } from "./Layers.styles.js";
|
|
5
|
+
import { featureOutlines, featurePosition, paletteColour, toMapFeatures, toMapHeatmap, toMapVector, toStyledShapes, toVectorHeatmaps } from "./mapFeatures.js";
|
|
6
|
+
import { createFormatterRegistry, hasZoomWindow, isFeedLayer, isHeatmapLayer, isQueryLayer, isShapeStyle, isVectorTileLayer, tileUrl } from "@mapcairn/core";
|
|
7
|
+
import { useEffect, useRef } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useLatestRef } from "@mapcairn/react";
|
|
10
|
+
// src/layers/MapDataLayers.tsx
|
|
11
|
+
var DEFAULT_FORMATTERS = createFormatterRegistry();
|
|
12
|
+
/**
|
|
13
|
+
* The map id of the affected area. Definition ids cannot contain a colon,
|
|
14
|
+
* so it never meets a layer's own id.
|
|
15
|
+
*/
|
|
16
|
+
var DETAIL_LAYER_ID = ":detail";
|
|
17
|
+
/** How long the map must stay still, in milliseconds, before layers that depend on its view are told it. */
|
|
18
|
+
var VIEW_SETTLE_MS = 400;
|
|
19
|
+
/**
|
|
20
|
+
* The map id of one heatmap source layer of a vector tile definition. Ids
|
|
21
|
+
* with a colon never meet a layer's own id.
|
|
22
|
+
*/
|
|
23
|
+
function heatmapId(layerId, index) {
|
|
24
|
+
return `${layerId}:heatmap:${index}`;
|
|
25
|
+
}
|
|
26
|
+
function opacityOf(layer) {
|
|
27
|
+
const control = layer.definition.controls.find((c) => c.kind === "opacity");
|
|
28
|
+
const value = control ? Number(layer.controls[control.id]) : 1;
|
|
29
|
+
return Number.isFinite(value) ? value : 1;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Hands one enabled layer to the adapter, unless it is unchanged. Returns
|
|
33
|
+
* what is drawn, by map id: one id for most layers, and one more for each
|
|
34
|
+
* heatmap source layer of a vector tile layer.
|
|
35
|
+
*/
|
|
36
|
+
function draw(adapter, layer, previous, now, formatters, catalogue) {
|
|
37
|
+
const { definition } = layer;
|
|
38
|
+
const own = previous(definition.id);
|
|
39
|
+
const replaced = own?.definition !== definition;
|
|
40
|
+
if (isHeatmapLayer(definition)) {
|
|
41
|
+
if (layer.features.length === 0) return [];
|
|
42
|
+
if (replaced || own.features !== layer.features || own.controls !== layer.controls) adapter.setHeatmapLayer(definition.id, toMapHeatmap(definition, layer.features, layer.controls));
|
|
43
|
+
return [[definition.id, {
|
|
44
|
+
definition,
|
|
45
|
+
features: layer.features,
|
|
46
|
+
controls: layer.controls
|
|
47
|
+
}]];
|
|
48
|
+
}
|
|
49
|
+
if (isVectorTileLayer(definition)) {
|
|
50
|
+
if (replaced || own.controls !== layer.controls) adapter.setVectorLayer(definition.id, toMapVector(definition, layer.controls, now));
|
|
51
|
+
const heatmaps = toVectorHeatmaps(definition, layer.controls, now);
|
|
52
|
+
let index = 0;
|
|
53
|
+
const drawnHeatmaps = definition.sourceLayers.flatMap((sourceLayer, position) => {
|
|
54
|
+
if (!("heatmap" in sourceLayer)) return [];
|
|
55
|
+
const id = heatmapId(definition.id, position);
|
|
56
|
+
const heatmap = heatmaps[index];
|
|
57
|
+
index += 1;
|
|
58
|
+
const before = previous(id);
|
|
59
|
+
if (heatmap && (before?.definition !== definition || before.controls !== layer.controls)) adapter.setHeatmapLayer(id, heatmap);
|
|
60
|
+
return [[id, {
|
|
61
|
+
definition,
|
|
62
|
+
controls: layer.controls
|
|
63
|
+
}]];
|
|
64
|
+
});
|
|
65
|
+
return [[definition.id, {
|
|
66
|
+
definition,
|
|
67
|
+
controls: layer.controls
|
|
68
|
+
}], ...drawnHeatmaps];
|
|
69
|
+
}
|
|
70
|
+
if (isFeedLayer(definition)) {
|
|
71
|
+
if (layer.features.length === 0) return [];
|
|
72
|
+
const { style } = definition;
|
|
73
|
+
const wrongLanguage = isShapeStyle(style) && own?.catalogue !== catalogue;
|
|
74
|
+
if (replaced || own.features !== layer.features || wrongLanguage) {
|
|
75
|
+
if (isShapeStyle(style)) adapter.setStyledShapes(definition.id, toStyledShapes({
|
|
76
|
+
...definition,
|
|
77
|
+
style
|
|
78
|
+
}, layer.features, formatters, now, catalogue));
|
|
79
|
+
else adapter.setFeatureLayer(definition.id, toMapFeatures(style, layer.features));
|
|
80
|
+
}
|
|
81
|
+
return [[definition.id, {
|
|
82
|
+
definition,
|
|
83
|
+
features: layer.features,
|
|
84
|
+
...isShapeStyle(style) ? { catalogue } : {}
|
|
85
|
+
}]];
|
|
86
|
+
}
|
|
87
|
+
const tiles = tileUrl(definition, layer.controls, now);
|
|
88
|
+
const opacity = opacityOf(layer);
|
|
89
|
+
if (replaced || own.tiles !== tiles || own.opacity !== opacity) adapter.setTileLayer(definition.id, {
|
|
90
|
+
tiles,
|
|
91
|
+
tileSize: definition.source.tileSize,
|
|
92
|
+
maxzoom: definition.source.maxzoom,
|
|
93
|
+
bounds: definition.source.bounds,
|
|
94
|
+
opacity
|
|
95
|
+
});
|
|
96
|
+
return [[definition.id, {
|
|
97
|
+
definition,
|
|
98
|
+
tiles,
|
|
99
|
+
opacity
|
|
100
|
+
}]];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Draws the layers that are on, and a shown affected area, through the map
|
|
104
|
+
* adapter, and turns a tap on a point into an open card. Renders nothing; put
|
|
105
|
+
* it inside `MapView`. Every layer is drawn from its definition, so nothing
|
|
106
|
+
* here names one.
|
|
107
|
+
*/
|
|
108
|
+
function MapDataLayers({ layers, onFeatureTap, ignoreTaps = false, formatters = DEFAULT_FORMATTERS }) {
|
|
109
|
+
const { adapter } = useMap();
|
|
110
|
+
const messages = useMessages();
|
|
111
|
+
const drawn = useRef(/* @__PURE__ */ new Map());
|
|
112
|
+
const { now, layers: states, detail } = layers;
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!adapter) return;
|
|
115
|
+
const next = /* @__PURE__ */ new Map();
|
|
116
|
+
for (const layer of states) {
|
|
117
|
+
if (!layer.enabled) continue;
|
|
118
|
+
const results = draw(adapter, layer, (id) => drawn.current.get(id), now(), formatters, messages);
|
|
119
|
+
for (const [id, result] of results) next.set(id, result);
|
|
120
|
+
}
|
|
121
|
+
for (const id of drawn.current.keys()) if (!next.has(id) && id !== DETAIL_LAYER_ID) adapter.removeLayer(id);
|
|
122
|
+
const detailLayer = states.find((layer) => layer.definition.id === detail?.layerId)?.definition;
|
|
123
|
+
if (detail?.status === "shown" && detailLayer && isFeedLayer(detailLayer) && detailLayer.detail) {
|
|
124
|
+
const own = drawn.current.get(DETAIL_LAYER_ID);
|
|
125
|
+
if (own?.features !== detail.shapes || own.definition !== detailLayer) adapter.setShapeLayer(DETAIL_LAYER_ID, {
|
|
126
|
+
geometries: detail.shapes.map((shape) => shape.geometry),
|
|
127
|
+
colour: paletteColour(detailLayer.detail.colour)
|
|
128
|
+
});
|
|
129
|
+
next.set(DETAIL_LAYER_ID, {
|
|
130
|
+
definition: detailLayer,
|
|
131
|
+
features: detail.shapes
|
|
132
|
+
});
|
|
133
|
+
} else if (drawn.current.has(DETAIL_LAYER_ID)) adapter.removeLayer(DETAIL_LAYER_ID);
|
|
134
|
+
drawn.current = next;
|
|
135
|
+
}, [
|
|
136
|
+
adapter,
|
|
137
|
+
states,
|
|
138
|
+
detail,
|
|
139
|
+
now,
|
|
140
|
+
formatters,
|
|
141
|
+
messages
|
|
142
|
+
]);
|
|
143
|
+
useEffect(() => () => {
|
|
144
|
+
for (const id of drawn.current.keys()) adapter?.removeLayer(id);
|
|
145
|
+
drawn.current = /* @__PURE__ */ new Map();
|
|
146
|
+
}, [adapter]);
|
|
147
|
+
const latest = useLatestRef({
|
|
148
|
+
choose: layers.choose,
|
|
149
|
+
cancelIdentify: layers.cancelIdentify,
|
|
150
|
+
setView: layers.setView,
|
|
151
|
+
reportTilesSlow: layers.reportTilesSlow,
|
|
152
|
+
reportTilesUnavailable: layers.reportTilesUnavailable,
|
|
153
|
+
reportTilesRecovered: layers.reportTilesRecovered,
|
|
154
|
+
onFeatureTap,
|
|
155
|
+
ignoreTaps
|
|
156
|
+
});
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if (!adapter) return;
|
|
159
|
+
const stopSlow = adapter.on("tileLayerSlow", ({ layerId, tiles }) => {
|
|
160
|
+
latest.current.reportTilesSlow(layerId, tiles);
|
|
161
|
+
});
|
|
162
|
+
const stopUnavailable = adapter.on("tileLayerUnavailable", ({ layerId, tiles }) => {
|
|
163
|
+
latest.current.reportTilesUnavailable(layerId, tiles);
|
|
164
|
+
});
|
|
165
|
+
const stopRecovered = adapter.on("tileLayerRecovered", ({ layerId, tiles }) => {
|
|
166
|
+
latest.current.reportTilesRecovered(layerId, tiles);
|
|
167
|
+
});
|
|
168
|
+
return () => {
|
|
169
|
+
stopSlow();
|
|
170
|
+
stopUnavailable();
|
|
171
|
+
stopRecovered();
|
|
172
|
+
};
|
|
173
|
+
}, [adapter, latest]);
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
if (ignoreTaps) latest.current.cancelIdentify();
|
|
176
|
+
}, [ignoreTaps, latest]);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
if (!adapter) return;
|
|
179
|
+
return adapter.on("featureTap", (tap) => {
|
|
180
|
+
const current = latest.current;
|
|
181
|
+
if (current.ignoreTaps) return;
|
|
182
|
+
current.choose(tap.hits, { focus: true });
|
|
183
|
+
current.onFeatureTap?.(tap);
|
|
184
|
+
});
|
|
185
|
+
}, [adapter, latest]);
|
|
186
|
+
const needsView = states.some(({ enabled, definition }) => enabled && (isQueryLayer(definition) || hasZoomWindow(definition)));
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
if (!adapter || !needsView) return;
|
|
189
|
+
const report = () => {
|
|
190
|
+
latest.current.setView(adapter.getBounds(), adapter.getView().zoom);
|
|
191
|
+
};
|
|
192
|
+
report();
|
|
193
|
+
let timer;
|
|
194
|
+
const stop = adapter.on("moveEnd", () => {
|
|
195
|
+
clearTimeout(timer);
|
|
196
|
+
timer = setTimeout(report, 400);
|
|
197
|
+
});
|
|
198
|
+
return () => {
|
|
199
|
+
clearTimeout(timer);
|
|
200
|
+
stop();
|
|
201
|
+
};
|
|
202
|
+
}, [
|
|
203
|
+
adapter,
|
|
204
|
+
needsView,
|
|
205
|
+
latest
|
|
206
|
+
]);
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
/** An SVG path along a polygon's rings or a line, in map pixels, or null when it has none. */
|
|
210
|
+
function outlinePath(adapter, feature) {
|
|
211
|
+
const outlines = featureOutlines(feature);
|
|
212
|
+
if (!outlines.every(({ points }) => points.every((p) => adapter.isVisible(p)))) return null;
|
|
213
|
+
const parts = outlines.map(({ points, closed }) => {
|
|
214
|
+
return `M${points.map((point) => {
|
|
215
|
+
const { x, y } = adapter.project(point);
|
|
216
|
+
return `${roundPixel(x)},${roundPixel(y)}`;
|
|
217
|
+
}).join(" L")}${closed ? " Z" : ""}`;
|
|
218
|
+
});
|
|
219
|
+
return parts.length > 0 ? parts.join(" ") : null;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* A ring around the point whose card is open, so the card and the map agree on which
|
|
223
|
+
* one it is. Render it inside `MapOverlayLayer`; like every overlay it is a
|
|
224
|
+
* picture of state the card already gives in words.
|
|
225
|
+
*/
|
|
226
|
+
function SelectionMarker({ layers }) {
|
|
227
|
+
const { adapter } = useMap();
|
|
228
|
+
const feature = layers.selected?.feature;
|
|
229
|
+
if (!adapter || !feature) return null;
|
|
230
|
+
if (feature.geometry.type !== "Point") {
|
|
231
|
+
const path = outlinePath(adapter, feature);
|
|
232
|
+
return path ? /* @__PURE__ */ jsxs("g", {
|
|
233
|
+
"data-testid": "selection-marker",
|
|
234
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
235
|
+
className: selectionHalo,
|
|
236
|
+
d: path
|
|
237
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
238
|
+
className: selectionRing,
|
|
239
|
+
d: path
|
|
240
|
+
})]
|
|
241
|
+
}) : null;
|
|
242
|
+
}
|
|
243
|
+
const position = featurePosition(feature);
|
|
244
|
+
if (!position) return null;
|
|
245
|
+
if (!adapter.isVisible(position)) return null;
|
|
246
|
+
const { x, y } = adapter.project(position);
|
|
247
|
+
return /* @__PURE__ */ jsxs("g", {
|
|
248
|
+
transform: `translate(${roundPixel(x)} ${roundPixel(y)})`,
|
|
249
|
+
"data-testid": "selection-marker",
|
|
250
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
251
|
+
className: selectionHalo,
|
|
252
|
+
r: 16
|
|
253
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
254
|
+
className: selectionRing,
|
|
255
|
+
r: 16
|
|
256
|
+
})]
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
export { MapDataLayers, SelectionMarker, VIEW_SETTLE_MS };
|
|
260
|
+
|
|
261
|
+
//# sourceMappingURL=MapDataLayers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapDataLayers.js","names":["styles.selectionHalo","styles.selectionRing"],"sources":["../../src/layers/MapDataLayers.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n createFormatterRegistry,\n type FormatterRegistry,\n hasZoomWindow,\n isFeedLayer,\n isHeatmapLayer,\n isQueryLayer,\n isShapeStyle,\n isVectorTileLayer,\n type LayerDefinition,\n type LayerFeature,\n type MapAdapter,\n type MapFeatureTap,\n type MessageCatalogue,\n tileUrl,\n} from \"@mapcairn/core\";\nimport { useLatestRef } from \"@mapcairn/react\";\nimport { useEffect, useRef } from \"react\";\nimport { useMap } from \"../host\";\nimport { roundPixel } from \"../host/overlays/geometry\";\nimport { useMessages } from \"../services\";\nimport * as styles from \"./Layers.css\";\nimport {\n featureOutlines,\n featurePosition,\n paletteColour,\n toMapFeatures,\n toMapHeatmap,\n toMapVector,\n toStyledShapes,\n toVectorHeatmaps,\n} from \"./mapFeatures\";\nimport type { DataLayerState, DataLayers } from \"./useDataLayers\";\n\nconst DEFAULT_FORMATTERS = createFormatterRegistry();\n\n/**\n * The map id of the affected area. Definition ids cannot contain a colon,\n * so it never meets a layer's own id.\n */\nconst DETAIL_LAYER_ID = \":detail\";\n\n/** How long the map must stay still, in milliseconds, before layers that depend on its view are told it. */\nexport const VIEW_SETTLE_MS = 400;\n\n/** Props for {@link MapDataLayers}. */\nexport interface MapDataLayersProps {\n readonly layers: DataLayers;\n /** Called after a tap on a point has selected it, so the app can open its card. */\n readonly onFeatureTap?: (tap: MapFeatureTap) => void;\n /** True while taps on the map mean something else, such as measuring. */\n readonly ignoreTaps?: boolean;\n /** The formatters label templates may name. Defaults to the built-ins. */\n readonly formatters?: FormatterRegistry;\n}\n\n/**\n * What was last handed to the adapter under one map id, to skip redrawing it\n * unchanged. A layer is also drawn again when its definition is another\n * object, so a refreshed list that replaces a definition redraws it even when\n * its URL, controls and features are the same. `partitionDefinitions` keeps\n * the old object for a definition that did not change, so a refresh that\n * changes nothing redraws nothing.\n */\ninterface Drawn {\n /** The definition the layer was drawn from, compared by identity. */\n readonly definition?: LayerDefinition;\n readonly features?: readonly LayerFeature[];\n readonly tiles?: string;\n readonly opacity?: number;\n /** The control values a heatmap or vector layer was drawn with. */\n readonly controls?: DataLayerState[\"controls\"];\n /**\n * The catalogue a polygon or line layer's labels were written with, compared\n * by identity: a figure in a label is written for the language, so another\n * catalogue draws them again.\n */\n readonly catalogue?: MessageCatalogue;\n}\n\n/**\n * The map id of one heatmap source layer of a vector tile definition. Ids\n * with a colon never meet a layer's own id.\n */\nfunction heatmapId(layerId: string, index: number): string {\n return `${layerId}:heatmap:${index}`;\n}\n\nfunction opacityOf(layer: DataLayerState): number {\n const control = layer.definition.controls.find((c) => c.kind === \"opacity\");\n const value = control ? Number(layer.controls[control.id]) : 1;\n return Number.isFinite(value) ? value : 1;\n}\n\n/**\n * Hands one enabled layer to the adapter, unless it is unchanged. Returns\n * what is drawn, by map id: one id for most layers, and one more for each\n * heatmap source layer of a vector tile layer.\n */\nfunction draw(\n adapter: MapAdapter,\n layer: DataLayerState,\n previous: (id: string) => Drawn | undefined,\n now: number,\n formatters: FormatterRegistry,\n catalogue: MessageCatalogue,\n): [string, Drawn][] {\n const { definition } = layer;\n const own = previous(definition.id);\n const replaced = own?.definition !== definition;\n if (isHeatmapLayer(definition)) {\n if (layer.features.length === 0) {\n return [];\n }\n if (\n replaced ||\n own.features !== layer.features ||\n own.controls !== layer.controls\n ) {\n adapter.setHeatmapLayer(\n definition.id,\n toMapHeatmap(definition, layer.features, layer.controls),\n );\n }\n return [\n [\n definition.id,\n { definition, features: layer.features, controls: layer.controls },\n ],\n ];\n }\n if (isVectorTileLayer(definition)) {\n if (replaced || own.controls !== layer.controls) {\n adapter.setVectorLayer(\n definition.id,\n toMapVector(definition, layer.controls, now),\n );\n }\n const heatmaps = toVectorHeatmaps(definition, layer.controls, now);\n let index = 0;\n const drawnHeatmaps = definition.sourceLayers.flatMap(\n (sourceLayer, position): [string, Drawn][] => {\n if (!(\"heatmap\" in sourceLayer)) {\n return [];\n }\n const id = heatmapId(definition.id, position);\n const heatmap = heatmaps[index];\n index += 1;\n const before = previous(id);\n if (\n heatmap &&\n (before?.definition !== definition ||\n before.controls !== layer.controls)\n ) {\n adapter.setHeatmapLayer(id, heatmap);\n }\n return [[id, { definition, controls: layer.controls }]];\n },\n );\n return [\n [definition.id, { definition, controls: layer.controls }],\n ...drawnHeatmaps,\n ];\n }\n if (isFeedLayer(definition)) {\n if (layer.features.length === 0) {\n return [];\n }\n const { style } = definition;\n // Only a polygon or line layer's labels depend on the language.\n const wrongLanguage = isShapeStyle(style) && own?.catalogue !== catalogue;\n if (replaced || own.features !== layer.features || wrongLanguage) {\n if (isShapeStyle(style)) {\n adapter.setStyledShapes(\n definition.id,\n toStyledShapes(\n { ...definition, style },\n layer.features,\n formatters,\n now,\n catalogue,\n ),\n );\n } else {\n adapter.setFeatureLayer(\n definition.id,\n toMapFeatures(style, layer.features),\n );\n }\n }\n return [\n [\n definition.id,\n {\n definition,\n features: layer.features,\n ...(isShapeStyle(style) ? { catalogue } : {}),\n },\n ],\n ];\n }\n const tiles = tileUrl(definition, layer.controls, now);\n const opacity = opacityOf(layer);\n if (replaced || own.tiles !== tiles || own.opacity !== opacity) {\n adapter.setTileLayer(definition.id, {\n tiles,\n tileSize: definition.source.tileSize,\n maxzoom: definition.source.maxzoom,\n bounds: definition.source.bounds,\n opacity,\n });\n }\n return [[definition.id, { definition, tiles, opacity }]];\n}\n\n/**\n * Draws the layers that are on, and a shown affected area, through the map\n * adapter, and turns a tap on a point into an open card. Renders nothing; put\n * it inside `MapView`. Every layer is drawn from its definition, so nothing\n * here names one.\n */\nexport function MapDataLayers({\n layers,\n onFeatureTap,\n ignoreTaps = false,\n formatters = DEFAULT_FORMATTERS,\n}: MapDataLayersProps) {\n const { adapter } = useMap();\n const messages = useMessages();\n const drawn = useRef(new Map<string, Drawn>());\n const { now, layers: states, detail } = layers;\n\n useEffect(() => {\n if (!adapter) {\n return;\n }\n const next = new Map<string, Drawn>();\n for (const layer of states) {\n if (!layer.enabled) {\n continue;\n }\n const results = draw(\n adapter,\n layer,\n (id) => drawn.current.get(id),\n now(),\n formatters,\n messages,\n );\n for (const [id, result] of results) {\n next.set(id, result);\n }\n }\n for (const id of drawn.current.keys()) {\n if (!next.has(id) && id !== DETAIL_LAYER_ID) {\n adapter.removeLayer(id);\n }\n }\n const detailLayer = states.find(\n (layer) => layer.definition.id === detail?.layerId,\n )?.definition;\n if (\n detail?.status === \"shown\" &&\n detailLayer &&\n isFeedLayer(detailLayer) &&\n detailLayer.detail\n ) {\n const own = drawn.current.get(DETAIL_LAYER_ID);\n if (own?.features !== detail.shapes || own.definition !== detailLayer) {\n adapter.setShapeLayer(DETAIL_LAYER_ID, {\n geometries: detail.shapes.map((shape) => shape.geometry),\n colour: paletteColour(detailLayer.detail.colour),\n });\n }\n next.set(DETAIL_LAYER_ID, {\n definition: detailLayer,\n features: detail.shapes,\n });\n } else if (drawn.current.has(DETAIL_LAYER_ID)) {\n adapter.removeLayer(DETAIL_LAYER_ID);\n }\n drawn.current = next;\n }, [adapter, states, detail, now, formatters, messages]);\n\n useEffect(\n () => () => {\n for (const id of drawn.current.keys()) {\n adapter?.removeLayer(id);\n }\n drawn.current = new Map();\n },\n [adapter],\n );\n\n const latest = useLatestRef({\n choose: layers.choose,\n cancelIdentify: layers.cancelIdentify,\n setView: layers.setView,\n reportTilesSlow: layers.reportTilesSlow,\n reportTilesUnavailable: layers.reportTilesUnavailable,\n reportTilesRecovered: layers.reportTilesRecovered,\n onFeatureTap,\n ignoreTaps,\n });\n useEffect(() => {\n if (!adapter) {\n return;\n }\n const stopSlow = adapter.on(\"tileLayerSlow\", ({ layerId, tiles }) => {\n latest.current.reportTilesSlow(layerId, tiles);\n });\n const stopUnavailable = adapter.on(\n \"tileLayerUnavailable\",\n ({ layerId, tiles }) => {\n latest.current.reportTilesUnavailable(layerId, tiles);\n },\n );\n const stopRecovered = adapter.on(\n \"tileLayerRecovered\",\n ({ layerId, tiles }) => {\n latest.current.reportTilesRecovered(layerId, tiles);\n },\n );\n return () => {\n stopSlow();\n stopUnavailable();\n stopRecovered();\n };\n }, [adapter, latest]);\n // Once taps mean something else (measuring, say), a raster layer's answer to\n // an earlier tap must not open a card over it.\n useEffect(() => {\n if (ignoreTaps) {\n latest.current.cancelIdentify();\n }\n }, [ignoreTaps, latest]);\n useEffect(() => {\n if (!adapter) {\n return;\n }\n return adapter.on(\"featureTap\", (tap) => {\n const current = latest.current;\n if (current.ignoreTaps) {\n return;\n }\n // One feature opens its card; several open a list to choose from. Either\n // cancels a raster lookup in flight, so its late answer cannot replace it.\n current.choose(tap.hits, { focus: true });\n current.onFeatureTap?.(tap);\n });\n }, [adapter, latest]);\n\n // Query layers ask for what is in view, and layers with a zoom window say\n // which level to zoom to, so they are told once the map has settled (and\n // straight away when one is turned on), never while it moves.\n const needsView = states.some(\n ({ enabled, definition }) =>\n enabled && (isQueryLayer(definition) || hasZoomWindow(definition)),\n );\n useEffect(() => {\n if (!adapter || !needsView) {\n return;\n }\n const report = () => {\n latest.current.setView(adapter.getBounds(), adapter.getView().zoom);\n };\n report();\n let timer: ReturnType<typeof setTimeout> | undefined;\n const stop = adapter.on(\"moveEnd\", () => {\n clearTimeout(timer);\n timer = setTimeout(report, VIEW_SETTLE_MS);\n });\n return () => {\n clearTimeout(timer);\n stop();\n };\n }, [adapter, needsView, latest]);\n\n return null;\n}\n\n/** An SVG path along a polygon's rings or a line, in map pixels, or null when it has none. */\nfunction outlinePath(\n adapter: MapAdapter,\n feature: LayerFeature,\n): string | null {\n const outlines = featureOutlines(feature);\n if (\n !outlines.every(({ points }) => points.every((p) => adapter.isVisible(p)))\n ) {\n return null;\n }\n const parts = outlines.map(({ points, closed }) => {\n const pixels = points.map((point) => {\n const { x, y } = adapter.project(point);\n return `${roundPixel(x)},${roundPixel(y)}`;\n });\n return `M${pixels.join(\" L\")}${closed ? \" Z\" : \"\"}`;\n });\n return parts.length > 0 ? parts.join(\" \") : null;\n}\n\n/** Props for {@link SelectionMarker}. */\nexport interface SelectionMarkerProps {\n readonly layers: DataLayers;\n}\n\n/**\n * A ring around the point whose card is open, so the card and the map agree on which\n * one it is. Render it inside `MapOverlayLayer`; like every overlay it is a\n * picture of state the card already gives in words.\n */\nexport function SelectionMarker({ layers }: SelectionMarkerProps) {\n const { adapter } = useMap();\n const feature = layers.selected?.feature;\n if (!adapter || !feature) {\n return null;\n }\n if (feature.geometry.type !== \"Point\") {\n const path = outlinePath(adapter, feature);\n return path ? (\n <g data-testid=\"selection-marker\">\n <path className={styles.selectionHalo} d={path} />\n <path className={styles.selectionRing} d={path} />\n </g>\n ) : null;\n }\n const position = featurePosition(feature);\n if (!position) {\n return null;\n }\n if (!adapter.isVisible(position)) {\n return null;\n }\n const { x, y } = adapter.project(position);\n return (\n <g\n transform={`translate(${roundPixel(x)} ${roundPixel(y)})`}\n data-testid=\"selection-marker\"\n >\n <circle className={styles.selectionHalo} r={16} />\n <circle className={styles.selectionRing} r={16} />\n </g>\n );\n}\n"],"mappings":";;;;;;;;;;AAoCA,IAAM,qBAAqB,wBAAwB;;;;;AAMnD,IAAM,kBAAkB;;AAGxB,IAAa,iBAAiB;;;;;AAyC9B,SAAS,UAAU,SAAiB,OAAuB;CACzD,OAAO,GAAG,QAAQ,WAAW;AAC/B;AAEA,SAAS,UAAU,OAA+B;CAChD,MAAM,UAAU,MAAM,WAAW,SAAS,MAAM,MAAM,EAAE,SAAS,SAAS;CAC1E,MAAM,QAAQ,UAAU,OAAO,MAAM,SAAS,QAAQ,GAAG,IAAI;CAC7D,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;AAC1C;;;;;;AAOA,SAAS,KACP,SACA,OACA,UACA,KACA,YACA,WACmB;CACnB,MAAM,EAAE,eAAe;CACvB,MAAM,MAAM,SAAS,WAAW,EAAE;CAClC,MAAM,WAAW,KAAK,eAAe;CACrC,IAAI,eAAe,UAAU,GAAG;EAC9B,IAAI,MAAM,SAAS,WAAW,GAC5B,OAAO,CAAC;EAEV,IACE,YACA,IAAI,aAAa,MAAM,YACvB,IAAI,aAAa,MAAM,UAEvB,QAAQ,gBACN,WAAW,IACX,aAAa,YAAY,MAAM,UAAU,MAAM,QAAQ,CACzD;EAEF,OAAO,CACL,CACE,WAAW,IACX;GAAE;GAAY,UAAU,MAAM;GAAU,UAAU,MAAM;EAAS,CACnE,CACF;CACF;CACA,IAAI,kBAAkB,UAAU,GAAG;EACjC,IAAI,YAAY,IAAI,aAAa,MAAM,UACrC,QA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