@open-pioneer/map-navigation 1.4.0-dev.20260727093741 → 1.5.0-dev.20260910103330
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 +40 -28
- package/History.js.map +1 -1
- package/InitialExtent.js.map +1 -1
- package/ViewHistoryModel.d.ts +1 -1
- package/ViewHistoryModel.js +1 -1
- package/ViewHistoryModel.js.map +1 -1
- package/Zoom.js.map +1 -1
- package/package.json +14 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
# @open-pioneer/map-navigation
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.5.0-dev.20260910103330
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f790fda: Update to Chakra 3.37.0
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 09ec7c7: Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 1.4.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
6
16
|
|
|
7
17
|
- c30396d: Update Chakra to 3.36.1
|
|
18
|
+
- d862003: Update to trails core-packages 4.7.0
|
|
8
19
|
|
|
9
20
|
### Patch Changes
|
|
10
21
|
|
|
11
22
|
- 078bef5: Use private JavaScript properties (#) instead of TypeScript keyword.
|
|
23
|
+
- c16a401: Migrated from eslint to oxlint and from prettier to oxfmt.
|
|
12
24
|
|
|
13
25
|
## 1.3.0
|
|
14
26
|
|
|
@@ -67,16 +79,16 @@
|
|
|
67
79
|
|
|
68
80
|
- 9376a74: Ensure that icons and other decorative elements are hidden from the screen reader using the `aria-hidden="true"` attribute.
|
|
69
81
|
|
|
70
|
-
|
|
82
|
+
The easiest way to do that is to wrap icons into chakra's `<Icon />` component, for example:
|
|
71
83
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
```tsx
|
|
85
|
+
import { Icon } from "@chakra-ui/react";
|
|
86
|
+
import { FiX } from "react-icons/fi";
|
|
75
87
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
<Icon>
|
|
89
|
+
<FiX />
|
|
90
|
+
</Icon>;
|
|
91
|
+
```
|
|
80
92
|
|
|
81
93
|
## 0.10.0
|
|
82
94
|
|
|
@@ -85,17 +97,17 @@
|
|
|
85
97
|
- 193068a: Deprecate the `mapId` property on React components.
|
|
86
98
|
Use the `MapModel` directly instead to pass a reference to the map.
|
|
87
99
|
|
|
88
|
-
|
|
100
|
+
Example:
|
|
89
101
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
102
|
+
```tsx
|
|
103
|
+
// Default map for entire component tree
|
|
104
|
+
<DefaultMapProvider map={mapModel}>
|
|
105
|
+
<Toc />
|
|
106
|
+
</DefaultMapProvider>
|
|
95
107
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
108
|
+
// Map for specific component
|
|
109
|
+
<Toc map={mapModel} />
|
|
110
|
+
```
|
|
99
111
|
|
|
100
112
|
### Patch Changes
|
|
101
113
|
|
|
@@ -110,18 +122,18 @@
|
|
|
110
122
|
- cb94c75: update dependencies
|
|
111
123
|
- 8dc793e: Add `ButtonProps` to `ToolButton` in `@open-pioneer/geolocation` and `@open-pioneer/map-navigation`
|
|
112
124
|
|
|
113
|
-
|
|
125
|
+
Example:
|
|
114
126
|
|
|
115
|
-
|
|
127
|
+
`<Geolocation buttonProps={{ variant: "outline" }} />`
|
|
116
128
|
|
|
117
129
|
## 0.8.0
|
|
118
130
|
|
|
119
131
|
### Minor Changes
|
|
120
132
|
|
|
121
133
|
- 2fa8020: Update trails core package dependencies.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
134
|
+
- Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
|
|
135
|
+
- Removes any obsolete references to `@chakra-ui/system`.
|
|
136
|
+
This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
|
|
125
137
|
|
|
126
138
|
### Patch Changes
|
|
127
139
|
|
|
@@ -134,10 +146,10 @@
|
|
|
134
146
|
|
|
135
147
|
- 440b165: Create new tool buttons that allow the user to navigate the history of map views (e.g. jump back to previous map extent):
|
|
136
148
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
149
|
+
```jsx
|
|
150
|
+
<HistoryBackward /* ... */ />
|
|
151
|
+
<HistoryForward /* ... */ />
|
|
152
|
+
```
|
|
141
153
|
|
|
142
154
|
- 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
|
|
143
155
|
|
|
@@ -149,7 +161,7 @@
|
|
|
149
161
|
- 583f1d6: The `mapId` or `map` properties are now optional on individual components.
|
|
150
162
|
You can use the `DefaultMapProvider` to configure an implicit default value.
|
|
151
163
|
|
|
152
|
-
|
|
164
|
+
Note that configuring _neither_ a default _nor_ an explicit `map` or `mapId` will trigger a runtime error.
|
|
153
165
|
|
|
154
166
|
- 583f1d6: All UI components in this project now accept the `mapId` (a `string`) _or_ the `map` (a `MapModel`) directly.
|
|
155
167
|
- a8b3449: Switch to a new versioning strategy.
|
package/History.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"History.js","sources":["History.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ButtonProps } from \"@chakra-ui/react\";\nimport { MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { ToolButton } from \"@open-pioneer/map-ui-components\";\nimport {
|
|
1
|
+
{"version":3,"file":"History.js","sources":["History.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ButtonProps } from \"@chakra-ui/react\";\nimport { MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { ToolButton } from \"@open-pioneer/map-ui-components\";\nimport {\n CommonComponentProps,\n useCommonComponentProps,\n classNames\n} from \"@open-pioneer/react-utils\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC, RefAttributes } from \"react\";\nimport { LuCornerUpLeft, LuCornerUpRight } from \"react-icons/lu\";\nimport { useHistoryViewModel } from \"./ViewHistoryModel\";\n\nexport type HistoryForwardProps = Omit<HistoryProps, \"viewDirection\">;\n\n/**\n * Provides a button by which the user can navigate to the next map view.\n *\n * This component composes {@link History}.\n */\nexport const HistoryForward: FC<HistoryForwardProps> = function HistoryForward(\n props: HistoryForwardProps\n) {\n return <History viewDirection=\"forward\" {...props} />;\n};\n\nexport type HistoryBackwardProps = HistoryForwardProps;\n\n/**\n * Provides a button by which the user can navigate to the previous map view.\n *\n * This component composes {@link History}.\n */\nexport const HistoryBackward: FC<HistoryBackwardProps> = function HistoryBackward(\n props: HistoryBackwardProps\n) {\n return <History viewDirection=\"backward\" {...props} />;\n};\n\nexport interface HistoryProps\n extends CommonComponentProps, RefAttributes<HTMLButtonElement>, MapModelProps {\n /**\n * Additional properties for the `Button` element.\n *\n * Note that the ToolButton also defines some of these props.\n */\n buttonProps?: Partial<ButtonProps>;\n\n /**\n * The view direction.\n *\n * The button will either view forward or view backward depending on this value.\n */\n viewDirection: \"forward\" | \"backward\";\n}\n\n/**\n * Provides a button by which the user can navigate forward or backward in the view history of the map.\n */\nexport const History: FC<HistoryProps> = function History(props: HistoryProps) {\n const intl = useIntl();\n const { buttonProps, viewDirection, ref } = props;\n const map = useMapModelValue(props);\n const viewModel = useHistoryViewModel(map);\n const { defaultClassName, buttonLabel, buttonIcon } = getDirectionProps(intl, viewDirection);\n const { containerProps } = useCommonComponentProps(classNames(\"view\", defaultClassName), props);\n\n const canNavigate = useReactiveSnapshot(() => {\n if (!viewModel) {\n return false;\n }\n\n if (viewDirection === \"forward\") {\n return viewModel.canForward;\n } else {\n return viewModel.canBackward;\n }\n }, [viewModel, viewDirection]);\n const navigate = () => {\n if (!viewModel) {\n return;\n }\n\n if (viewDirection === \"forward\") {\n viewModel.forward();\n } else {\n viewModel.backward();\n }\n };\n\n return (\n viewModel && (\n <ToolButton\n ref={ref}\n {...containerProps}\n buttonProps={buttonProps}\n label={buttonLabel}\n icon={buttonIcon}\n onClick={navigate}\n disabled={!canNavigate}\n />\n )\n );\n};\n\nfunction getDirectionProps(intl: PackageIntl, viewDirection: \"forward\" | \"backward\") {\n switch (viewDirection) {\n case \"forward\":\n return {\n defaultClassName: \"view-forward\",\n buttonLabel: intl.formatMessage({ id: \"view-forward.title\" }),\n buttonIcon: <LuCornerUpRight />\n };\n case \"backward\":\n return {\n defaultClassName: \"view-backward\",\n buttonLabel: intl.formatMessage({ id: \"view-backward.title\" }),\n buttonIcon: <LuCornerUpLeft />\n };\n }\n}\n"],"names":["HistoryForward","HistoryBackward","History"],"mappings":";;;;;;;;;AAyBO,MAAM,cAAA,GAA0C,SAASA,eAAAA,CAC5D,KAAA,EACF;AACE,EAAA,uBAAO,GAAA,CAAC,OAAA,EAAA,EAAQ,aAAA,EAAc,SAAA,EAAW,GAAG,KAAA,EAAO,CAAA;AACvD;AASO,MAAM,eAAA,GAA4C,SAASC,gBAAAA,CAC9D,KAAA,EACF;AACE,EAAA,uBAAO,GAAA,CAAC,OAAA,EAAA,EAAQ,aAAA,EAAc,UAAA,EAAY,GAAG,KAAA,EAAO,CAAA;AACxD;AAsBO,MAAM,OAAA,GAA4B,SAASC,QAAAA,CAAQ,KAAA,EAAqB;AAC3E,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,MAAM,EAAE,WAAA,EAAa,aAAA,EAAe,GAAA,EAAI,GAAI,KAAA;AAC5C,EAAA,MAAM,GAAA,GAAM,iBAAiB,KAAK,CAAA;AAClC,EAAA,MAAM,SAAA,G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aAAA,CAAc,EAAE,EAAA,EAAI,sBAAsB,CAAA;AAAA,QAC5D,UAAA,sBAAa,eAAA,EAAA,EAAgB;AAAA,OACjC;AAAA,IACJ,KAAK,UAAA;AACD,MAAA,OAAO;AAAA,QACH,gBAAA,EAAkB,eAAA;AAAA,QAClB,aAAa,IAAA,CAAK,aAAA,CAAc,EAAE,EAAA,EAAI,uBAAuB,CAAA;AAAA,QAC7D,UAAA,sBAAa,cAAA,EAAA,EAAe;AAAA,OAChC;AAAA;AAEZ;;;;"}
|
package/InitialExtent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InitialExtent.js","sources":["InitialExtent.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ButtonProps } from \"@chakra-ui/react\";\nimport { MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { ToolButton } from \"@open-pioneer/map-ui-components\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { Extent } from \"ol/extent\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC, RefAttributes } from \"react\";\nimport { LuHouse } from \"react-icons/lu\";\n\nexport interface InitialExtentProps\n extends CommonComponentProps, RefAttributes<HTMLButtonElement>, MapModelProps {\n /**\n * Additional properties for the `Button` element.\n *\n * Note that the ToolButton also defines some of these props.\n */\n buttonProps?: Partial<ButtonProps>;\n}\n\n/**\n * Provides a simple button that switches the view to its initial viewpoint.\n */\nexport const InitialExtent: FC<InitialExtentProps> = function InitialExtent(\n props: InitialExtentProps\n) {\n const { containerProps } = useCommonComponentProps(\"initial-extent\", props);\n const map = useMapModelValue(props);\n const intl = useIntl();\n const { buttonProps, ref } = props;\n\n function setInitExtent() {\n const initialExtent = map.initialExtent;\n if (initialExtent) {\n const newExtent: Extent = [\n initialExtent.xMin,\n initialExtent.yMin,\n initialExtent.xMax,\n initialExtent.yMax\n ];\n\n map.olView.fit(newExtent, { duration: 200 });\n }\n }\n\n return (\n <ToolButton\n ref={ref}\n buttonProps={buttonProps}\n label={intl.formatMessage({ id: \"initial-extent.title\" })}\n icon={<LuHouse />}\n onClick={setInitExtent}\n {...containerProps}\n />\n );\n};\n"],"names":["InitialExtent"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"InitialExtent.js","sources":["InitialExtent.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ButtonProps } from \"@chakra-ui/react\";\nimport { MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { ToolButton } from \"@open-pioneer/map-ui-components\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { Extent } from \"ol/extent\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC, RefAttributes } from \"react\";\nimport { LuHouse } from \"react-icons/lu\";\n\nexport interface InitialExtentProps\n extends CommonComponentProps, RefAttributes<HTMLButtonElement>, MapModelProps {\n /**\n * Additional properties for the `Button` element.\n *\n * Note that the ToolButton also defines some of these props.\n */\n buttonProps?: Partial<ButtonProps>;\n}\n\n/**\n * Provides a simple button that switches the view to its initial viewpoint.\n */\nexport const InitialExtent: FC<InitialExtentProps> = function InitialExtent(\n props: InitialExtentProps\n) {\n const { containerProps } = useCommonComponentProps(\"initial-extent\", props);\n const map = useMapModelValue(props);\n const intl = useIntl();\n const { buttonProps, ref } = props;\n\n function setInitExtent() {\n const initialExtent = map.initialExtent;\n if (initialExtent) {\n const newExtent: Extent = [\n initialExtent.xMin,\n initialExtent.yMin,\n initialExtent.xMax,\n initialExtent.yMax\n ];\n\n map.olView.fit(newExtent, { duration: 200 });\n }\n }\n\n return (\n <ToolButton\n ref={ref}\n buttonProps={buttonProps}\n label={intl.formatMessage({ id: \"initial-extent.title\" })}\n icon={<LuHouse />}\n onClick={setInitExtent}\n {...containerProps}\n />\n );\n};\n"],"names":["InitialExtent"],"mappings":";;;;;;;AAyBO,MAAM,aAAA,GAAwC,SAASA,cAAAA,CAC1D,KAAA,EACF;AACE,EAAA,MAAM,EAAE,cAAA,EAAe,GAAI,uBAAA,CAAwB,kBAAkB,KAAK,CAAA;AAC1E,EAAA,MAAM,GAAA,GAAM,iBAAiB,KAAK,CAAA;AAClC,EAAA,MAAM,OAAO,OAAA,EAAQ;AACrB,EAAA,MAAM,EAAE,WAAA,EAAa,GAAA,EAAI,GAAI,KAAA;AAE7B,EAAA,SAAS,aAAA,GAAgB;AACrB,IAAA,MAAM,gBAAgB,GAAA,CAAI,aAAA;AAC1B,IAAA,IAAI,aAAA,EAAe;AACf,MAAA,MAAM,SAAA,GAAoB;AAAA,QACtB,aAAA,CAAc,IAAA;AAAA,QACd,aAAA,CAAc,IAAA;AAAA,QACd,aAAA,CAAc,IAAA;AAAA,QACd,aAAA,CAAc;AAAA,OAClB;AAEA,MAAA,GAAA,CAAI,OAAO,GAAA,CAAI,SAAA,EAAW,EAAE,QAAA,EAAU,KAAK,CAAA;AAAA,IAC/C;AAAA,EACJ;AAEA,EAAA,uBACI,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACG,GAAA;AAAA,MACA,WAAA;AAAA,MACA,OAAO,IAAA,CAAK,aAAA,CAAc,EAAE,EAAA,EAAI,wBAAwB,CAAA;AAAA,MACxD,IAAA,sBAAO,OAAA,EAAA,EAAQ,CAAA;AAAA,MACf,OAAA,EAAS,aAAA;AAAA,MACR,GAAG;AAAA;AAAA,GACR;AAER;;;;"}
|
package/ViewHistoryModel.d.ts
CHANGED
package/ViewHistoryModel.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { reactiveMap, reactive } from '@conterra/reactivity-core';
|
|
1
2
|
import { View } from 'ol';
|
|
2
3
|
import { unByKey } from 'ol/Observable.js';
|
|
3
|
-
import { reactiveMap, reactive } from '@conterra/reactivity-core';
|
|
4
4
|
import { useState, useEffect } from 'react';
|
|
5
5
|
|
|
6
6
|
const SIZE_LIMIT = 200;
|
package/ViewHistoryModel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewHistoryModel.js","sources":["ViewHistoryModel.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":"ViewHistoryModel.js","sources":["ViewHistoryModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Reactive, reactive, ReactiveMap, reactiveMap } from \"@conterra/reactivity-core\";\nimport { MapModel } from \"@open-pioneer/map\";\nimport { View } from \"ol\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { EventsKey } from \"ol/events\";\nimport OlMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport { useEffect, useState } from \"react\";\n\ninterface MapViewState {\n /** Map resolution */\n resolution: number;\n\n /** Map center */\n center: Coordinate;\n}\n\nconst SIZE_LIMIT = 200;\n\nexport class ViewHistoryModel {\n #olMap: OlMap;\n #handle: EventsKey | undefined;\n\n #mapViews: ReactiveMap<number, MapViewState> = reactiveMap<number, MapViewState>();\n #activeViewId: Reactive<number> = reactive(0);\n\n constructor(map: MapModel) {\n this.#olMap = map.olMap;\n this.#handle = this.#subscribeToMapEvents();\n }\n\n destroy() {\n this.#handle && unByKey(this.#handle);\n this.#handle = undefined;\n }\n\n get activeViewId(): number {\n return this.#activeViewId.value;\n }\n\n get mapViews(): ReactiveMap<number, MapViewState> {\n return this.#mapViews;\n }\n\n get canBackward(): boolean {\n return this.mapViews.get(this.activeViewId - 1) != null;\n }\n\n get canForward(): boolean {\n return this.mapViews.get(this.activeViewId + 1) != null;\n }\n\n backward = () => {\n if (this.canBackward) {\n this.#setActiveView(this.activeViewId - 1);\n this.#goto(this.activeViewId);\n } else throw new Error(\"Backward is not possible at the moment\");\n };\n\n forward = () => {\n if (this.canForward) {\n this.#setActiveView(this.activeViewId + 1);\n this.#goto(this.activeViewId);\n } else throw new Error(\"Forward is not possible at the moment\");\n };\n\n #goto(activeViewId: number) {\n const view = this.#olMap.getView();\n const activeView = this.mapViews.get(activeViewId);\n if (activeView == null) {\n throw new Error(`No view found for id ${activeViewId}`);\n }\n this.#olMap.setView(\n new View({\n center: activeView.center,\n resolution: activeView.resolution,\n projection: view.getProjection()\n })\n );\n }\n\n #setActiveView(activeViewId: number) {\n this.#activeViewId.value = activeViewId;\n }\n\n #subscribeToMapEvents() {\n const eventsKey: EventsKey = this.#olMap.on(\"moveend\", () => {\n onCenterResChange();\n });\n\n const onCenterResChange = () => {\n const olMap = this.#olMap;\n const mapViews = this.mapViews;\n const view = olMap.getView();\n const resolution = view.getResolution();\n const center = view.getCenter();\n if (resolution != null && center != null) {\n if (\n center !== mapViews.get(this.activeViewId)?.center ||\n resolution !== mapViews.get(this.activeViewId)?.resolution\n ) {\n const mapState = {\n resolution: resolution,\n center: center\n };\n const nextViewId = this.activeViewId + 1;\n\n // Remove keys in the \"future\". Note: an array would probably be more efficient.\n for (const k of mapViews.keys()) {\n if (k > nextViewId) {\n mapViews.delete(k);\n }\n }\n\n // Remove old keys above limit (maps are sorted by insertion order, so this removes the oldest entries)\n for (const k of mapViews.keys()) {\n if (mapViews.size < SIZE_LIMIT) {\n break;\n }\n mapViews.delete(k);\n }\n\n this.#setActiveView(nextViewId);\n mapViews.set(nextViewId, mapState);\n }\n }\n };\n\n return eventsKey;\n }\n}\n\ninterface ViewModelState {\n vm: ViewHistoryModel;\n useCount: number; // 0 -> must destroy\n}\n\nconst VIEW_MODELS = new WeakMap<MapModel, ViewModelState>();\n\n/**\n * An internal hook that returns a shared HistoryViewModel.\n * History tools that are active at the same time share a single model.\n *\n * The model is destroyed when the last tool is unmounted.\n *\n * TODO: `undefined` only because the map can be undefined at the moment (loading).\n *\n * NOTE: May be useful to have this a general solution in the future; but this is the only usage right now.\n */\nexport function useHistoryViewModel(map: MapModel): ViewHistoryModel | undefined {\n const [vm, setVm] = useState<ViewHistoryModel>();\n useEffect(() => {\n let state = VIEW_MODELS.get(map);\n if (state == null) {\n state = {\n vm: new ViewHistoryModel(map),\n useCount: 1\n };\n VIEW_MODELS.set(map, state);\n } else {\n state.useCount++;\n }\n setVm(state.vm);\n\n return () => {\n setVm(undefined);\n\n state.useCount--;\n if (state.useCount === 0) {\n state.vm.destroy();\n VIEW_MODELS.delete(map);\n }\n };\n }, [map]);\n return vm;\n}\n"],"names":[],"mappings":";;;;;AAoBA,MAAM,UAAA,GAAa,GAAA;AAEZ,MAAM,gBAAA,CAAiB;AAAA,EAC1B,MAAA;AAAA,EACA,OAAA;AAAA,EAEA,YAA+C,WAAA,EAAkC;AAAA,EACjF,aAAA,GAAkC,SAAS,CAAC,CAAA;AAAA,EAE5C,YAAY,GAAA,EAAe;AACvB,IAAA,IAAA,CAAK,SAAS,GAAA,CAAI,KAAA;AAClB,IAAA,IAAA,CAAK,OAAA,GAAU,KAAK,qBAAA,EAAsB;AAAA,EAC9C;AAAA,EAEA,OAAA,GAAU;AACN,IAAA,IAAA,CAAK,OAAA,IAAW,OAAA,CAAQ,IAAA,CAAK,OAAO,CAAA;AACpC,IAAA,IAAA,CAAK,OAAA,GAAU,MAAA;AAAA,EACnB;AAAA,EAEA,IAAI,YAAA,GAAuB;AACvB,IAAA,OAAO,KAAK,aAAA,CAAc,KAAA;AAAA,EAC9B;AAAA,EAEA,IAAI,QAAA,GAA8C;AAC9C,IAAA,OAAO,IAAA,CAAK,SAAA;AAAA,EAChB;AAAA,EAEA,IAAI,WAAA,GAAuB;AACvB,IAAA,OAAO,KAAK,QAAA,CAAS,GAAA,CAAI,IAAA,CAAK,YAAA,GAAe,CAAC,CAAA,IAAK,IAAA;AAAA,EACvD;AAAA,EAEA,IAAI,UAAA,GAAsB;AACtB,IAA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AAI,YAAY,QAAQ,CAAA;AAAA,QACrC;AAAA,MACJ;AAAA,IACJ,CAAA;AAEA,IAAA,OAAO,SAAA;AAAA,EACX;AACJ;AAOA,MAAM,WAAA,uBAAkB,OAAA,EAAkC;AAYnD,SAAS,oBAAoB,GAAA,EAA6C;AAC7E,EAAA,MAAM,CAAC,EAAA,EAAI,KAAK,CAAA,GAAI,QAAA,EAA2B;AAC/C,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,IAAI,KAAA,GAAQ,WAAA,CAAY,GAAA,CAAI,GAAG,CAAA;AAC/B,IAAA,IAAI,SAAS,IAAA,EAAM;AACf,MAAA,KAAA,GAAQ;AAAA,QACJ,EAAA,EAAI,IAAI,gBAAA,CAAiB,GAAG,CAAA;AAAA,QAC5B,QAAA,EAAU;AAAA,OACd;AACA,MAAA,WAAA,CAAY,GAAA,CAAI,KAAK,KAAK,CAAA;AAAA,IAC9B,CAAA,MAAO;AACH,MAAA,KAAA,CAAM,QAAA,EAAA;AAAA,IACV;AACA,IAAA,KAAA,CAAM,MAAM,EAAE,CAAA;AAEd,IAAA,OAAO,MAAM;AACT,MAAA,KAAA,CAAM,MAAS,CAAA;AAEf,MAAA,KAAA,CAAM,QAAA,EAAA;AACN,MAAA,IAAI,KAAA,CAAM,aAAa,CAAA,EAAG;AACtB,QAAA,KAAA,CAAM,GAAG,OAAA,EAAQ;AACjB,QAAA,WAAA,CAAY,OAAO,GAAG,CAAA;AAAA,MAC1B;AAAA,IACJ,CAAA;AAAA,EACJ,CAAA,EAAG,CAAC,GAAG,CAAC,CAAA;AACR,EAAA,OAAO,EAAA;AACX;;;;"}
|
package/Zoom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Zoom.js","sources":["Zoom.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { ButtonProps } from \"@chakra-ui/react\";\nimport { MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { ToolButton } from \"@open-pioneer/map-ui-components\";\nimport {
|
|
1
|
+
{"version":3,"file":"Zoom.js","sources":["Zoom.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ButtonProps } from \"@chakra-ui/react\";\nimport { MapModelProps, useMapModelValue } from \"@open-pioneer/map\";\nimport { ToolButton } from \"@open-pioneer/map-ui-components\";\nimport {\n CommonComponentProps,\n useCommonComponentProps,\n classNames\n} from \"@open-pioneer/react-utils\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC, RefAttributes, useState } from \"react\";\nimport { LuMinus, LuPlus } from \"react-icons/lu\";\n\nexport type ZoomInProps = Omit<ZoomProps, \"zoomDirection\">;\n\n/**\n * Provides a button by which the user can zoom into the map.\n *\n * This component composes {@link Zoom}.\n */\nexport const ZoomIn: FC<ZoomInProps> = function ZoomIn(props) {\n return <Zoom zoomDirection=\"in\" {...props} />;\n};\n\nexport type ZoomOutProps = ZoomInProps;\n\n/**\n * Provides a button by which the user can zoom out of the map.\n *\n * This component composes {@link Zoom}.\n */\nexport const ZoomOut: FC<ZoomOutProps> = function ZoomOut(props) {\n return <Zoom zoomDirection=\"out\" {...props} />;\n};\n\nexport interface ZoomProps\n extends CommonComponentProps, RefAttributes<HTMLButtonElement>, MapModelProps {\n /**\n * Additional properties for the `Button` element.\n *\n * Note that the ToolButton also defines some of these props.\n */\n buttonProps?: Partial<ButtonProps>;\n\n /**\n * The zoom direction.\n *\n * The button will either zoom in or zoom out depending on this value.\n */\n zoomDirection: \"in\" | \"out\";\n}\n\n/**\n * Provides a button by which the user can zoom in or zoom out of the map.\n */\nexport const Zoom: FC<ZoomProps> = function Zoom(props: ZoomProps) {\n const { buttonProps, zoomDirection, ref } = props;\n const map = useMapModelValue(props);\n const intl = useIntl();\n const [disabled, setDisabled] = useState<boolean>(false);\n const { defaultClassName, buttonLabel, buttonIcon } = getDirectionProps(intl, zoomDirection);\n\n const { containerProps } = useCommonComponentProps(classNames(\"zoom\", defaultClassName), props);\n\n function zoom() {\n if (disabled) {\n return;\n }\n setDisabled(true);\n\n const view = map.olView;\n const maxZoom = view.getMaxZoom() || Number.MAX_SAFE_INTEGER;\n const minZoom = view.getMinZoom() || 0;\n\n let currZoom = map.zoomLevel;\n if (currZoom != null) {\n if (zoomDirection === \"in\" && currZoom < maxZoom) {\n ++currZoom;\n } else if (zoomDirection === \"out\" && currZoom > minZoom) {\n --currZoom;\n }\n\n view.animate({ zoom: currZoom, duration: 200 }, () => setDisabled(false));\n }\n }\n\n return (\n <ToolButton\n ref={ref}\n buttonProps={buttonProps}\n label={buttonLabel}\n icon={buttonIcon}\n onClick={zoom}\n {...containerProps}\n />\n );\n};\n\nfunction getDirectionProps(intl: PackageIntl, zoomDirection: \"in\" | \"out\") {\n switch (zoomDirection) {\n case \"in\":\n return {\n defaultClassName: \"zoom-in\",\n buttonLabel: intl.formatMessage({ id: \"zoom-in.title\" }),\n buttonIcon: <LuPlus />\n };\n case \"out\":\n return {\n defaultClassName: \"zoom-out\",\n buttonLabel: intl.formatMessage({ id: \"zoom-out.title\" }),\n buttonIcon: <LuMinus />\n };\n }\n}\n"],"names":["ZoomIn","ZoomOut","Zoom"],"mappings":";;;;;;;;AAuBO,MAAM,MAAA,GAA0B,SAASA,OAAAA,CAAO,KAAA,EAAO;AAC1D,EAAA,uBAAO,GAAA,CAAC,IAAA,EAAA,EAAK,aAAA,EAAc,IAAA,EAAM,GAAG,KAAA,EAAO,CAAA;AAC/C;AASO,MAAM,OAAA,GAA4B,SAASC,QAAAA,CAAQ,KAAA,EAAO;AAC7D,EAAA,uBAAO,GAAA,CAAC,IAAA,EAAA,EAAK,aAAA,EAAc,KAAA,EAAO,GAAG,KAAA,EAAO,CAAA;AAChD;AAsBO,MAAM,IAAA,GAAsB,SAAS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AA,IAAC,UAAA;AAAA,IAAA;AAAA,MACG,GAAA;AAAA,MACA,WAAA;AAAA,MACA,KAAA,EAAO,WAAA;AAAA,MACP,IAAA,EAAM,UAAA;AAAA,MACN,OAAA,EAAS,IAAA;AAAA,MACR,GAAG;AAAA;AAAA,GACR;AAER;AAEA,SAAS,iBAAA,CAAkB,MAAmB,aAAA,EAA6B;AACvE,EAAA,QAAQ,aAAA;AAAe,IACnB,KAAK,IAAA;AACD,MAAA,OAAO;AAAA,QACH,gBAAA,EAAkB,SAAA;AAAA,QAClB,aAAa,IAAA,CAAK,aAAA,CAAc,EAAE,EAAA,EAAI,iBAAiB,CAAA;AAAA,QACvD,UAAA,sBAAa,MAAA,EAAA,EAAO;AAAA,OACxB;AAAA,IACJ,KAAK,KAAA;AACD,MAAA,OAAO;AAAA,QACH,gBAAA,EAAkB,UAAA;AAAA,QAClB,aAAa,IAAA,CAAK,aAAA,CAAc,EAAE,EAAA,EAAI,kBAAkB,CAAA;AAAA,QACxD,UAAA,sBAAa,OAAA,EAAA,EAAQ;AAAA,OACzB;AAAA;AAEZ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/map-navigation",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0-dev.20260910103330",
|
|
5
5
|
"description": "This package provides a collection of map navigation controls.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,16 +14,20 @@
|
|
|
14
14
|
"directory": "src/packages/map-navigation"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@
|
|
19
|
-
"@open-pioneer/
|
|
20
|
-
"@open-pioneer/
|
|
21
|
-
"@open-pioneer/
|
|
22
|
-
"
|
|
17
|
+
"@chakra-ui/react": "^3.37.0",
|
|
18
|
+
"@conterra/reactivity-core": "^0.8.8",
|
|
19
|
+
"@open-pioneer/map": "1.5.0-dev.20260910103330",
|
|
20
|
+
"@open-pioneer/map-ui-components": "1.5.0-dev.20260910103330",
|
|
21
|
+
"@open-pioneer/react-utils": "4.8.0-dev.20260910101405",
|
|
22
|
+
"@open-pioneer/reactivity": "4.8.0-dev.20260910101405",
|
|
23
|
+
"@open-pioneer/runtime": "4.8.0-dev.20260910101405",
|
|
24
|
+
"ol": "^10.10.0",
|
|
23
25
|
"react": "^19.2.8",
|
|
24
|
-
"react-icons": "^5.7.0"
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
"react-icons": "^5.7.0"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"directory": "dist",
|
|
30
|
+
"linkDirectory": false
|
|
27
31
|
},
|
|
28
32
|
"exports": {
|
|
29
33
|
"./package.json": "./package.json",
|