@open-pioneer/map 0.10.0 → 0.11.0-dev.20250515143825
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/CHANGELOG.md +22 -14
- package/README.md +1 -1
- package/model/Highlights.js +1 -1
- package/package.json +7 -7
- package/ui/MapAnchor.js +1 -1
- package/ui/MapAnchor.js.map +1 -1
- package/ui/MapContainer.js +27 -27
- package/ui/MapContainer.js.map +1 -1
- package/ui/computeMapAnchorStyles.d.ts +2 -2
- package/ui/computeMapAnchorStyles.js.map +1 -1
- package/ui/styles.css +7 -4
- package/ui/styles.css.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @open-pioneer/map
|
|
2
2
|
|
|
3
|
+
## 0.11.0-dev.20250515143825
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 738390e: Update to Chakra v3
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 738390e: Fix an issue with "raw" map container children that are not wrapped in a map anchor.
|
|
12
|
+
|
|
13
|
+
Consider, for example, the following snippet:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<MapContainer>
|
|
17
|
+
{/* .custom-content does absolute positioning relative to map container */}
|
|
18
|
+
<div className="custom-content">Hi</div>
|
|
19
|
+
</MapContainer>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Previously, the `div` was rendered relative to the map container div but did _not_ respect the map's view padding.
|
|
23
|
+
Now the `div` will move according to the map padding as well.
|
|
24
|
+
|
|
3
25
|
## 0.10.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -84,20 +106,6 @@
|
|
|
84
106
|
}
|
|
85
107
|
```
|
|
86
108
|
|
|
87
|
-
This change also fixes an issue with "raw" map container children that are not wrapped in a map anchor.
|
|
88
|
-
|
|
89
|
-
Consider, for example, the following snippet:
|
|
90
|
-
|
|
91
|
-
```tsx
|
|
92
|
-
<MapContainer>
|
|
93
|
-
{/* .custom-content does absolute positioning relative to map container */}
|
|
94
|
-
<div className="custom-content">Hi</div>
|
|
95
|
-
</MapContainer>
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Previously, the `div` was rendered relative to the map container div but _did not_ respect the map's view padding.
|
|
99
|
-
Now the `div` will move according to the map padding as well.
|
|
100
|
-
|
|
101
109
|
## 0.9.0
|
|
102
110
|
|
|
103
111
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ The `MapContainer` fills the entire available space.
|
|
|
24
24
|
Example: Integration of a map container with a given map (for an example with `DefaultMapProvider` see [Using the `DefaultMapProvider`](#using-the-defaultmapprovider):
|
|
25
25
|
|
|
26
26
|
```jsx
|
|
27
|
-
import { Box } from "@
|
|
27
|
+
import { Box } from "@chakra-ui/react";
|
|
28
28
|
import { MapContainer } from "@open-pioneer/map";
|
|
29
29
|
|
|
30
30
|
// ...
|
package/model/Highlights.js
CHANGED
|
@@ -16,7 +16,7 @@ import 'ol/Observable.js';
|
|
|
16
16
|
import 'ol/proj.js';
|
|
17
17
|
import 'react';
|
|
18
18
|
import 'react/jsx-runtime';
|
|
19
|
-
import '@
|
|
19
|
+
import '@chakra-ui/react';
|
|
20
20
|
import '@open-pioneer/react-utils';
|
|
21
21
|
import 'react-dom';
|
|
22
22
|
import '../ui/MapContainerContext.js';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/map",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0-dev.20250515143825",
|
|
5
5
|
"description": "This package integrates OpenLayers maps into an open pioneer trails application.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"directory": "src/packages/map"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@open-pioneer/core": "
|
|
19
|
-
"@open-pioneer/http": "
|
|
20
|
-
"@open-pioneer/react-utils": "
|
|
21
|
-
"@open-pioneer/runtime": "
|
|
17
|
+
"@chakra-ui/react": "^3.17.0",
|
|
18
|
+
"@open-pioneer/core": "4.0.0-dev.20250512105016",
|
|
19
|
+
"@open-pioneer/http": "4.0.0-dev.20250512105016",
|
|
20
|
+
"@open-pioneer/react-utils": "4.0.0-dev.20250512105016",
|
|
21
|
+
"@open-pioneer/runtime": "4.0.0-dev.20250512105016",
|
|
22
22
|
"@types/proj4": "^2.5.2",
|
|
23
23
|
"ol": "^10.5.0",
|
|
24
24
|
"proj4": "^2.12.1",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react-dom": "^19.1.0",
|
|
27
27
|
"react-use": "^17.5.1",
|
|
28
28
|
"uuid": "^11.1.0",
|
|
29
|
-
"@conterra/reactivity-core": "^0.
|
|
29
|
+
"@conterra/reactivity-core": "^0.6.0"
|
|
30
30
|
},
|
|
31
31
|
"exports": {
|
|
32
32
|
"./package.json": "./package.json",
|
package/ui/MapAnchor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Box } from '@
|
|
2
|
+
import { Box } from '@chakra-ui/react';
|
|
3
3
|
import { useCommonComponentProps } from '@open-pioneer/react-utils';
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
package/ui/MapAnchor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapAnchor.js","sources":["MapAnchor.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box } from \"@
|
|
1
|
+
{"version":3,"file":"MapAnchor.js","sources":["MapAnchor.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box } from \"@chakra-ui/react\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { ReactNode, useMemo } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { computeMapAnchorStyles } from \"./computeMapAnchorStyles\";\nimport { useMapContainerContext } from \"./MapContainerContext\";\n\n/**\n * The position of an anchor on the map.\n *\n * This is either a predefined position (like a corner) or a completely manual position.\n */\nexport type MapAnchorPosition =\n | \"manual\"\n | \"top-left\"\n | \"top-right\"\n | \"top-center\"\n | \"bottom-left\"\n | \"bottom-right\"\n | \"bottom-center\"\n | \"left-center\"\n | \"right-center\"\n | \"center\";\n\nconst defaultPosition: MapAnchorPosition = \"top-right\";\n\nexport interface MapAnchorProps extends CommonComponentProps {\n /**\n * The position of the anchor container above the map.\n *\n * Use `manual` if you wish to position the anchor manually using absolute positioning.\n * This can be achieved by configuring a css class on the map anchor and using css properties like `left`, `top`, etc.\n *\n * @default \"top-right\"\n */\n position?: MapAnchorPosition;\n\n /**\n * Horizontal gap in pixel applied to anchor container.\n * Only interpreted if a non-manual position is used.\n *\n * @default 0\n */\n horizontalGap?: number;\n\n /**\n * Vertical gap in pixel applied to anchor container.\n * Only interpreted if a non-manual position is used.\n *\n * @default 0 (If positioned at the bottom, default verticalGap == `30`)\n */\n verticalGap?: number;\n\n children?: ReactNode;\n}\n\n/**\n * A map anchor is a layout component that sits on top of the map.\n *\n * It can be used to position widgets (such as zoom buttons) at a specific location.\n *\n * Map anchors respect the map's current _view padding_.\n */\nexport function MapAnchor(props: MapAnchorProps): ReactNode {\n const { position = defaultPosition, children, horizontalGap, verticalGap } = props;\n const { containerProps } = useCommonComponentProps(\"map-anchor\", props);\n const { mapAnchorsHost } = useMapContainerContext();\n const styleProps = useMemo(\n () => computeMapAnchorStyles(position, horizontalGap, verticalGap),\n [position, horizontalGap, verticalGap]\n );\n\n return createPortal(\n <Box {...containerProps} {...styleProps}>\n {children}\n </Box>,\n mapAnchorsHost\n );\n}\n"],"names":[],"mappings":";;;;;;;;AA0BA,MAAM,eAAqC,GAAA,WAAA;AAuCpC,SAAS,UAAU,KAAkC,EAAA;AACxD,EAAA,MAAM,EAAE,QAAW,GAAA,eAAA,EAAiB,QAAU,EAAA,aAAA,EAAe,aAAgB,GAAA,KAAA;AAC7E,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,cAAc,KAAK,CAAA;AACtE,EAAM,MAAA,EAAE,cAAe,EAAA,GAAI,sBAAuB,EAAA;AAClD,EAAA,MAAM,UAAa,GAAA,OAAA;AAAA,IACf,MAAM,sBAAA,CAAuB,QAAU,EAAA,aAAA,EAAe,WAAW,CAAA;AAAA,IACjE,CAAC,QAAU,EAAA,aAAA,EAAe,WAAW;AAAA,GACzC;AAEA,EAAO,OAAA,YAAA;AAAA,wBACF,GAAK,EAAA,EAAA,GAAG,cAAiB,EAAA,GAAG,YACxB,QACL,EAAA,CAAA;AAAA,IACA;AAAA,GACJ;AACJ;;;;"}
|
package/ui/MapContainer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { chakra } from '@
|
|
2
|
+
import { chakra } from '@chakra-ui/react';
|
|
3
3
|
import { createLogger } from '@open-pioneer/core';
|
|
4
4
|
import { useCommonComponentProps } from '@open-pioneer/react-utils';
|
|
5
5
|
import { useRef, useState, useEffect, useMemo } from 'react';
|
|
@@ -16,7 +16,7 @@ function MapContainer(props) {
|
|
|
16
16
|
"aria-label": ariaLabel,
|
|
17
17
|
"aria-labelledby": ariaLabelledBy
|
|
18
18
|
} = props;
|
|
19
|
-
const { containerProps } = useCommonComponentProps("map-container", props);
|
|
19
|
+
const { containerProps } = useCommonComponentProps("map-container-root", props);
|
|
20
20
|
const mapContainer = useRef(null);
|
|
21
21
|
const mapAnchorsHost = useRef(null);
|
|
22
22
|
const modelState = useMapModel(props);
|
|
@@ -53,31 +53,31 @@ function MapContainer(props) {
|
|
|
53
53
|
"--map-padding-right": `${viewPadding?.right ?? 0}px`
|
|
54
54
|
};
|
|
55
55
|
}, [viewPadding]);
|
|
56
|
-
return /* @__PURE__ */ jsxs(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
);
|
|
56
|
+
return /* @__PURE__ */ jsxs(chakra.div, { ...containerProps, css: styleProps, children: [
|
|
57
|
+
/* @__PURE__ */ jsx(
|
|
58
|
+
chakra.div,
|
|
59
|
+
{
|
|
60
|
+
className: "map-container",
|
|
61
|
+
ref: mapContainer,
|
|
62
|
+
role,
|
|
63
|
+
"aria-label": ariaLabel,
|
|
64
|
+
"aria-labelledby": ariaLabelledBy,
|
|
65
|
+
h: "100%",
|
|
66
|
+
w: "100%",
|
|
67
|
+
tabIndex: 0
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
/* @__PURE__ */ jsx(chakra.div, { ref: mapAnchorsHost, className: "map-anchors", children: ready && map && /* @__PURE__ */ jsx(
|
|
71
|
+
MapContainerReady,
|
|
72
|
+
{
|
|
73
|
+
olMap: map.olMap,
|
|
74
|
+
mapAnchorsHost: mapAnchorsHost.current,
|
|
75
|
+
viewPadding,
|
|
76
|
+
viewPaddingChangeBehavior,
|
|
77
|
+
children
|
|
78
|
+
}
|
|
79
|
+
) })
|
|
80
|
+
] });
|
|
81
81
|
}
|
|
82
82
|
function MapContainerReady(props) {
|
|
83
83
|
const {
|
package/ui/MapContainer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapContainer.js","sources":["MapContainer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { chakra } from \"@open-pioneer/chakra-integration\";\nimport { Resource, createLogger } from \"@open-pioneer/core\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport type OlMap from \"ol/Map\";\nimport { Extent } from \"ol/extent\";\nimport { ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { MapModel, MapPadding } from \"../api\";\nimport { MapContainerContextProvider, MapContainerContextType } from \"./MapContainerContext\";\nimport { MapModelProps, useMapModel } from \"./useMapModel\";\nconst LOG = createLogger(\"map:MapContainer\");\n\nexport interface MapContainerProps extends CommonComponentProps, MapModelProps {\n /**\n * Sets the map's padding directly.\n * Do not use the view's padding property directly on the OL map.\n *\n * See: https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding)\n */\n viewPadding?: MapPadding | undefined;\n\n /**\n * Behavior performed by the map when the view padding changes.\n *\n * - `none`: Do nothing.\n * - `preserve-center`: Ensures that the center point remains the same by animating the view.\n * - `preserve-extent`: Ensures that the extent remains the same by zooming.\n *\n * @default \"preserve-center\"\n */\n viewPaddingChangeBehavior?: \"none\" | \"preserve-center\" | \"preserve-extent\";\n\n children?: ReactNode;\n\n /**\n * Optional role property.\n *\n * This property is directly applied to the map's container div element.\n */\n role?: string;\n\n /**\n * Optional aria-labelledby property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-labelledby\"?: string;\n\n /**\n * Optional aria-label property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-label\"?: string;\n}\n\n/**\n * Displays the map with the given id.\n *\n * There can only be at most one MapContainer for every map.\n */\nexport function MapContainer(props: MapContainerProps) {\n const {\n viewPadding,\n viewPaddingChangeBehavior,\n children,\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy\n } = props;\n const { containerProps } = useCommonComponentProps(\"map-container\", props);\n const mapContainer = useRef<HTMLDivElement>(null);\n const mapAnchorsHost = useRef<HTMLDivElement>(null);\n const modelState = useMapModel(props);\n const map = modelState.map;\n\n const [ready, setReady] = useState(false);\n\n useEffect(() => {\n if (modelState.kind === \"loading\") {\n return;\n }\n\n if (modelState.kind === \"rejected\") {\n LOG.error(`Cannot display the map. Caused by `, modelState.error);\n return;\n }\n\n if (!map) {\n LOG.error(`No configuration available for the configured map.`);\n return;\n }\n\n // Mount the map into the DOM\n if (mapContainer.current) {\n const resource = registerMapTarget(map, mapContainer.current);\n return () => resource?.destroy();\n }\n }, [modelState, map]);\n\n // Wait for mount to make sure that the map anchors host is available\n useEffect(() => {\n setReady(true);\n }, []);\n\n const styleProps = useMemo(() => {\n return {\n height: \"100%\",\n position: \"relative\",\n\n // set css variables according to view padding\n \"--map-padding-top\": `${viewPadding?.top ?? 0}px`,\n \"--map-padding-bottom\": `${viewPadding?.bottom ?? 0}px`,\n \"--map-padding-left\": `${viewPadding?.left ?? 0}px`,\n \"--map-padding-right\": `${viewPadding?.right ?? 0}px`\n };\n }, [viewPadding]);\n\n return (\n <chakra.div\n {...containerProps}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n ref={mapContainer}\n sx={styleProps}\n //eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n >\n {ready && map && (\n <MapContainerReady\n olMap={map.olMap}\n mapAnchorsHost={mapAnchorsHost.current!}\n viewPadding={viewPadding}\n viewPaddingChangeBehavior={viewPaddingChangeBehavior}\n >\n {children}\n </MapContainerReady>\n )}\n <chakra.div ref={mapAnchorsHost} className=\"map-anchors\">\n {/* Map anchors will be mounted here via portal */}\n </chakra.div>\n </chakra.div>\n );\n}\n\n/**\n * This inner component is rendered when the map has been loaded.\n *\n * It provides the map instance and additional properties down the component tree.\n */\nfunction MapContainerReady(\n props: { olMap: OlMap; mapAnchorsHost: HTMLElement } & Omit<\n MapContainerProps,\n \"mapId\" | \"map\" | \"className\"\n >\n): ReactNode {\n const {\n olMap,\n mapAnchorsHost,\n viewPadding: viewPaddingProp,\n viewPaddingChangeBehavior = \"preserve-center\",\n children\n } = props;\n\n const viewPadding = useMemo<Required<MapPadding>>(() => {\n return {\n left: viewPaddingProp?.left ?? 0,\n right: viewPaddingProp?.right ?? 0,\n top: viewPaddingProp?.top ?? 0,\n bottom: viewPaddingProp?.bottom ?? 0\n };\n }, [viewPaddingProp]);\n\n // Apply view padding\n useEffect(() => {\n const mapView = olMap?.getView();\n if (!olMap || !mapView) {\n return;\n }\n\n const oldCenter = mapView.getCenter();\n const oldPadding = fromOlPadding(mapView.padding);\n const oldExtent = extentIncludingPadding(olMap, oldPadding);\n\n mapView.padding = toOlPadding(viewPadding);\n switch (viewPaddingChangeBehavior) {\n case \"preserve-center\":\n mapView.animate({ center: oldCenter, duration: 300 });\n break;\n case \"preserve-extent\": {\n if (oldExtent) {\n mapView.animate({\n center: oldCenter,\n resolution: mapView.getResolutionForExtent(oldExtent),\n duration: 300\n });\n }\n break;\n }\n case \"none\":\n }\n }, [viewPadding, olMap, viewPaddingChangeBehavior]);\n\n const mapContext = useMemo((): MapContainerContextType => {\n return {\n mapAnchorsHost\n };\n }, [mapAnchorsHost]);\n return <MapContainerContextProvider value={mapContext}>{children}</MapContainerContextProvider>;\n}\n\nfunction registerMapTarget(mapModel: MapModel, target: HTMLDivElement): Resource | undefined {\n const mapId = mapModel.id;\n const olMap = mapModel.olMap;\n if (olMap.getTarget()) {\n LOG.error(\n `Failed to display the map: the map already has a target. There may be more than one <MapContainer />.`\n );\n return undefined;\n }\n\n LOG.isDebug() && LOG.debug(`Setting target of map '${mapId}':`, target);\n if (!(\"keyboardEventTarget_\" in olMap)) {\n throw new Error(\n \"Internal error: failed to override keyboard event target. The property is no longer present.\"\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = target;\n olMap.setTarget(target);\n\n let unregistered = false;\n return {\n destroy() {\n if (!unregistered) {\n LOG.isDebug() && LOG.debug(`Removing target of map '${mapId}':`, target);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = undefined;\n olMap.setTarget(undefined);\n unregistered = true;\n }\n }\n };\n}\n\n/**\n * Returns the extent visible in the non-padded region of the map.\n */\nfunction extentIncludingPadding(map: OlMap, padding: Required<MapPadding>): Extent | undefined {\n const size = map.getSize();\n if (!size || size.length < 2) {\n return undefined;\n }\n\n const [width, height] = size as [number, number];\n const bottomLeft = map.getCoordinateFromPixel([padding.left, padding.bottom]);\n const topRight = map.getCoordinateFromPixel([\n Math.max(0, width - padding.right),\n Math.max(0, height - padding.top)\n ]);\n if (!bottomLeft || !topRight) {\n return undefined;\n }\n\n const [xmin, ymin] = bottomLeft;\n const [xmax, ymax] = topRight;\n return [xmin, ymin, xmax, ymax] as Extent;\n}\n\nfunction fromOlPadding(padding: number[] | undefined): Required<MapPadding> {\n // top, right, bottom, left\n return {\n top: padding?.[0] ?? 0,\n right: padding?.[1] ?? 0,\n bottom: padding?.[2] ?? 0,\n left: padding?.[3] ?? 0\n };\n}\n\nfunction toOlPadding(padding: Required<MapPadding>): number[] {\n // top, right, bottom, left\n const { top, right, bottom, left } = padding;\n return [top, right, bottom, left];\n}\n"],"names":[],"mappings":";;;;;;;;AAWA,MAAM,GAAA,GAAM,aAAa,kBAAkB,CAAA;AAqDpC,SAAS,aAAa,KAA0B,EAAA;AACnD,EAAM,MAAA;AAAA,IACF,WAAA;AAAA,IACA,yBAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,YAAc,EAAA,SAAA;AAAA,IACd,iBAAmB,EAAA;AAAA,GACnB,GAAA,KAAA;AACJ,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,iBAAiB,KAAK,CAAA;AACzE,EAAM,MAAA,YAAA,GAAe,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CAAC,CAAA;AAC5E,EAAM,MAAA,QAAA,GAAW,IAAI,sBAAuB,CAAA;AAAA,IACxC,IAAK,CAAA,GAAA,CAAI,CAAG,EAAA,KAAA,GAAQ,QAAQ,KAAK,CAAA;AAAA,IACjC,IAAK,CAAA,GAAA,CAAI,CAAG,EAAA,MAAA,GAAS,QAAQ,GAAG;AAAA,GACnC,CAAA;AACD,EAAI,IAAA,CAAC,UAAc,IAAA,CAAC,QAAU,EAAA;AAC1B,IAAO,OAAA,MAAA;AAAA;AAGX,EAAM,MAAA,CAAC,IAAM,EAAA,IAAI,CAAI,GAAA,UAAA;AACrB,EAAM,MAAA,CAAC,IAAM,EAAA,IAAI,CAAI,GAAA,QAAA;AACrB,EAAA,OAAO,CAAC,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,IAAI,CAAA;AAClC;AAEA,SAAS,cAAc,OAAqD,EAAA;AAExE,EAAO,OAAA;AAAA,IACH,GAAA,EAAK,OAAU,GAAA,CAAC,CAAK,IAAA,CAAA;AAAA,IACrB,KAAA,EAAO,OAAU,GAAA,CAAC,CAAK,IAAA,CAAA;AAAA,IACvB,MAAA,EAAQ,OAAU,GAAA,CAAC,CAAK,IAAA,CAAA;AAAA,IACxB,IAAA,EAAM,OAAU,GAAA,CAAC,CAAK,IAAA;AAAA,GAC1B;AACJ;AAEA,SAAS,YAAY,OAAyC,EAAA;AAE1D,EAAA,MAAM,EAAE,GAAA,EAAK,KAAO,EAAA,MAAA,EAAQ,MAAS,GAAA,OAAA;AACrC,EAAA,OAAO,CAAC,GAAA,EAAK,KAAO,EAAA,MAAA,EAAQ,IAAI,CAAA;AACpC;;;;"}
|
|
1
|
+
{"version":3,"file":"MapContainer.js","sources":["MapContainer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { chakra } from \"@chakra-ui/react\";\nimport { Resource, createLogger } from \"@open-pioneer/core\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport type OlMap from \"ol/Map\";\nimport { Extent } from \"ol/extent\";\nimport { ReactNode, useEffect, useMemo, useRef, useState } from \"react\";\nimport { MapModel, MapPadding } from \"../api\";\nimport { MapContainerContextProvider, MapContainerContextType } from \"./MapContainerContext\";\nimport { MapModelProps, useMapModel } from \"./useMapModel\";\nconst LOG = createLogger(\"map:MapContainer\");\n\nexport interface MapContainerProps extends CommonComponentProps, MapModelProps {\n /**\n * Sets the map's padding directly.\n * Do not use the view's padding property directly on the OL map.\n *\n * See: https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding)\n */\n viewPadding?: MapPadding | undefined;\n\n /**\n * Behavior performed by the map when the view padding changes.\n *\n * - `none`: Do nothing.\n * - `preserve-center`: Ensures that the center point remains the same by animating the view.\n * - `preserve-extent`: Ensures that the extent remains the same by zooming.\n *\n * @default \"preserve-center\"\n */\n viewPaddingChangeBehavior?: \"none\" | \"preserve-center\" | \"preserve-extent\";\n\n children?: ReactNode;\n\n /**\n * Optional role property.\n *\n * This property is directly applied to the map's container div element.\n */\n role?: string;\n\n /**\n * Optional aria-labelledby property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-labelledby\"?: string;\n\n /**\n * Optional aria-label property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-label\"?: string;\n}\n\n/**\n * Displays the map with the given id.\n *\n * There can only be at most one MapContainer for every map.\n */\nexport function MapContainer(props: MapContainerProps) {\n const {\n viewPadding,\n viewPaddingChangeBehavior,\n children,\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy\n } = props;\n const { containerProps } = useCommonComponentProps(\"map-container-root\", props);\n const mapContainer = useRef<HTMLDivElement>(null);\n const mapAnchorsHost = useRef<HTMLDivElement>(null);\n const modelState = useMapModel(props);\n const map = modelState.map;\n\n const [ready, setReady] = useState(false);\n\n useEffect(() => {\n if (modelState.kind === \"loading\") {\n return;\n }\n\n if (modelState.kind === \"rejected\") {\n LOG.error(`Cannot display the map. Caused by `, modelState.error);\n return;\n }\n\n if (!map) {\n LOG.error(`No configuration available for the configured map.`);\n return;\n }\n\n // Mount the map into the DOM\n if (mapContainer.current) {\n const resource = registerMapTarget(map, mapContainer.current);\n return () => resource?.destroy();\n }\n }, [modelState, map]);\n\n // Wait for mount to make sure that the map anchors host is available\n useEffect(() => {\n setReady(true);\n }, []);\n\n const styleProps = useMemo(() => {\n return {\n height: \"100%\",\n position: \"relative\",\n\n // set css variables according to view padding\n \"--map-padding-top\": `${viewPadding?.top ?? 0}px`,\n \"--map-padding-bottom\": `${viewPadding?.bottom ?? 0}px`,\n \"--map-padding-left\": `${viewPadding?.left ?? 0}px`,\n \"--map-padding-right\": `${viewPadding?.right ?? 0}px`\n };\n }, [viewPadding]);\n\n return (\n <chakra.div {...containerProps} css={styleProps}>\n {/* Used by open layers to mount the map. This node receives the keyboard focus when interacting with the map. */}\n <chakra.div\n className=\"map-container\"\n ref={mapContainer}\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n h=\"100%\"\n w=\"100%\"\n //eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex\n tabIndex={0}\n />\n\n {/* Contains user widgets (map anchors and raw children). These are separate from the map so they don't interfere with mouse/keyboard events. */}\n <chakra.div ref={mapAnchorsHost} className=\"map-anchors\">\n {ready && map && (\n <MapContainerReady\n olMap={map.olMap}\n mapAnchorsHost={mapAnchorsHost.current!}\n viewPadding={viewPadding}\n viewPaddingChangeBehavior={viewPaddingChangeBehavior}\n >\n {children}\n </MapContainerReady>\n )}\n </chakra.div>\n </chakra.div>\n );\n}\n\n/**\n * This inner component is rendered when the map has been loaded.\n *\n * It provides the map instance and additional properties down the component tree.\n */\nfunction MapContainerReady(\n props: { olMap: OlMap; mapAnchorsHost: HTMLElement } & Omit<\n MapContainerProps,\n \"mapId\" | \"map\" | \"className\"\n >\n): ReactNode {\n const {\n olMap,\n mapAnchorsHost,\n viewPadding: viewPaddingProp,\n viewPaddingChangeBehavior = \"preserve-center\",\n children\n } = props;\n\n const viewPadding = useMemo<Required<MapPadding>>(() => {\n return {\n left: viewPaddingProp?.left ?? 0,\n right: viewPaddingProp?.right ?? 0,\n top: viewPaddingProp?.top ?? 0,\n bottom: viewPaddingProp?.bottom ?? 0\n };\n }, [viewPaddingProp]);\n\n // Apply view padding\n useEffect(() => {\n const mapView = olMap?.getView();\n if (!olMap || !mapView) {\n return;\n }\n\n const oldCenter = mapView.getCenter();\n const oldPadding = fromOlPadding(mapView.padding);\n const oldExtent = extentIncludingPadding(olMap, oldPadding);\n\n mapView.padding = toOlPadding(viewPadding);\n switch (viewPaddingChangeBehavior) {\n case \"preserve-center\":\n mapView.animate({ center: oldCenter, duration: 300 });\n break;\n case \"preserve-extent\": {\n if (oldExtent) {\n mapView.animate({\n center: oldCenter,\n resolution: mapView.getResolutionForExtent(oldExtent),\n duration: 300\n });\n }\n break;\n }\n case \"none\":\n }\n }, [viewPadding, olMap, viewPaddingChangeBehavior]);\n\n const mapContext = useMemo((): MapContainerContextType => {\n return {\n mapAnchorsHost\n };\n }, [mapAnchorsHost]);\n return <MapContainerContextProvider value={mapContext}>{children}</MapContainerContextProvider>;\n}\n\nfunction registerMapTarget(mapModel: MapModel, target: HTMLDivElement): Resource | undefined {\n const mapId = mapModel.id;\n const olMap = mapModel.olMap;\n if (olMap.getTarget()) {\n LOG.error(\n `Failed to display the map: the map already has a target. There may be more than one <MapContainer />.`\n );\n return undefined;\n }\n\n LOG.isDebug() && LOG.debug(`Setting target of map '${mapId}':`, target);\n if (!(\"keyboardEventTarget_\" in olMap)) {\n throw new Error(\n \"Internal error: failed to override keyboard event target. The property is no longer present.\"\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = target;\n olMap.setTarget(target);\n\n let unregistered = false;\n return {\n destroy() {\n if (!unregistered) {\n LOG.isDebug() && LOG.debug(`Removing target of map '${mapId}':`, target);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = undefined;\n olMap.setTarget(undefined);\n unregistered = true;\n }\n }\n };\n}\n\n/**\n * Returns the extent visible in the non-padded region of the map.\n */\nfunction extentIncludingPadding(map: OlMap, padding: Required<MapPadding>): Extent | undefined {\n const size = map.getSize();\n if (!size || size.length < 2) {\n return undefined;\n }\n\n const [width, height] = size as [number, number];\n const bottomLeft = map.getCoordinateFromPixel([padding.left, padding.bottom]);\n const topRight = map.getCoordinateFromPixel([\n Math.max(0, width - padding.right),\n Math.max(0, height - padding.top)\n ]);\n if (!bottomLeft || !topRight) {\n return undefined;\n }\n\n const [xmin, ymin] = bottomLeft;\n const [xmax, ymax] = topRight;\n return [xmin, ymin, xmax, ymax] as Extent;\n}\n\nfunction fromOlPadding(padding: number[] | undefined): Required<MapPadding> {\n // top, right, bottom, left\n return {\n top: padding?.[0] ?? 0,\n right: padding?.[1] ?? 0,\n bottom: padding?.[2] ?? 0,\n left: padding?.[3] ?? 0\n };\n}\n\nfunction toOlPadding(padding: Required<MapPadding>): number[] {\n // top, right, bottom, left\n const { top, right, bottom, left } = padding;\n return [top, right, bottom, left];\n}\n"],"names":[],"mappings":";;;;;;;;AAWA,MAAM,GAAA,GAAM,aAAa,kBAAkB,CAAA;AAqDpC,SAAS,aAAa,KAA0B,EAAA;AACnD,EAAM,MAAA;AAAA,IACF,WAAA;AAAA,IACA,yBAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,YAAc,EAAA,SAAA;AAAA,IACd,iBAAmB,EAAA;AAAA,GACnB,GAAA,KAAA;AACJ,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,sBAAsB,KAAK,CAAA;AAC9E,EAAM,MAAA,YAAA,GAAe,OAAuB,IAAI,CAAA;AAChD,EAAM,MAAA,cAAA,GAAiB,OAAuB,IAAI,CAAA;AAClD,EAAM,MA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AC,QAAQ,IAAM,EAAA,OAAA,CAAQ,MAAM,CAAC,CAAA;AAC5E,EAAM,MAAA,QAAA,GAAW,IAAI,sBAAuB,CAAA;AAAA,IACxC,IAAK,CAAA,GAAA,CAAI,CAAG,EAAA,KAAA,GAAQ,QAAQ,KAAK,CAAA;AAAA,IACjC,IAAK,CAAA,GAAA,CAAI,CAAG,EAAA,MAAA,GAAS,QAAQ,GAAG;AAAA,GACnC,CAAA;AACD,EAAI,IAAA,CAAC,UAAc,IAAA,CAAC,QAAU,EAAA;AAC1B,IAAO,OAAA,MAAA;AAAA;AAGX,EAAM,MAAA,CAAC,IAAM,EAAA,IAAI,CAAI,GAAA,UAAA;AACrB,EAAM,MAAA,CAAC,IAAM,EAAA,IAAI,CAAI,GAAA,QAAA;AACrB,EAAA,OAAO,CAAC,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,IAAI,CAAA;AAClC;AAEA,SAAS,cAAc,OAAqD,EAAA;AAExE,EAAO,OAAA;AAAA,IACH,GAAA,EAAK,OAAU,GAAA,CAAC,CAAK,IAAA,CAAA;AAAA,IACrB,KAAA,EAAO,OAAU,GAAA,CAAC,CAAK,IAAA,CAAA;AAAA,IACvB,MAAA,EAAQ,OAAU,GAAA,CAAC,CAAK,IAAA,CAAA;AAAA,IACxB,IAAA,EAAM,OAAU,GAAA,CAAC,CAAK,IAAA;AAAA,GAC1B;AACJ;AAEA,SAAS,YAAY,OAAyC,EAAA;AAE1D,EAAA,MAAM,EAAE,GAAA,EAAK,KAAO,EAAA,MAAA,EAAQ,MAAS,GAAA,OAAA;AACrC,EAAA,OAAO,CAAC,GAAA,EAAK,KAAO,EAAA,MAAA,EAAQ,IAAI,CAAA;AACpC;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SystemStyleObject } from "@chakra-ui/react";
|
|
2
2
|
import { MapAnchorPosition } from "./MapAnchor";
|
|
3
|
-
export declare function computeMapAnchorStyles(position: MapAnchorPosition, horizontalGap?: number | undefined, verticalGap?: number | undefined):
|
|
3
|
+
export declare function computeMapAnchorStyles(position: MapAnchorPosition, horizontalGap?: number | undefined, verticalGap?: number | undefined): SystemStyleObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeMapAnchorStyles.js","sources":["computeMapAnchorStyles.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {
|
|
1
|
+
{"version":3,"file":"computeMapAnchorStyles.js","sources":["computeMapAnchorStyles.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { SystemStyleObject } from \"@chakra-ui/react\";\nimport { MapAnchorPosition } from \"./MapAnchor\";\n\nexport function computeMapAnchorStyles(\n position: MapAnchorPosition,\n horizontalGap?: number | undefined,\n verticalGap?: number | undefined\n): SystemStyleObject {\n const horizontal = horizontalGap ?? 0;\n const vertical = verticalGap ?? 0;\n const attributionGap = verticalGap == null ? ATTR_GAP : 0;\n\n const styleProps: SystemStyleObject = {};\n switch (position) {\n case \"top-left\":\n styleProps.left = `${horizontal}px`;\n styleProps.top = `${vertical}px`;\n break;\n case \"top-right\":\n styleProps.right = `${horizontal}px`;\n styleProps.top = `${vertical}px`;\n break;\n case \"bottom-left\":\n styleProps.left = `${horizontal}px`;\n styleProps.bottom = `${vertical + attributionGap}px`;\n break;\n case \"bottom-right\":\n styleProps.right = `${horizontal}px`;\n styleProps.bottom = `${vertical + attributionGap}px`;\n break;\n case \"top-center\":\n styleProps.top = `${vertical}px`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translateX(-50%)\";\n break;\n case \"bottom-center\":\n styleProps.bottom = `${vertical + attributionGap}px`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translateX(-50%)\";\n break;\n case \"left-center\":\n styleProps.left = `${horizontal}px`;\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.transform = \"translateY(-50%)\";\n break;\n case \"right-center\":\n styleProps.right = `${horizontal}px`;\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.transform = \"translateY(-50%)\";\n break;\n case \"center\":\n styleProps.top = `calc((100% - ${vertical}px) / 2)`;\n styleProps.left = `calc((100% - ${horizontal}px) / 2)`;\n styleProps.transform = \"translate(-50%, -50%)\";\n break;\n }\n\n styleProps.maxW = `calc((100%) - ${2 * horizontal}px)`;\n styleProps.maxH = `calc((100%) - ${attributionGap}px - ${2 * vertical}px)`;\n return styleProps;\n}\n\n/**\n * height of the ol attribution component\n * improvement: Get height directly from `Attribution` HTMLDivElement\n */\nconst ATTR_HEIGHT = 20;\n\n/**\n * additional space between attribution and map anchor container\n */\nconst ATTR_SPACE = 10;\nconst ATTR_GAP = ATTR_HEIGHT + ATTR_SPACE;\n"],"names":[],"mappings":"AAKgB,SAAA,sBAAA,CACZ,QACA,EAAA,aAAA,EACA,WACiB,EAAA;AACjB,EAAA,MAAM,aAAa,aAAiB,IAAA,CAAA;AACpC,EAAA,MAAM,WAAW,WAAe,IAAA,CAAA;AAChC,EAAM,MAAA,cAAA,GAAiB,WAAe,IAAA,IAAA,GAAO,QAAW,GAAA,CAAA;AAExD,EAAA,MAAM,aAAgC,EAAC;AACvC,EAAA,QAAQ,QAAU;AAAA,IACd,KAAK,UAAA;AACD,MAAW,UAAA,CAAA,IAAA,GAAO,GAAG,UAAU,CAAA,EAAA,CAAA;AAC/B,MAAW,UAAA,CAAA,GAAA,GAAM,GAAG,QAAQ,CAAA,EAAA,CAAA;AAC5B,MAAA;AAAA,IACJ,KAAK,WAAA;AACD,MAAW,UAAA,CAAA,KAAA,GAAQ,GAAG,UAAU,CAAA,EAAA,CAAA;AAChC,MAAW,UAAA,CAAA,GAAA,GAAM,GAAG,QAAQ,CAAA,EAAA,CAAA;AAC5B,MAAA;AAA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AAA;AACvB,MAAA;AAAA,IACJ,KAAK,QAAA;AACD,MAAW,UAAA,CAAA,GAAA,GAAM,gBAAgB,QAAQ,CAAA,QAAA,CAAA;AACzC,MAAW,UAAA,CAAA,IAAA,GAAO,gBAAgB,UAAU,CAAA,QAAA,CAAA;AAC5C,MAAA,UAAA,CAAW,SAAY,GAAA,uBAAA;AACvB,MAAA;AAAA;AAGR,EAAW,UAAA,CAAA,IAAA,GAAO,CAAiB,cAAA,EAAA,CAAA,GAAI,UAAU,CAAA,GAAA,CAAA;AACjD,EAAA,UAAA,CAAW,IAAO,GAAA,CAAA,cAAA,EAAiB,cAAc,CAAA,KAAA,EAAQ,IAAI,QAAQ,CAAA,GAAA,CAAA;AACrE,EAAO,OAAA,UAAA;AACX;AAMA,MAAM,WAAc,GAAA,EAAA;AAKpB,MAAM,UAAa,GAAA,EAAA;AACnB,MAAM,WAAW,WAAc,GAAA,UAAA;;;;"}
|
package/ui/styles.css
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
/* Move attribution according to map view's padding */
|
|
4
4
|
|
|
5
|
-
.map-container .ol-viewport .ol-attribution {
|
|
5
|
+
.map-container-root .map-container .ol-viewport .ol-attribution {
|
|
6
6
|
bottom: var(--map-padding-bottom);
|
|
7
7
|
right: var(--map-padding-right);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
.map-container .map-anchors {
|
|
10
|
+
.map-container-root .map-anchors {
|
|
11
11
|
pointer-events: none;
|
|
12
12
|
overflow: hidden;
|
|
13
13
|
|
|
@@ -22,8 +22,7 @@
|
|
|
22
22
|
transition-timing-function: ease-in-out;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
.map-container .map-anchors .map-anchor {
|
|
26
|
-
pointer-events: auto;
|
|
25
|
+
.map-container-root .map-anchors .map-anchor {
|
|
27
26
|
z-index: 1;
|
|
28
27
|
overflow: hidden;
|
|
29
28
|
|
|
@@ -31,4 +30,8 @@
|
|
|
31
30
|
/* positioned absolute in .map-anchors, but actual coordinates are currently set via JS */
|
|
32
31
|
}
|
|
33
32
|
|
|
33
|
+
.map-container-root .map-anchors > * {
|
|
34
|
+
pointer-events: auto;
|
|
35
|
+
}
|
|
36
|
+
|
|
34
37
|
/*# sourceMappingURL=styles.css.map */
|
package/ui/styles.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["styles.css"],"names":[],"mappings":"AAAA,mBAAmB;;AAEnB,qDAAqD;;AACrD;IACI,iCAAiC;IACjC,+BAA+B;AACnC;;AAEA;IACI,oBAAoB;IACpB,gBAAgB;;IAEhB,kBAAkB;IAClB,2BAA2B;IAC3B,iCAAiC;IACjC,6BAA6B;IAC7B,+BAA+B;;IAE/B,6CAA6C;IAC7C,0BAA0B;IAC1B,uCAAuC;AAC3C;;AAEA;IACI,
|
|
1
|
+
{"version":3,"sources":["styles.css"],"names":[],"mappings":"AAAA,mBAAmB;;AAEnB,qDAAqD;;AACrD;IACI,iCAAiC;IACjC,+BAA+B;AACnC;;AAEA;IACI,oBAAoB;IACpB,gBAAgB;;IAEhB,kBAAkB;IAClB,2BAA2B;IAC3B,iCAAiC;IACjC,6BAA6B;IAC7B,+BAA+B;;IAE/B,6CAA6C;IAC7C,0BAA0B;IAC1B,uCAAuC;AAC3C;;AAEA;IACI,UAAU;IACV,gBAAgB;;IAEhB,kBAAkB;IAClB,yFAAyF;AAC7F;;AAEA;IACI,oBAAoB;AACxB","file":"styles.css","sourcesContent":["@import \"ol/ol.css\";\n\n/* Move attribution according to map view's padding */\n.map-container-root .map-container .ol-viewport .ol-attribution {\n bottom: var(--map-padding-bottom);\n right: var(--map-padding-right);\n}\n\n.map-container-root .map-anchors {\n pointer-events: none;\n overflow: hidden;\n\n position: absolute;\n top: var(--map-padding-top);\n bottom: var(--map-padding-bottom);\n left: var(--map-padding-left);\n right: var(--map-padding-right);\n\n transition-property: left, right, top, bottom;\n transition-duration: 200ms;\n transition-timing-function: ease-in-out;\n}\n\n.map-container-root .map-anchors .map-anchor {\n z-index: 1;\n overflow: hidden;\n\n position: absolute;\n /* positioned absolute in .map-anchors, but actual coordinates are currently set via JS */\n}\n\n.map-container-root .map-anchors > * {\n pointer-events: auto;\n}\n"]}
|