@open-pioneer/map 0.0.0-dev-20241120114910
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 +354 -0
- package/LICENSE +202 -0
- package/MapRegistryImpl.d.ts +17 -0
- package/MapRegistryImpl.js +91 -0
- package/MapRegistryImpl.js.map +1 -0
- package/README.md +871 -0
- package/_virtual/_virtual-pioneer-module_react-hooks.js +7 -0
- package/_virtual/_virtual-pioneer-module_react-hooks.js.map +1 -0
- package/api/BaseFeature.d.ts +31 -0
- package/api/MapConfig.d.ts +111 -0
- package/api/MapModel.d.ts +229 -0
- package/api/MapRegistry.d.ts +48 -0
- package/api/index.d.ts +15 -0
- package/api/layers/GroupLayer.d.ts +50 -0
- package/api/layers/GroupLayer.js +6 -0
- package/api/layers/GroupLayer.js.map +1 -0
- package/api/layers/SimpleLayer.d.ts +27 -0
- package/api/layers/SimpleLayer.js +6 -0
- package/api/layers/SimpleLayer.js.map +1 -0
- package/api/layers/WMSLayer.d.ts +57 -0
- package/api/layers/WMSLayer.js +6 -0
- package/api/layers/WMSLayer.js.map +1 -0
- package/api/layers/WMTSLayer.d.ts +33 -0
- package/api/layers/WMTSLayer.js +6 -0
- package/api/layers/WMTSLayer.js.map +1 -0
- package/api/layers/base.d.ts +242 -0
- package/api/layers/base.js +9 -0
- package/api/layers/base.js.map +1 -0
- package/api/layers/index.d.ts +5 -0
- package/api/shared.d.ts +10 -0
- package/assets/images/mapMarker.png +0 -0
- package/index.d.ts +1 -0
- package/index.js +15 -0
- package/index.js.map +1 -0
- package/internalTestSupport.d.ts +8 -0
- package/internalTestSupport.js +2 -0
- package/internalTestSupport.js.map +1 -0
- package/layers/BkgTopPlusOpen.d.ts +21 -0
- package/layers/BkgTopPlusOpen.js +61 -0
- package/layers/BkgTopPlusOpen.js.map +1 -0
- package/model/AbstractLayer.d.ts +25 -0
- package/model/AbstractLayer.js +186 -0
- package/model/AbstractLayer.js.map +1 -0
- package/model/AbstractLayerBase.d.ts +54 -0
- package/model/AbstractLayerBase.js +119 -0
- package/model/AbstractLayerBase.js.map +1 -0
- package/model/Highlights.d.ts +42 -0
- package/model/Highlights.js +272 -0
- package/model/Highlights.js.map +1 -0
- package/model/LayerCollectionImpl.d.ts +27 -0
- package/model/LayerCollectionImpl.js +228 -0
- package/model/LayerCollectionImpl.js.map +1 -0
- package/model/MapModelImpl.d.ts +46 -0
- package/model/MapModelImpl.js +271 -0
- package/model/MapModelImpl.js.map +1 -0
- package/model/SublayersCollectionImpl.d.ts +18 -0
- package/model/SublayersCollectionImpl.js +31 -0
- package/model/SublayersCollectionImpl.js.map +1 -0
- package/model/createMapModel.d.ts +4 -0
- package/model/createMapModel.js +157 -0
- package/model/createMapModel.js.map +1 -0
- package/model/layers/GroupLayerImpl.d.ts +39 -0
- package/model/layers/GroupLayerImpl.js +88 -0
- package/model/layers/GroupLayerImpl.js.map +1 -0
- package/model/layers/SimpleLayerImpl.d.ts +13 -0
- package/model/layers/SimpleLayerImpl.js +19 -0
- package/model/layers/SimpleLayerImpl.js.map +1 -0
- package/model/layers/WMSLayerImpl.d.ts +41 -0
- package/model/layers/WMSLayerImpl.js +297 -0
- package/model/layers/WMSLayerImpl.js.map +1 -0
- package/model/layers/WMTSLayerImpl.d.ts +17 -0
- package/model/layers/WMTSLayerImpl.js +156 -0
- package/model/layers/WMTSLayerImpl.js.map +1 -0
- package/package.json +86 -0
- package/projections.d.ts +27 -0
- package/projections.js +15 -0
- package/projections.js.map +1 -0
- package/services.d.ts +1 -0
- package/services.js +2 -0
- package/services.js.map +1 -0
- package/ui/CssProps.d.ts +9 -0
- package/ui/CssProps.js +13 -0
- package/ui/CssProps.js.map +1 -0
- package/ui/DefaultMapProvider.d.ts +39 -0
- package/ui/DefaultMapProvider.js +24 -0
- package/ui/DefaultMapProvider.js.map +1 -0
- package/ui/MapAnchor.d.ts +36 -0
- package/ui/MapAnchor.js +28 -0
- package/ui/MapAnchor.js.map +1 -0
- package/ui/MapContainer.d.ts +50 -0
- package/ui/MapContainer.js +191 -0
- package/ui/MapContainer.js.map +1 -0
- package/ui/MapContainerContext.d.ts +7 -0
- package/ui/MapContainerContext.js +17 -0
- package/ui/MapContainerContext.js.map +1 -0
- package/ui/computeMapAnchorStyles.d.ts +3 -0
- package/ui/computeMapAnchorStyles.js +51 -0
- package/ui/computeMapAnchorStyles.js.map +1 -0
- package/ui/hooks.d.ts +34 -0
- package/ui/hooks.js +73 -0
- package/ui/hooks.js.map +1 -0
- package/ui/styles.css +10 -0
- package/ui/styles.css.map +1 -0
- package/ui/useMapModel.d.ts +58 -0
- package/ui/useMapModel.js +59 -0
- package/ui/useMapModel.js.map +1 -0
- package/util/capabilities-utils.d.ts +2 -0
- package/util/capabilities-utils.js +11 -0
- package/util/capabilities-utils.js.map +1 -0
- package/util/geometry-utils.d.ts +7 -0
- package/util/geometry-utils.js +25 -0
- package/util/geometry-utils.js.map +1 -0
- package/util/ol-test-support.d.ts +2 -0
- package/util/ol-test-support.js +24 -0
- package/util/ol-test-support.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projections.js","sources":["projections.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { register } from \"ol/proj/proj4\";\nimport proj4, { ProjectionDefinition as Proj4ProjectionDefinition } from \"proj4\";\n\nexport type ProjectionDefinition = string | Proj4ProjectionDefinition;\n\n/**\n * Adds new registrations to the global [proj4js](https://github.com/proj4js/proj4js) definition set.\n *\n * See the proj4js documentation for more details.\n *\n * Example:\n *\n * ```ts\n * import { registerProjections } from \"@open-pioneer/map\";\n *\n * registerProjections({\n * \"EPSG:25832\": \"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\",\n * // ... more projections\n * });\n * ```\n *\n * @param projections\n * An object containing (key, definition) pairs. The key must be projection name (such as `\"EPSG:4326\"`).\n * The value can be a string defining the projection or an existing proj4 definition object.\n */\nexport function registerProjections(projections: Record<string, ProjectionDefinition>): void {\n for (const [name, definition] of Object.entries(projections)) {\n proj4.defs(name, definition);\n }\n register(proj4);\n}\n\n/**\n * Searches the global [proj4js](https://github.com/proj4js/proj4js) definition set for a definition with the given name.\n */\nexport function getProjection(name: string): Proj4ProjectionDefinition {\n return proj4.defs(name);\n}\n"],"names":[],"mappings":";;;AA2BO,SAAS,oBAAoB,WAAyD,EAAA;AACzF,EAAA,KAAA,MAAW,CAAC,IAAM,EAAA,UAAU,KAAK,MAAO,CAAA,OAAA,CAAQ,WAAW,CAAG,EAAA;AAC1D,IAAM,KAAA,CAAA,IAAA,CAAK,MAAM,UAAU,CAAA,CAAA;AAAA,GAC/B;AACA,EAAA,QAAA,CAAS,KAAK,CAAA,CAAA;AAClB,CAAA;AAKO,SAAS,cAAc,IAAyC,EAAA;AACnE,EAAO,OAAA,KAAA,CAAM,KAAK,IAAI,CAAA,CAAA;AAC1B;;;;"}
|
package/services.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MapRegistryImpl } from "./MapRegistryImpl";
|
package/services.js
ADDED
package/services.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/ui/CssProps.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CssProp {
|
|
2
|
+
ref: string;
|
|
3
|
+
definition: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function createCssProp(name: string): CssProp;
|
|
6
|
+
export declare const PADDING_LEFT: CssProp;
|
|
7
|
+
export declare const PADDING_RIGHT: CssProp;
|
|
8
|
+
export declare const PADDING_TOP: CssProp;
|
|
9
|
+
export declare const PADDING_BOTTOM: CssProp;
|
package/ui/CssProps.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function createCssProp(name) {
|
|
2
|
+
return {
|
|
3
|
+
definition: `--${name}`,
|
|
4
|
+
ref: `var(--${name})`
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
const PADDING_LEFT = createCssProp("map-padding-left");
|
|
8
|
+
const PADDING_RIGHT = createCssProp("map-padding-right");
|
|
9
|
+
const PADDING_TOP = createCssProp("map-padding-top");
|
|
10
|
+
const PADDING_BOTTOM = createCssProp("map-padding-bottom");
|
|
11
|
+
|
|
12
|
+
export { PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT, PADDING_TOP, createCssProp };
|
|
13
|
+
//# sourceMappingURL=CssProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CssProps.js","sources":["CssProps.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nexport interface CssProp {\n // css expression to retrieve the value, i.e. var(..:)\n ref: string;\n\n // css property name (i.e. --...)\n definition: string;\n}\n\nexport function createCssProp(name: string): CssProp {\n return {\n definition: `--${name}`,\n ref: `var(--${name})`\n };\n}\n\nexport const PADDING_LEFT = createCssProp(\"map-padding-left\");\nexport const PADDING_RIGHT = createCssProp(\"map-padding-right\");\nexport const PADDING_TOP = createCssProp(\"map-padding-top\");\nexport const PADDING_BOTTOM = createCssProp(\"map-padding-bottom\");\n"],"names":[],"mappings":"AAUO,SAAS,cAAc,IAAuB,EAAA;AACjD,EAAO,OAAA;AAAA,IACH,UAAA,EAAY,KAAK,IAAI,CAAA,CAAA;AAAA,IACrB,GAAA,EAAK,SAAS,IAAI,CAAA,CAAA,CAAA;AAAA,GACtB,CAAA;AACJ,CAAA;AAEa,MAAA,YAAA,GAAe,cAAc,kBAAkB,EAAA;AAC/C,MAAA,aAAA,GAAgB,cAAc,mBAAmB,EAAA;AACjD,MAAA,WAAA,GAAc,cAAc,iBAAiB,EAAA;AAC7C,MAAA,cAAA,GAAiB,cAAc,oBAAoB;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { MapModelProps } from "./useMapModel";
|
|
2
|
+
/**
|
|
3
|
+
* Configures the given map as the default map for all child components.
|
|
4
|
+
* Child components do not need to specify the map explicitly, unless they wish to use a different one.
|
|
5
|
+
*
|
|
6
|
+
* The map can be specified either by its id (`mapId`) or by a direct reference to the map model (`map`).
|
|
7
|
+
* Specifying both `mapId` and `map` at the same time will result in an error.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* Using map id:
|
|
12
|
+
*
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <DefaultMapProvider mapId="my-map">
|
|
15
|
+
* <MapContainer />
|
|
16
|
+
* <Toc />
|
|
17
|
+
* </DefaultMapProvider>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
*
|
|
22
|
+
* Using map model reference:
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <DefaultMapProvider map={myMapModel}>
|
|
26
|
+
* <MapContainer />
|
|
27
|
+
* <Toc />
|
|
28
|
+
* </DefaultMapProvider>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function DefaultMapProvider(props: MapModelProps & {
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
/**
|
|
35
|
+
* Accesses the default map props provided by {@link DefaultMapProvider} (or returns undefined).
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function useDefaultMapProps(): MapModelProps | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createContext, useMemo, useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
const DefaultMapContext = createContext(void 0);
|
|
5
|
+
DefaultMapContext.displayName = "DefaultMapContext";
|
|
6
|
+
function DefaultMapProvider(props) {
|
|
7
|
+
const { mapId, map, children } = props;
|
|
8
|
+
const value = useMemo(() => ({ mapId, map }), [mapId, map]);
|
|
9
|
+
if (mapId != null && map != null) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
`Cannot specify both 'mapId' and 'map' in DefaultMapProvider at the same time.`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
if (mapId == null && map == null) {
|
|
15
|
+
throw new Error(`Either 'mapId' or 'map' must be specified in DefaultMapProvider.`);
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ jsx(DefaultMapContext.Provider, { value, children });
|
|
18
|
+
}
|
|
19
|
+
function useDefaultMapProps() {
|
|
20
|
+
return useContext(DefaultMapContext);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { DefaultMapProvider, useDefaultMapProps };
|
|
24
|
+
//# sourceMappingURL=DefaultMapProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultMapProvider.js","sources":["DefaultMapProvider.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createContext, useContext, useMemo } from \"react\";\nimport { MapModelProps } from \"./useMapModel\";\n\nconst DefaultMapContext = createContext<MapModelProps | undefined>(undefined);\nDefaultMapContext.displayName = \"DefaultMapContext\";\n\n/**\n * Configures the given map as the default map for all child components.\n * Child components do not need to specify the map explicitly, unless they wish to use a different one.\n *\n * The map can be specified either by its id (`mapId`) or by a direct reference to the map model (`map`).\n * Specifying both `mapId` and `map` at the same time will result in an error.\n *\n * @example\n *\n * Using map id:\n *\n * ```tsx\n * <DefaultMapProvider mapId=\"my-map\">\n * <MapContainer />\n * <Toc />\n * </DefaultMapProvider>\n * ```\n *\n * @example\n *\n * Using map model reference:\n *\n * ```tsx\n * <DefaultMapProvider map={myMapModel}>\n * <MapContainer />\n * <Toc />\n * </DefaultMapProvider>\n * ```\n */\nexport function DefaultMapProvider(props: MapModelProps & { children?: React.ReactNode }) {\n const { mapId, map, children } = props;\n const value = useMemo((): MapModelProps => ({ mapId, map }), [mapId, map]);\n if (mapId != null && map != null) {\n throw new Error(\n `Cannot specify both 'mapId' and 'map' in DefaultMapProvider at the same time.`\n );\n }\n if (mapId == null && map == null) {\n throw new Error(`Either 'mapId' or 'map' must be specified in DefaultMapProvider.`);\n }\n return <DefaultMapContext.Provider value={value}>{children}</DefaultMapContext.Provider>;\n}\n\n/**\n * Accesses the default map props provided by {@link DefaultMapProvider} (or returns undefined).\n *\n * @internal\n */\nexport function useDefaultMapProps(): MapModelProps | undefined {\n return useContext(DefaultMapContext);\n}\n"],"names":[],"mappings":";;;AAKA,MAAM,iBAAA,GAAoB,cAAyC,KAAS,CAAA,CAAA,CAAA;AAC5E,iBAAA,CAAkB,WAAc,GAAA,mBAAA,CAAA;AA+BzB,SAAS,mBAAmB,KAAuD,EAAA;AACtF,EAAA,MAAM,EAAE,KAAA,EAAO,GAAK,EAAA,QAAA,EAAa,GAAA,KAAA,CAAA;AACjC,EAAM,MAAA,KAAA,GAAQ,OAAQ,CAAA,OAAsB,EAAE,KAAA,EAAO,KAAQ,CAAA,EAAA,CAAC,KAAO,EAAA,GAAG,CAAC,CAAA,CAAA;AACzE,EAAI,IAAA,KAAA,IAAS,IAAQ,IAAA,GAAA,IAAO,IAAM,EAAA;AAC9B,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,6EAAA,CAAA;AAAA,KACJ,CAAA;AAAA,GACJ;AACA,EAAI,IAAA,KAAA,IAAS,IAAQ,IAAA,GAAA,IAAO,IAAM,EAAA;AAC9B,IAAM,MAAA,IAAI,MAAM,CAAkE,gEAAA,CAAA,CAAA,CAAA;AAAA,GACtF;AACA,EAAA,uBAAQ,GAAA,CAAA,iBAAA,CAAkB,QAAlB,EAAA,EAA2B,OAAe,QAAS,EAAA,CAAA,CAAA;AAC/D,CAAA;AAOO,SAAS,kBAAgD,GAAA;AAC5D,EAAA,OAAO,WAAW,iBAAiB,CAAA,CAAA;AACvC;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CommonComponentProps } from "@open-pioneer/react-utils";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export type MapAnchorPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
4
|
+
export interface MapAnchorProps extends CommonComponentProps {
|
|
5
|
+
/**
|
|
6
|
+
* The position of the anchor container above the map.
|
|
7
|
+
* @default "top-right"
|
|
8
|
+
*/
|
|
9
|
+
position?: MapAnchorPosition;
|
|
10
|
+
/**
|
|
11
|
+
* Horizontal gap in pixel applied to anchor container.
|
|
12
|
+
*
|
|
13
|
+
* Applied:
|
|
14
|
+
* - left, if position `*-left`
|
|
15
|
+
* - right, if position `*-right`
|
|
16
|
+
*
|
|
17
|
+
* @default 0
|
|
18
|
+
*/
|
|
19
|
+
horizontalGap?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Vertical gap in pixel applied to anchor container.
|
|
22
|
+
*
|
|
23
|
+
* Applied:
|
|
24
|
+
* - top, if position `top-*`
|
|
25
|
+
* - bottom, if position `bottom-*`
|
|
26
|
+
*
|
|
27
|
+
* @default 0 (If position `bottom-*`, default verticalGap == `30`)
|
|
28
|
+
*/
|
|
29
|
+
verticalGap?: number;
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
export declare function MapAnchor(props: MapAnchorProps): JSX.Element;
|
|
33
|
+
export declare function computeAttributionGap(verticalGap?: number): {
|
|
34
|
+
gap: number;
|
|
35
|
+
space: number;
|
|
36
|
+
};
|
package/ui/MapAnchor.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Box } from '@open-pioneer/chakra-integration';
|
|
3
|
+
import { useCommonComponentProps } from '@open-pioneer/react-utils';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { computeMapAnchorStyles } from './computeMapAnchorStyles.js';
|
|
6
|
+
import { useMapContainerContext } from './MapContainerContext.js';
|
|
7
|
+
|
|
8
|
+
const defaultPosition = "top-right";
|
|
9
|
+
function MapAnchor(props) {
|
|
10
|
+
const { position = defaultPosition, children, horizontalGap, verticalGap } = props;
|
|
11
|
+
const { containerProps } = useCommonComponentProps("map-anchor", props);
|
|
12
|
+
const { mapAnchorsHost } = useMapContainerContext();
|
|
13
|
+
return createPortal(
|
|
14
|
+
/* @__PURE__ */ jsx(Box, { ...containerProps, ...computeMapAnchorStyles(position, horizontalGap, verticalGap), children }),
|
|
15
|
+
mapAnchorsHost
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function computeAttributionGap(verticalGap) {
|
|
19
|
+
const height = 20;
|
|
20
|
+
const space = 10;
|
|
21
|
+
return {
|
|
22
|
+
gap: verticalGap === void 0 ? height + space : 0,
|
|
23
|
+
space
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { MapAnchor, computeAttributionGap };
|
|
28
|
+
//# sourceMappingURL=MapAnchor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapAnchor.js","sources":["MapAnchor.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box } from \"@open-pioneer/chakra-integration\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { computeMapAnchorStyles } from \"./computeMapAnchorStyles\";\nimport { useMapContainerContext } from \"./MapContainerContext\";\n\nexport type MapAnchorPosition = \"top-left\" | \"top-right\" | \"bottom-left\" | \"bottom-right\";\n\nconst defaultPosition: MapAnchorPosition = \"top-right\";\n\nexport interface MapAnchorProps extends CommonComponentProps {\n /**\n * The position of the anchor container above the map.\n * @default \"top-right\"\n */\n position?: MapAnchorPosition;\n\n /**\n * Horizontal gap in pixel applied to anchor container.\n *\n * Applied:\n * - left, if position `*-left`\n * - right, if position `*-right`\n *\n * @default 0\n */\n horizontalGap?: number;\n\n /**\n * Vertical gap in pixel applied to anchor container.\n *\n * Applied:\n * - top, if position `top-*`\n * - bottom, if position `bottom-*`\n *\n * @default 0 (If position `bottom-*`, default verticalGap == `30`)\n */\n verticalGap?: number;\n\n children?: ReactNode;\n}\n\nexport function MapAnchor(props: MapAnchorProps): JSX.Element {\n const { position = defaultPosition, children, horizontalGap, verticalGap } = props;\n const { containerProps } = useCommonComponentProps(\"map-anchor\", props);\n const { mapAnchorsHost } = useMapContainerContext();\n\n return createPortal(\n <Box {...containerProps} {...computeMapAnchorStyles(position, horizontalGap, verticalGap)}>\n {children}\n </Box>,\n mapAnchorsHost\n );\n}\n\nexport function computeAttributionGap(verticalGap?: number): {\n gap: number;\n space: number;\n} {\n /**\n * height of the ol attribution component\n * improvement: Get height directly from `Attribution` HTMLDivElement\n */\n const height = 20;\n\n /**\n * additional space between attribution and map anchor container\n */\n const space = 10;\n\n return {\n gap: verticalGap === undefined ? height + space : 0,\n space\n };\n}\n"],"names":[],"mappings":";;;;;;;AAWA,MAAM,eAAqC,GAAA,WAAA,CAAA;AAkCpC,SAAS,UAAU,KAAoC,EAAA;AAC1D,EAAA,MAAM,EAAE,QAAW,GAAA,eAAA,EAAiB,QAAU,EAAA,aAAA,EAAe,aAAgB,GAAA,KAAA,CAAA;AAC7E,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,cAAc,KAAK,CAAA,CAAA;AACtE,EAAM,MAAA,EAAE,cAAe,EAAA,GAAI,sBAAuB,EAAA,CAAA;AAElD,EAAO,OAAA,YAAA;AAAA,oBACH,GAAA,CAAC,GAAK,EAAA,EAAA,GAAG,cAAiB,EAAA,GAAG,uBAAuB,QAAU,EAAA,aAAA,EAAe,WAAW,CAAA,EACnF,QACL,EAAA,CAAA;AAAA,IACA,cAAA;AAAA,GACJ,CAAA;AACJ,CAAA;AAEO,SAAS,sBAAsB,WAGpC,EAAA;AAKE,EAAA,MAAM,MAAS,GAAA,EAAA,CAAA;AAKf,EAAA,MAAM,KAAQ,GAAA,EAAA,CAAA;AAEd,EAAO,OAAA;AAAA,IACH,GAAK,EAAA,WAAA,KAAgB,KAAY,CAAA,GAAA,MAAA,GAAS,KAAQ,GAAA,CAAA;AAAA,IAClD,KAAA;AAAA,GACJ,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CommonComponentProps } from "@open-pioneer/react-utils";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { MapPadding } from "../api";
|
|
4
|
+
import { MapModelProps } from "./useMapModel";
|
|
5
|
+
export interface MapContainerProps extends CommonComponentProps, MapModelProps {
|
|
6
|
+
/**
|
|
7
|
+
* Sets the map's padding directly.
|
|
8
|
+
* Do not use the view's padding property directly on the OL map.
|
|
9
|
+
*
|
|
10
|
+
* See: https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding)
|
|
11
|
+
*/
|
|
12
|
+
viewPadding?: MapPadding | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Behavior performed by the map when the view padding changes.
|
|
15
|
+
*
|
|
16
|
+
* - `none`: Do nothing.
|
|
17
|
+
* - `preserve-center`: Ensures that the center point remains the same by animating the view.
|
|
18
|
+
* - `preserve-extent`: Ensures that the extent remains the same by zooming.
|
|
19
|
+
*
|
|
20
|
+
* @default "preserve-center"
|
|
21
|
+
*/
|
|
22
|
+
viewPaddingChangeBehavior?: "none" | "preserve-center" | "preserve-extent";
|
|
23
|
+
children?: ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Optional role property.
|
|
26
|
+
*
|
|
27
|
+
* This property is directly applied to the map's container div element.
|
|
28
|
+
*/
|
|
29
|
+
role?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Optional aria-labelledby property.
|
|
32
|
+
* Do not use together with aria-label.
|
|
33
|
+
*
|
|
34
|
+
* This property is directly applied to the map's container div element.
|
|
35
|
+
*/
|
|
36
|
+
"aria-labelledby"?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional aria-label property.
|
|
39
|
+
* Do not use together with aria-label.
|
|
40
|
+
*
|
|
41
|
+
* This property is directly applied to the map's container div element.
|
|
42
|
+
*/
|
|
43
|
+
"aria-label"?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Displays the map with the given id.
|
|
47
|
+
*
|
|
48
|
+
* There can only be at most one MapContainer for every map.
|
|
49
|
+
*/
|
|
50
|
+
export declare function MapContainer(props: MapContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { chakra } from '@open-pioneer/chakra-integration';
|
|
3
|
+
import { createLogger } from '@open-pioneer/core';
|
|
4
|
+
import { useCommonComponentProps } from '@open-pioneer/react-utils';
|
|
5
|
+
import { useRef, useState, useEffect, useMemo } from 'react';
|
|
6
|
+
import { MapContainerContextProvider } from './MapContainerContext.js';
|
|
7
|
+
import { useMapModel } from './useMapModel.js';
|
|
8
|
+
import { PADDING_TOP, PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT } from './CssProps.js';
|
|
9
|
+
|
|
10
|
+
const LOG = createLogger("map:MapContainer");
|
|
11
|
+
function MapContainer(props) {
|
|
12
|
+
const {
|
|
13
|
+
viewPadding,
|
|
14
|
+
viewPaddingChangeBehavior,
|
|
15
|
+
children,
|
|
16
|
+
role,
|
|
17
|
+
"aria-label": ariaLabel,
|
|
18
|
+
"aria-labelledby": ariaLabelledBy
|
|
19
|
+
} = props;
|
|
20
|
+
const { containerProps } = useCommonComponentProps("map-container", props);
|
|
21
|
+
const mapContainer = useRef(null);
|
|
22
|
+
const mapAnchorsHost = useRef(null);
|
|
23
|
+
const modelState = useMapModel(props);
|
|
24
|
+
const map = modelState.map;
|
|
25
|
+
const [ready, setReady] = useState(false);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (modelState.kind === "loading") {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (modelState.kind === "rejected") {
|
|
31
|
+
LOG.error(`Cannot display the map. Caused by `, modelState.error);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!map) {
|
|
35
|
+
LOG.error(`No configuration available for the configured map.`);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (mapContainer.current) {
|
|
39
|
+
const resource = registerMapTarget(map, mapContainer.current);
|
|
40
|
+
return () => resource?.destroy();
|
|
41
|
+
}
|
|
42
|
+
}, [modelState, map]);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
setReady(true);
|
|
45
|
+
}, []);
|
|
46
|
+
const styleProps = useMemo(() => {
|
|
47
|
+
return {
|
|
48
|
+
height: "100%",
|
|
49
|
+
position: "relative",
|
|
50
|
+
// set css variables according to view padding
|
|
51
|
+
[PADDING_TOP.definition]: viewPadding?.top != void 0 ? viewPadding.top + "px" : "0px",
|
|
52
|
+
[PADDING_BOTTOM.definition]: viewPadding?.bottom != void 0 ? viewPadding.bottom + "px" : "0px",
|
|
53
|
+
[PADDING_LEFT.definition]: viewPadding?.left != void 0 ? viewPadding.left + "px" : "0px",
|
|
54
|
+
[PADDING_RIGHT.definition]: viewPadding?.right != void 0 ? viewPadding.right + "px" : "0px"
|
|
55
|
+
};
|
|
56
|
+
}, [viewPadding]);
|
|
57
|
+
return /* @__PURE__ */ jsxs(
|
|
58
|
+
chakra.div,
|
|
59
|
+
{
|
|
60
|
+
...containerProps,
|
|
61
|
+
role,
|
|
62
|
+
"aria-label": ariaLabel,
|
|
63
|
+
"aria-labelledby": ariaLabelledBy,
|
|
64
|
+
ref: mapContainer,
|
|
65
|
+
style: styleProps,
|
|
66
|
+
tabIndex: 0,
|
|
67
|
+
children: [
|
|
68
|
+
ready && map && /* @__PURE__ */ jsx(
|
|
69
|
+
MapContainerReady,
|
|
70
|
+
{
|
|
71
|
+
olMap: map.olMap,
|
|
72
|
+
mapAnchorsHost: mapAnchorsHost.current,
|
|
73
|
+
viewPadding,
|
|
74
|
+
viewPaddingChangeBehavior,
|
|
75
|
+
children
|
|
76
|
+
}
|
|
77
|
+
),
|
|
78
|
+
/* @__PURE__ */ jsx(
|
|
79
|
+
chakra.div,
|
|
80
|
+
{
|
|
81
|
+
ref: mapAnchorsHost,
|
|
82
|
+
className: "map-anchors"
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
function MapContainerReady(props) {
|
|
90
|
+
const {
|
|
91
|
+
olMap,
|
|
92
|
+
mapAnchorsHost,
|
|
93
|
+
viewPadding: viewPaddingProp,
|
|
94
|
+
viewPaddingChangeBehavior = "preserve-center",
|
|
95
|
+
children
|
|
96
|
+
} = props;
|
|
97
|
+
const viewPadding = useMemo(() => {
|
|
98
|
+
return {
|
|
99
|
+
left: viewPaddingProp?.left ?? 0,
|
|
100
|
+
right: viewPaddingProp?.right ?? 0,
|
|
101
|
+
top: viewPaddingProp?.top ?? 0,
|
|
102
|
+
bottom: viewPaddingProp?.bottom ?? 0
|
|
103
|
+
};
|
|
104
|
+
}, [viewPaddingProp]);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
const mapView = olMap?.getView();
|
|
107
|
+
if (!olMap || !mapView) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const oldCenter = mapView.getCenter();
|
|
111
|
+
const oldPadding = fromOlPadding(mapView.padding);
|
|
112
|
+
const oldExtent = extentIncludingPadding(olMap, oldPadding);
|
|
113
|
+
mapView.padding = toOlPadding(viewPadding);
|
|
114
|
+
switch (viewPaddingChangeBehavior) {
|
|
115
|
+
case "preserve-center":
|
|
116
|
+
mapView.animate({ center: oldCenter, duration: 300 });
|
|
117
|
+
break;
|
|
118
|
+
case "preserve-extent": {
|
|
119
|
+
if (oldExtent) {
|
|
120
|
+
mapView.animate({
|
|
121
|
+
center: oldCenter,
|
|
122
|
+
resolution: mapView.getResolutionForExtent(oldExtent),
|
|
123
|
+
duration: 300
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, [viewPadding, olMap, viewPaddingChangeBehavior]);
|
|
130
|
+
const mapContext = useMemo(() => {
|
|
131
|
+
return {
|
|
132
|
+
mapAnchorsHost
|
|
133
|
+
};
|
|
134
|
+
}, [mapAnchorsHost]);
|
|
135
|
+
return /* @__PURE__ */ jsx(MapContainerContextProvider, { value: mapContext, children });
|
|
136
|
+
}
|
|
137
|
+
function registerMapTarget(mapModel, target) {
|
|
138
|
+
const mapId = mapModel.id;
|
|
139
|
+
const olMap = mapModel.olMap;
|
|
140
|
+
if (olMap.getTarget()) {
|
|
141
|
+
LOG.error(
|
|
142
|
+
`Failed to display the map: the map already has a target. There may be more than one <MapContainer />.`
|
|
143
|
+
);
|
|
144
|
+
return void 0;
|
|
145
|
+
}
|
|
146
|
+
LOG.isDebug() && LOG.debug(`Setting target of map '${mapId}':`, target);
|
|
147
|
+
olMap.setTarget(target);
|
|
148
|
+
let unregistered = false;
|
|
149
|
+
return {
|
|
150
|
+
destroy() {
|
|
151
|
+
if (!unregistered) {
|
|
152
|
+
LOG.isDebug() && LOG.debug(`Removing target of map '${mapId}':`, target);
|
|
153
|
+
olMap.setTarget(void 0);
|
|
154
|
+
unregistered = true;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function extentIncludingPadding(map, padding) {
|
|
160
|
+
const size = map.getSize();
|
|
161
|
+
if (!size || size.length < 2) {
|
|
162
|
+
return void 0;
|
|
163
|
+
}
|
|
164
|
+
const [width, height] = size;
|
|
165
|
+
const bottomLeft = map.getCoordinateFromPixel([padding.left, padding.bottom]);
|
|
166
|
+
const topRight = map.getCoordinateFromPixel([
|
|
167
|
+
Math.max(0, width - padding.right),
|
|
168
|
+
Math.max(0, height - padding.top)
|
|
169
|
+
]);
|
|
170
|
+
if (!bottomLeft || !topRight) {
|
|
171
|
+
return void 0;
|
|
172
|
+
}
|
|
173
|
+
const [xmin, ymin] = bottomLeft;
|
|
174
|
+
const [xmax, ymax] = topRight;
|
|
175
|
+
return [xmin, ymin, xmax, ymax];
|
|
176
|
+
}
|
|
177
|
+
function fromOlPadding(padding) {
|
|
178
|
+
return {
|
|
179
|
+
top: padding?.[0] ?? 0,
|
|
180
|
+
right: padding?.[1] ?? 0,
|
|
181
|
+
bottom: padding?.[2] ?? 0,
|
|
182
|
+
left: padding?.[3] ?? 0
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function toOlPadding(padding) {
|
|
186
|
+
const { top, right, bottom, left } = padding;
|
|
187
|
+
return [top, right, bottom, left];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export { MapContainer };
|
|
191
|
+
//# sourceMappingURL=MapContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapContainer.js","sources":["MapContainer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 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, CSSProperties } from \"react\";\nimport { MapModel, MapPadding } from \"../api\";\nimport { MapContainerContextProvider, MapContainerContextType } from \"./MapContainerContext\";\nimport { MapModelProps, useMapModel } from \"./useMapModel\";\nimport { PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT, PADDING_TOP } from \"./CssProps\";\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 [PADDING_TOP.definition]:\n viewPadding?.top != undefined ? viewPadding.top + \"px\" : \"0px\",\n [PADDING_BOTTOM.definition]:\n viewPadding?.bottom != undefined ? viewPadding.bottom + \"px\" : \"0px\",\n [PADDING_LEFT.definition]:\n viewPadding?.left != undefined ? viewPadding.left + \"px\" : \"0px\",\n [PADDING_RIGHT.definition]:\n viewPadding?.right != undefined ? viewPadding.right + \"px\" : \"0px\"\n } as CSSProperties;\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 style={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\n ref={mapAnchorsHost}\n className=\"map-anchors\"\n /* note: zero sized, children have a size and are positioned relative to the map-container */\n >\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): JSX.Element {\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 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 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":";;;;;;;;;AAYA,MAAM,GAAA,GAAM,aAAa,kBAAkB,CAAA,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,cAAA;AAAA,GACnB,GAAA,KAAA,CAAA;AACJ,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,iBAAiB,KAAK,CAAA,CAAA;AACzE,EAAM,MAAA,YAAA,GAAe,OAAuB,IAAI,CAAA,CAAA;AAChD,EAAM,MAAA,cAAA,GAAiB,OAAuB,IAAI,CAAA,CAAA;AAClD,EAAM,MAAA,UAAA,GAAa,YAAY,KAAK,CAAA,CAAA;AACpC,EAAA,MAAM,MAAM,UAAW,CAAA,GAAA,CAAA;AAEvB,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,KAAK,CAAA,CAAA;AAExC,EAAA,SAAA,CAAU,MAAM;AACZ,IAAI,IAAA,UAAA,CAAW,SAAS,SAAW,EAAA;AAC/B,MAAA,OAAA;AAAA,KACJ;AAEA,IAAI,IAAA,UAAA,CAAW,SAAS,UAAY,EAAA;AAChC,MAAI,GAAA,CAAA,KAAA,CAAM,CAAsC,kCAAA,CAAA,EAAA,UAAA,CAAW,KAAK,CAAA,CAAA;AAChE,MAAA,OAAA;AAAA,KACJ;AAEA,IAAA,IAAI,CAAC,GAAK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AAA;AAAA,IACjC,IAAK,CAAA,GAAA,CAAI,CAAG,EAAA,MAAA,GAAS,QAAQ,GAAG,CAAA;AAAA,GACnC,CAAA,CAAA;AACD,EAAI,IAAA,CAAC,UAAc,IAAA,CAAC,QAAU,EAAA;AAC1B,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACX;AAEA,EAAM,MAAA,CAAC,IAAM,EAAA,IAAI,CAAI,GAAA,UAAA,CAAA;AACrB,EAAM,MAAA,CAAC,IAAM,EAAA,IAAI,CAAI,GAAA,QAAA,CAAA;AACrB,EAAA,OAAO,CAAC,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,IAAI,CAAA,CAAA;AAClC,CAAA;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,CAAA;AAAA,GAC1B,CAAA;AACJ,CAAA;AAEA,SAAS,YAAY,OAAyC,EAAA;AAE1D,EAAA,MAAM,EAAE,GAAA,EAAK,KAAO,EAAA,MAAA,EAAQ,MAAS,GAAA,OAAA,CAAA;AACrC,EAAA,OAAO,CAAC,GAAA,EAAK,KAAO,EAAA,MAAA,EAAQ,IAAI,CAAA,CAAA;AACpC;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Provider } from "react";
|
|
2
|
+
/** Values provided to children of {@link MapContainer}. */
|
|
3
|
+
export interface MapContainerContextType {
|
|
4
|
+
mapAnchorsHost: HTMLElement;
|
|
5
|
+
}
|
|
6
|
+
export declare const MapContainerContextProvider: Provider<MapContainerContextType>;
|
|
7
|
+
export declare function useMapContainerContext(): MapContainerContextType;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const MapContainerContext = createContext(void 0);
|
|
4
|
+
MapContainerContext.displayName = "MapContainerContext";
|
|
5
|
+
const MapContainerContextProvider = MapContainerContext.Provider;
|
|
6
|
+
function useMapContainerContext() {
|
|
7
|
+
const contextValue = useContext(MapContainerContext);
|
|
8
|
+
if (!contextValue) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
`Map container context is not available. The component must be a child of the <MapContainer /> component.`
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
return contextValue;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { MapContainerContextProvider, useMapContainerContext };
|
|
17
|
+
//# sourceMappingURL=MapContainerContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapContainerContext.js","sources":["MapContainerContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Provider, createContext, useContext } from \"react\";\n\n/** Values provided to children of {@link MapContainer}. */\nexport interface MapContainerContextType {\n mapAnchorsHost: HTMLElement;\n}\n\nconst MapContainerContext = createContext<MapContainerContextType | undefined>(undefined);\nMapContainerContext.displayName = \"MapContainerContext\";\n\nexport const MapContainerContextProvider: Provider<MapContainerContextType> =\n MapContainerContext.Provider as Provider<MapContainerContextType>;\n\nexport function useMapContainerContext(): MapContainerContextType {\n const contextValue = useContext(MapContainerContext);\n if (!contextValue) {\n throw new Error(\n `Map container context is not available. The component must be a child of the <MapContainer /> component.`\n );\n }\n return contextValue;\n}\n"],"names":[],"mappings":";;AASA,MAAM,mBAAA,GAAsB,cAAmD,KAAS,CAAA,CAAA,CAAA;AACxF,mBAAA,CAAoB,WAAc,GAAA,qBAAA,CAAA;AAE3B,MAAM,8BACT,mBAAoB,CAAA,SAAA;AAEjB,SAAS,sBAAkD,GAAA;AAC9D,EAAM,MAAA,YAAA,GAAe,WAAW,mBAAmB,CAAA,CAAA;AACnD,EAAA,IAAI,CAAC,YAAc,EAAA;AACf,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,wGAAA,CAAA;AAAA,KACJ,CAAA;AAAA,GACJ;AACA,EAAO,OAAA,YAAA,CAAA;AACX;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PADDING_RIGHT, PADDING_BOTTOM, PADDING_LEFT, PADDING_TOP } from './CssProps.js';
|
|
2
|
+
import { computeAttributionGap } from './MapAnchor.js';
|
|
3
|
+
|
|
4
|
+
function computeMapAnchorStyles(position, horizontalGap, verticalGap) {
|
|
5
|
+
const styleProps = {
|
|
6
|
+
position: "absolute",
|
|
7
|
+
zIndex: 1,
|
|
8
|
+
// above map
|
|
9
|
+
transitionProperty: "left, right, top, bottom",
|
|
10
|
+
transitionDuration: "200ms",
|
|
11
|
+
transitionTimingFunction: "ease-out",
|
|
12
|
+
overflow: "hidden"
|
|
13
|
+
};
|
|
14
|
+
const defaultHorizontalGap = 0;
|
|
15
|
+
const horizontal = horizontalGap ?? defaultHorizontalGap;
|
|
16
|
+
const defaultVerticalGap = 0;
|
|
17
|
+
const vertical = verticalGap ?? defaultVerticalGap;
|
|
18
|
+
const attribution = computeAttributionGap(verticalGap);
|
|
19
|
+
const gap = (paddingProp, pixels) => `(${paddingProp} + ${pixels}px)`;
|
|
20
|
+
const posExprs = {};
|
|
21
|
+
switch (position) {
|
|
22
|
+
case "top-left":
|
|
23
|
+
posExprs.left = gap(PADDING_LEFT.ref, horizontal);
|
|
24
|
+
posExprs.top = gap(PADDING_TOP.ref, vertical);
|
|
25
|
+
break;
|
|
26
|
+
case "top-right":
|
|
27
|
+
posExprs.right = gap(PADDING_RIGHT.ref, horizontal);
|
|
28
|
+
posExprs.top = gap(PADDING_TOP.ref, vertical);
|
|
29
|
+
break;
|
|
30
|
+
case "bottom-left":
|
|
31
|
+
posExprs.left = gap(PADDING_LEFT.ref, horizontal);
|
|
32
|
+
posExprs.bottom = gap(PADDING_BOTTOM.ref, vertical + attribution.gap);
|
|
33
|
+
break;
|
|
34
|
+
case "bottom-right":
|
|
35
|
+
posExprs.right = gap(PADDING_RIGHT.ref, horizontal);
|
|
36
|
+
posExprs.bottom = gap(PADDING_BOTTOM.ref, vertical + attribution.gap);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
for (const [key, value] of Object.entries(posExprs)) {
|
|
40
|
+
styleProps[key] = `calc(${value})`;
|
|
41
|
+
}
|
|
42
|
+
styleProps.maxH = `calc((100%) - ${defaultValue(posExprs.top, "0px")} - ${defaultValue(posExprs.bottom, attribution.gap + "px")} - ${vertical}px - ${attribution.space}px)`;
|
|
43
|
+
styleProps.maxW = `calc((100%) - ${defaultValue(posExprs.left, "0px")} - ${defaultValue(posExprs.right, "0px")} - ${horizontal}px)`;
|
|
44
|
+
return styleProps;
|
|
45
|
+
}
|
|
46
|
+
function defaultValue(value, defaultValue2) {
|
|
47
|
+
return value ?? defaultValue2;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { computeMapAnchorStyles };
|
|
51
|
+
//# sourceMappingURL=computeMapAnchorStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeMapAnchorStyles.js","sources":["computeMapAnchorStyles.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { StyleProps } from \"@open-pioneer/chakra-integration\";\nimport { PADDING_BOTTOM, PADDING_LEFT, PADDING_RIGHT, PADDING_TOP } from \"./CssProps\";\nimport { computeAttributionGap, MapAnchorPosition } from \"./MapAnchor\";\n\nexport function computeMapAnchorStyles(\n position: MapAnchorPosition,\n horizontalGap?: number | undefined,\n verticalGap?: number | undefined\n): StyleProps {\n const styleProps: StyleProps = {\n position: \"absolute\",\n zIndex: 1, // above map\n transitionProperty: \"left, right, top, bottom\",\n transitionDuration: \"200ms\",\n transitionTimingFunction: \"ease-out\",\n overflow: \"hidden\"\n };\n\n const defaultHorizontalGap = 0;\n const horizontal = horizontalGap ?? defaultHorizontalGap;\n\n const defaultVerticalGap = 0;\n const vertical = verticalGap ?? defaultVerticalGap;\n\n const attribution = computeAttributionGap(verticalGap);\n const gap = (paddingProp: string, pixels: number) => `(${paddingProp} + ${pixels}px)`;\n\n interface PosExprs {\n left?: string;\n right?: string;\n top?: string;\n bottom?: string;\n }\n\n // CSS Expressions for inside calc(...)\n const posExprs: PosExprs = {};\n switch (position) {\n case \"top-left\":\n posExprs.left = gap(PADDING_LEFT.ref, horizontal);\n posExprs.top = gap(PADDING_TOP.ref, vertical);\n break;\n case \"top-right\":\n posExprs.right = gap(PADDING_RIGHT.ref, horizontal);\n posExprs.top = gap(PADDING_TOP.ref, vertical);\n break;\n case \"bottom-left\":\n posExprs.left = gap(PADDING_LEFT.ref, horizontal);\n posExprs.bottom = gap(PADDING_BOTTOM.ref, vertical + attribution.gap);\n break;\n case \"bottom-right\":\n posExprs.right = gap(PADDING_RIGHT.ref, horizontal);\n posExprs.bottom = gap(PADDING_BOTTOM.ref, vertical + attribution.gap);\n break;\n }\n\n for (const [key, value] of Object.entries(posExprs)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (styleProps as any)[key] = `calc(${value})`;\n }\n\n /**\n * Apply max-height and max-width to MapAnchor to avoid content overflow\n */\n styleProps.maxH = `calc((100%) - ${defaultValue(posExprs.top, \"0px\")} - ${defaultValue(posExprs.bottom, attribution.gap + \"px\")} - ${vertical}px - ${attribution.space}px)`;\n styleProps.maxW = `calc((100%) - ${defaultValue(posExprs.left, \"0px\")} - ${defaultValue(posExprs.right, \"0px\")} - ${horizontal}px)`;\n return styleProps;\n}\n\nfunction defaultValue(value: string | undefined, defaultValue: string): string {\n return value ?? defaultValue;\n}\n"],"names":["defaultValue"],"mappings":";;;AAMgB,SAAA,sBAAA,CACZ,QACA,EAAA,aAAA,EACA,WACU,EA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/Map";
|
|
2
|
+
import OlView from "ol/View";
|
|
3
|
+
import { Projection } from "ol/proj";
|
|
4
|
+
import { Coordinate } from "ol/coordinate";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the current view of the given map.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated Use `mapModel.olView` instead.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useView(map: OlMap | undefined): OlView | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Returns the current projection of the map.
|
|
13
|
+
*
|
|
14
|
+
* @deprecated Use `mapModel.projection` instead.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useProjection(map: OlMap | undefined): Projection | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the current resolution of the map.
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Use `mapModel.resolution` instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useResolution(map: OlMap | undefined): number | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the current center coordinates of the map.
|
|
25
|
+
*
|
|
26
|
+
* @deprecated Use `mapModel.center` instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useCenter(map: OlMap | undefined): Coordinate | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the current scale of the map.
|
|
31
|
+
*
|
|
32
|
+
* @deprecated Use `mapModel.scale` instead.
|
|
33
|
+
*/
|
|
34
|
+
export declare function useScale(map: OlMap | undefined): number | undefined;
|