react-spatial 1.5.4 → 1.5.6-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +94 -63
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +1 -1
- package/components/BaseLayerSwitcher/index.js.map +1 -1
- package/components/BasicMap/BasicMap.js +60 -15
- package/components/BasicMap/BasicMap.js.map +2 -2
- package/components/BasicMap/index.js.map +1 -1
- package/components/CanvasSaveButton/CanvasSaveButton.js +95 -12
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +2 -2
- package/components/CanvasSaveButton/index.js.map +1 -1
- package/components/Copyright/Copyright.js +19 -5
- package/components/Copyright/Copyright.js.map +1 -1
- package/components/Copyright/index.js.map +1 -1
- package/components/FeatureExportButton/FeatureExportButton.js +30 -12
- package/components/FeatureExportButton/FeatureExportButton.js.map +1 -1
- package/components/FeatureExportButton/index.js.map +1 -1
- package/components/FitExtent/FitExtent.js +24 -8
- package/components/FitExtent/FitExtent.js.map +1 -1
- package/components/FitExtent/index.js.map +1 -1
- package/components/Geolocation/Geolocation.js +47 -14
- package/components/Geolocation/Geolocation.js.map +1 -1
- package/components/Geolocation/index.js.map +1 -1
- package/components/LayerTree/LayerTree.js +155 -46
- package/components/LayerTree/LayerTree.js.map +1 -1
- package/components/LayerTree/index.js.map +1 -1
- package/components/MousePosition/MousePosition.js +48 -16
- package/components/MousePosition/MousePosition.js.map +1 -1
- package/components/MousePosition/index.js.map +1 -1
- package/components/NorthArrow/NorthArrow.js +21 -5
- package/components/NorthArrow/NorthArrow.js.map +1 -1
- package/components/NorthArrow/index.js.map +1 -1
- package/components/Overlay/Overlay.js +72 -44
- package/components/Overlay/Overlay.js.map +1 -1
- package/components/Overlay/index.js.map +1 -1
- package/components/Permalink/Permalink.js +37 -0
- package/components/Permalink/Permalink.js.map +1 -1
- package/components/Permalink/index.js.map +1 -1
- package/components/Popup/Popup.js +84 -33
- package/components/Popup/Popup.js.map +1 -1
- package/components/Popup/index.js.map +1 -1
- package/components/ResizeHandler/ResizeHandler.js +1 -0
- package/components/ResizeHandler/ResizeHandler.js.map +1 -1
- package/components/ResizeHandler/index.js.map +1 -1
- package/components/RouteSchedule/RouteSchedule.js +121 -76
- package/components/RouteSchedule/RouteSchedule.js.map +2 -2
- package/components/RouteSchedule/index.js.map +1 -1
- package/components/ScaleLine/ScaleLine.js +8 -5
- package/components/ScaleLine/ScaleLine.js.map +1 -1
- package/components/ScaleLine/index.js.map +1 -1
- package/components/StopsFinder/StopsFinder.js +96 -51
- package/components/StopsFinder/StopsFinder.js.map +1 -1
- package/components/StopsFinder/StopsFinderOption.js +2 -9
- package/components/StopsFinder/StopsFinderOption.js.map +1 -1
- package/components/StopsFinder/index.js.map +1 -1
- package/components/Zoom/Zoom.js +48 -29
- package/components/Zoom/Zoom.js.map +1 -1
- package/components/Zoom/index.js.map +1 -1
- package/package.json +32 -31
- package/propTypes.js +19 -1
- package/propTypes.js.map +2 -2
- package/utils/KML.js +8 -0
- package/utils/KML.js.map +1 -1
- package/utils/KMLFormat.js +32 -4
- package/utils/KMLFormat.js.map +1 -1
- package/utils/getPolygonPattern.js.map +1 -1
- package/utils/timeUtils.js.map +1 -1
|
@@ -4,16 +4,39 @@ import { FaChevronLeft } from "react-icons/fa";
|
|
|
4
4
|
import { Layer } from "mobility-toolbox-js/ol";
|
|
5
5
|
import { unByKey } from "ol/Observable";
|
|
6
6
|
const propTypes = {
|
|
7
|
+
/**
|
|
8
|
+
* An array of [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers).
|
|
9
|
+
*/
|
|
7
10
|
layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)).isRequired,
|
|
11
|
+
/**
|
|
12
|
+
* Object containing relative paths to the base layer images. Object
|
|
13
|
+
* keys need to correspond to layer keys
|
|
14
|
+
*/
|
|
8
15
|
layerImages: PropTypes.objectOf(PropTypes.string),
|
|
16
|
+
/**
|
|
17
|
+
* CSS class to apply on the container.
|
|
18
|
+
*/
|
|
9
19
|
className: PropTypes.string,
|
|
20
|
+
/**
|
|
21
|
+
* Alternative text rendered if layer images can't be loaded
|
|
22
|
+
*/
|
|
10
23
|
altText: PropTypes.string,
|
|
24
|
+
/**
|
|
25
|
+
* Button titles.
|
|
26
|
+
*/
|
|
11
27
|
titles: PropTypes.shape({
|
|
12
28
|
button: PropTypes.string,
|
|
13
29
|
openSwitcher: PropTypes.string,
|
|
14
30
|
closeSwitcher: PropTypes.string
|
|
15
31
|
}),
|
|
32
|
+
/**
|
|
33
|
+
* Image (node) rendered in the switcher close button.
|
|
34
|
+
*/
|
|
16
35
|
closeButtonImage: PropTypes.node,
|
|
36
|
+
/**
|
|
37
|
+
* Translation function.
|
|
38
|
+
* @param {function} Translation function returning the translated string.
|
|
39
|
+
*/
|
|
17
40
|
t: PropTypes.func
|
|
18
41
|
};
|
|
19
42
|
const defaultProps = {
|
|
@@ -151,79 +174,87 @@ function BaseLayerSwitcher({
|
|
|
151
174
|
if (!layers || layers.length < 2 || !currentLayer) {
|
|
152
175
|
return null;
|
|
153
176
|
}
|
|
154
|
-
const toggleBtn = /* @__PURE__ */ React.createElement("div", {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
177
|
+
const toggleBtn = /* @__PURE__ */ React.createElement("div", { className: "rs-base-layer-switcher-btn-wrapper" }, /* @__PURE__ */ React.createElement(
|
|
178
|
+
"div",
|
|
179
|
+
{
|
|
180
|
+
className: "rs-base-layer-switcher-close-btn",
|
|
181
|
+
role: "button",
|
|
182
|
+
onClick: () => {
|
|
183
|
+
return setSwitcherOpen(false);
|
|
184
|
+
},
|
|
185
|
+
onKeyPress: (e) => {
|
|
186
|
+
return e.which === 13 && setSwitcherOpen(false);
|
|
187
|
+
},
|
|
188
|
+
tabIndex: switcherOpen ? "0" : "-1",
|
|
189
|
+
"aria-label": titles.closeSwitcher,
|
|
190
|
+
title: titles.closeSwitcher
|
|
164
191
|
},
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
192
|
+
closeButtonImage
|
|
193
|
+
));
|
|
194
|
+
return /* @__PURE__ */ React.createElement("div", { className: `${className}${openClass}` }, /* @__PURE__ */ React.createElement(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
className: `rs-base-layer-switcher-button rs-opener${openClass}`,
|
|
198
|
+
role: "button",
|
|
199
|
+
title: titles.openSwitcher,
|
|
200
|
+
"aria-label": titles.openSwitcher,
|
|
201
|
+
onClick: handleSwitcherClick,
|
|
202
|
+
onKeyPress: (e) => {
|
|
203
|
+
if (e.which === 13) {
|
|
204
|
+
handleSwitcherClick();
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
style: getImageStyle(nextImage),
|
|
208
|
+
tabIndex: "0"
|
|
181
209
|
},
|
|
182
|
-
|
|
183
|
-
tabIndex: "0"
|
|
184
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
185
|
-
className: "rs-base-layer-switcher-title"
|
|
186
|
-
}, layers.length !== 2 ? titles.button : layers.find((layer) => {
|
|
187
|
-
return !layer.visible;
|
|
188
|
-
}) && t(
|
|
189
|
-
layers.find((layer) => {
|
|
210
|
+
/* @__PURE__ */ React.createElement("div", { className: "rs-base-layer-switcher-title" }, layers.length !== 2 ? titles.button : layers.find((layer) => {
|
|
190
211
|
return !layer.visible;
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
212
|
+
}) && t(
|
|
213
|
+
layers.find((layer) => {
|
|
214
|
+
return !layer.visible;
|
|
215
|
+
}).name
|
|
216
|
+
)),
|
|
217
|
+
nextImage ? null : /* @__PURE__ */ React.createElement("span", { className: "rs-alt-text" }, t(altText))
|
|
218
|
+
), layers.map((layer, idx) => {
|
|
195
219
|
const layerName = layer.name;
|
|
196
220
|
const activeClass = layerName === currentLayer.name ? " rs-active" : "";
|
|
197
221
|
const imageStyle = getImageStyle(
|
|
198
222
|
layerImages ? layerImages[`${layer.key}`] : layer.get("previewImage")
|
|
199
223
|
);
|
|
200
|
-
return /* @__PURE__ */ React.createElement(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
title: t(layerName),
|
|
211
|
-
"aria-label": t(layerName),
|
|
212
|
-
onClick: () => {
|
|
213
|
-
return onLayerSelect(layer);
|
|
214
|
-
},
|
|
215
|
-
onKeyPress: (e) => {
|
|
216
|
-
if (e.which === 13) {
|
|
217
|
-
onLayerSelect(layer);
|
|
224
|
+
return /* @__PURE__ */ React.createElement(
|
|
225
|
+
"div",
|
|
226
|
+
{
|
|
227
|
+
key: layer.key,
|
|
228
|
+
className: "rs-base-layer-switcher-btn-wrapper",
|
|
229
|
+
style: {
|
|
230
|
+
/* stylelint-disable-next-line value-keyword-case */
|
|
231
|
+
overflow: hiddenStyle,
|
|
232
|
+
/* stylelint-disable-next-line value-keyword-case */
|
|
233
|
+
zIndex: layers.length - idx
|
|
218
234
|
}
|
|
219
235
|
},
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
236
|
+
/* @__PURE__ */ React.createElement(
|
|
237
|
+
"div",
|
|
238
|
+
{
|
|
239
|
+
className: `rs-base-layer-switcher-button${openClass}`,
|
|
240
|
+
role: "button",
|
|
241
|
+
title: t(layerName),
|
|
242
|
+
"aria-label": t(layerName),
|
|
243
|
+
onClick: () => {
|
|
244
|
+
return onLayerSelect(layer);
|
|
245
|
+
},
|
|
246
|
+
onKeyPress: (e) => {
|
|
247
|
+
if (e.which === 13) {
|
|
248
|
+
onLayerSelect(layer);
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
style: imageStyle,
|
|
252
|
+
tabIndex: switcherOpen ? "0" : "-1"
|
|
253
|
+
},
|
|
254
|
+
/* @__PURE__ */ React.createElement("div", { className: `rs-base-layer-switcher-title${activeClass}` }, t(layerName)),
|
|
255
|
+
imageStyle ? null : /* @__PURE__ */ React.createElement("span", { className: "rs-alt-text" }, t(altText))
|
|
256
|
+
)
|
|
257
|
+
);
|
|
227
258
|
}), toggleBtn);
|
|
228
259
|
}
|
|
229
260
|
BaseLayerSwitcher.propTypes = propTypes;
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/BaseLayerSwitcher/BaseLayerSwitcher.js"],
|
|
4
4
|
"sourcesContent": ["/* eslint-disable jsx-a11y/interactive-supports-focus */\nimport React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { FaChevronLeft } from 'react-icons/fa';\nimport { Layer } from 'mobility-toolbox-js/ol';\nimport { unByKey } from 'ol/Observable';\n\nconst propTypes = {\n /**\n * An array of [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers).\n */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)).isRequired,\n\n /**\n * Object containing relative paths to the base layer images. Object\n * keys need to correspond to layer keys\n */\n layerImages: PropTypes.objectOf(PropTypes.string),\n\n /**\n * CSS class to apply on the container.\n */\n className: PropTypes.string,\n\n /**\n * Alternative text rendered if layer images can't be loaded\n */\n altText: PropTypes.string,\n\n /**\n * Button titles.\n */\n titles: PropTypes.shape({\n button: PropTypes.string,\n openSwitcher: PropTypes.string,\n closeSwitcher: PropTypes.string,\n }),\n\n /**\n * Image (node) rendered in the switcher close button.\n */\n closeButtonImage: PropTypes.node,\n\n /**\n * Translation function.\n * @param {function} Translation function returning the translated string.\n */\n t: PropTypes.func,\n};\n\nconst defaultProps = {\n className: 'rs-base-layer-switcher',\n altText: 'Source not found',\n titles: {\n button: 'Base layers',\n openSwitcher: 'Open Baselayer-Switcher',\n closeSwitcher: 'Close Baselayer-Switcher',\n },\n closeButtonImage: <FaChevronLeft />,\n layerImages: undefined,\n t: (s) => {\n return s;\n },\n};\n\nconst getVisibleLayer = (layers) => {\n return layers.find((layer) => {\n return layer.visible;\n });\n};\n\nconst getNextImage = (currentLayer, layers, layerImages) => {\n const currentIndex = layers.indexOf(\n layers.find((layer) => {\n return layer === currentLayer;\n }),\n );\n const nextIndex = currentIndex + 1 === layers.length ? 0 : currentIndex + 1;\n return layerImages[nextIndex];\n};\n\nconst getImageStyle = (url) => {\n return url\n ? {\n backgroundImage: `url(${url})`,\n backgroundSize: 'cover',\n backgroundRepeat: 'no-repeat',\n backgroundPosition: 'center',\n }\n : null;\n};\n\n/**\n * The BaseLayerSwitcher component renders a button interface for switching the visible\n * [mobility-toolbox-js layer](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers)\n * when defined as base layer.\n */\n\nfunction BaseLayerSwitcher({\n layers,\n layerImages,\n className,\n altText,\n titles,\n closeButtonImage,\n t,\n}) {\n const [switcherOpen, setSwitcherOpen] = useState(false);\n const [isClosed, setIsClosed] = useState(true);\n const [currentLayer, setCurrentLayer] = useState(\n getVisibleLayer(layers) || layers[0],\n );\n\n useEffect(() => {\n // Update the layer selected when a visibility changes.\n const olKeys = (layers || []).map((layer) => {\n return layer.on('change:visible', (evt) => {\n if (evt.target.visible && currentLayer !== evt.target) {\n setCurrentLayer(evt.target);\n }\n });\n });\n return () => {\n unByKey(olKeys);\n };\n }, [currentLayer, layers]);\n\n /* Images are loaded from props if provided, fallback from layer */\n const images = layerImages\n ? Object.keys(layerImages).map((layerImage) => {\n return layerImages[layerImage];\n })\n : layers.map((layer) => {\n return layer.get('previewImage');\n });\n\n const openClass = switcherOpen ? ' rs-open' : '';\n const hiddenStyle = switcherOpen && !isClosed ? 'visible' : 'hidden';\n\n const handleSwitcherClick = () => {\n if (layers.length === 2) {\n /* On only two layer options the opener becomes a layer toggle button */\n const nextLayer = layers.find((layer) => {\n return !layer.visible;\n });\n if (currentLayer.setVisible) {\n currentLayer.setVisible(false);\n } else {\n currentLayer.visible = false;\n }\n setCurrentLayer(nextLayer);\n if (nextLayer.setVisible) {\n nextLayer.setVisible(true);\n } else {\n nextLayer.visible = true;\n }\n return;\n }\n // eslint-disable-next-line consistent-return\n return setSwitcherOpen(true) && setIsClosed(false);\n };\n\n const onLayerSelect = (layer) => {\n if (!switcherOpen) {\n setSwitcherOpen(true);\n return;\n }\n setCurrentLayer(layer);\n if (layer.setVisible) {\n layer.setVisible(true);\n } else {\n // eslint-disable-next-line no-param-reassign\n layer.visible = true;\n }\n layers\n .filter((l) => {\n return l !== layer;\n })\n .forEach((l) => {\n if (l.setVisible) {\n l.setVisible(false);\n } else {\n // eslint-disable-next-line no-param-reassign\n l.visible = false;\n }\n });\n setSwitcherOpen(false);\n };\n\n /* Get next image for closed button */\n const nextImage = getNextImage(currentLayer, layers, images);\n\n useEffect(() => {\n /* Ensure correct layer is active on app load */\n if (currentLayer !== getVisibleLayer(layers)) {\n setCurrentLayer(getVisibleLayer(layers) || layers[0]);\n }\n }, [currentLayer, layers]);\n\n useEffect(() => {\n /* Used for correct layer image render with animation */\n let timeout;\n if (!switcherOpen) {\n timeout = setTimeout(() => {\n setIsClosed(true);\n }, 200);\n } else {\n timeout = setTimeout(() => {\n setIsClosed(false);\n }, 800);\n }\n return () => {\n return clearTimeout(timeout);\n };\n }, [switcherOpen]);\n\n if (!layers || layers.length < 2 || !currentLayer) {\n return null;\n }\n\n const toggleBtn = (\n <div className=\"rs-base-layer-switcher-btn-wrapper\">\n <div\n className=\"rs-base-layer-switcher-close-btn\"\n role=\"button\"\n onClick={() => {\n return setSwitcherOpen(false);\n }}\n onKeyPress={(e) => {\n return e.which === 13 && setSwitcherOpen(false);\n }}\n tabIndex={switcherOpen ? '0' : '-1'}\n aria-label={titles.closeSwitcher}\n title={titles.closeSwitcher}\n >\n {closeButtonImage}\n </div>\n </div>\n );\n\n return (\n <div className={`${className}${openClass}`}>\n <div\n className={`rs-base-layer-switcher-button rs-opener${openClass}`}\n role=\"button\"\n title={titles.openSwitcher}\n aria-label={titles.openSwitcher}\n onClick={handleSwitcherClick}\n onKeyPress={(e) => {\n if (e.which === 13) {\n handleSwitcherClick();\n }\n }}\n style={getImageStyle(nextImage)}\n tabIndex=\"0\"\n >\n <div className=\"rs-base-layer-switcher-title\">\n {layers.length !== 2\n ? titles.button\n : layers.find((layer) => {\n return !layer.visible;\n }) &&\n t(\n layers.find((layer) => {\n return !layer.visible;\n }).name,\n )}\n </div>\n {nextImage ? null : <span className=\"rs-alt-text\">{t(altText)}</span>}\n </div>\n {layers.map((layer, idx) => {\n const layerName = layer.name;\n const activeClass = layerName === currentLayer.name ? ' rs-active' : '';\n const imageStyle = getImageStyle(\n layerImages ? layerImages[`${layer.key}`] : layer.get('previewImage'),\n );\n return (\n <div\n key={layer.key}\n className=\"rs-base-layer-switcher-btn-wrapper\"\n style={{\n /* stylelint-disable-next-line value-keyword-case */\n overflow: hiddenStyle,\n /* stylelint-disable-next-line value-keyword-case */\n zIndex: layers.length - idx,\n }}\n >\n <div\n className={`rs-base-layer-switcher-button${openClass}`}\n role=\"button\"\n title={t(layerName)}\n aria-label={t(layerName)}\n onClick={() => {\n return onLayerSelect(layer);\n }}\n onKeyPress={(e) => {\n if (e.which === 13) {\n onLayerSelect(layer);\n }\n }}\n style={imageStyle}\n tabIndex={switcherOpen ? '0' : '-1'}\n >\n <div className={`rs-base-layer-switcher-title${activeClass}`}>\n {t(layerName)}\n </div>\n {imageStyle ? null : (\n <span className=\"rs-alt-text\">{t(altText)}</span>\n )}\n </div>\n </div>\n );\n })}\n {toggleBtn}\n </div>\n );\n}\n\nBaseLayerSwitcher.propTypes = propTypes;\nBaseLayerS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;AAAA,UAEL,UAAU;AAAA;AAAA,UAEV,QAAQ,OAAO,SAAS;AAAA,QAC1B;AAAA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,WAAW,gCAAgC,SAAS;AAAA,UACpD,MAAK;AAAA,UACL,OAAO,EAAE,SAAS;AAAA,UAClB,cAAY,EAAE,SAAS;AAAA,UACvB,SAAS,MAAM;AACb,mBAAO,cAAc,KAAK;AAAA,UAC5B;AAAA,UACA,YAAY,CAAC,MAAM;AACjB,gBAAI,EAAE,UAAU,IAAI;AAClB,4BAAc,KAAK;AAAA,YACrB;AAAA,UACF;AAAA,UACA,OAAO;AAAA,UACP,UAAU,eAAe,MAAM;AAAA;AAAA,QAE/B,oCAAC,SAAI,WAAW,+BAA+B,WAAW,MACvD,EAAE,SAAS,CACd;AAAA,QACC,aAAa,OACZ,oCAAC,UAAK,WAAU,iBAAe,EAAE,OAAO,CAAE;AAAA,MAE9C;AAAA,IACF;AAAA,EAEJ,CAAC,GACA,SACH;AAEJ;AAEA,kBAAkB,YAAY;AAC9B,kBAAkB,eAAe;AAEjC,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -10,39 +10,71 @@ import Interaction from "ol/interaction/Interaction";
|
|
|
10
10
|
import { Layer } from "mobility-toolbox-js/ol";
|
|
11
11
|
import ResizeHandler from "../ResizeHandler";
|
|
12
12
|
const propTypes = {
|
|
13
|
+
/** Map animation options */
|
|
13
14
|
animationOptions: PropTypes.shape({
|
|
14
15
|
center: PropTypes.arrayOf(PropTypes.number),
|
|
15
16
|
resolution: PropTypes.number,
|
|
16
17
|
zoom: PropTypes.number
|
|
17
18
|
}),
|
|
19
|
+
/** Center of the [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html). */
|
|
18
20
|
center: PropTypes.arrayOf(PropTypes.number),
|
|
21
|
+
/** Class name of the map container */
|
|
19
22
|
className: PropTypes.string,
|
|
23
|
+
/** Map extent */
|
|
20
24
|
extent: PropTypes.arrayOf(PropTypes.number),
|
|
25
|
+
/** Openlayers [fit options](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit) when extent is updated */
|
|
21
26
|
fitOptions: PropTypes.object,
|
|
27
|
+
/** Array of [ol/interaction](https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html). */
|
|
22
28
|
interactions: PropTypes.oneOfType([
|
|
23
29
|
PropTypes.arrayOf(PropTypes.instanceOf(Interaction)),
|
|
24
30
|
PropTypes.instanceOf(OLCollection)
|
|
25
31
|
]),
|
|
32
|
+
/** Array of [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers) to display. */
|
|
26
33
|
layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),
|
|
34
|
+
/** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */
|
|
27
35
|
map: PropTypes.instanceOf(OLMap),
|
|
36
|
+
/**
|
|
37
|
+
* Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is clicked.
|
|
38
|
+
* @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).
|
|
39
|
+
* @param {ol.MapBrowserEvent} event The singleclick [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:singleclick).
|
|
40
|
+
*/
|
|
28
41
|
onFeaturesClick: PropTypes.func,
|
|
42
|
+
/**
|
|
43
|
+
* Optional options to pass on feature click. Passed to ol's 'getFeaturesAtPixel' method.
|
|
44
|
+
* https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html#getFeaturesAtPixel
|
|
45
|
+
*/
|
|
29
46
|
featuresClickOptions: PropTypes.shape({
|
|
30
47
|
layerFilter: PropTypes.func,
|
|
31
48
|
hitTolerance: PropTypes.number,
|
|
32
49
|
checkWrapped: PropTypes.bool
|
|
33
50
|
}),
|
|
51
|
+
/**
|
|
52
|
+
* Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is hovered.
|
|
53
|
+
* @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).
|
|
54
|
+
* @param {ol.MapBrowserEvent} event The pointermove [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:pointermove).
|
|
55
|
+
*/
|
|
34
56
|
onFeaturesHover: PropTypes.func,
|
|
57
|
+
/**
|
|
58
|
+
* Callback when the map was moved.
|
|
59
|
+
* @param {ol.MapEvent} event The movend [ol/MapEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:moveend).
|
|
60
|
+
*/
|
|
35
61
|
onMapMoved: PropTypes.func,
|
|
62
|
+
/** Map resolution */
|
|
36
63
|
resolution: PropTypes.number,
|
|
64
|
+
/** The tabIndex of the map. */
|
|
37
65
|
tabIndex: PropTypes.number,
|
|
66
|
+
/** The style of the map. */
|
|
38
67
|
style: PropTypes.object,
|
|
68
|
+
/** HTML aria-label. */
|
|
39
69
|
ariaLabel: PropTypes.string,
|
|
70
|
+
/** [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html) constructor options */
|
|
40
71
|
viewOptions: PropTypes.shape({
|
|
41
72
|
minZoom: PropTypes.number,
|
|
42
73
|
maxZoom: PropTypes.number,
|
|
43
74
|
extent: PropTypes.array,
|
|
44
75
|
projection: PropTypes.string
|
|
45
76
|
}),
|
|
77
|
+
/** Map zoom level */
|
|
46
78
|
zoom: PropTypes.number
|
|
47
79
|
};
|
|
48
80
|
const defaultProps = {
|
|
@@ -129,6 +161,12 @@ class BasicMap extends PureComponent {
|
|
|
129
161
|
} = this.props;
|
|
130
162
|
const { node } = this.state;
|
|
131
163
|
if (prevState.node !== node) {
|
|
164
|
+
if (zoom) {
|
|
165
|
+
this.map.getView().setZoom(zoom);
|
|
166
|
+
}
|
|
167
|
+
if (resolution) {
|
|
168
|
+
this.map.getView().setResolution(resolution);
|
|
169
|
+
}
|
|
132
170
|
this.map.setTarget(node);
|
|
133
171
|
if (!prevState.node && node && extent) {
|
|
134
172
|
this.map.getView().fit(extent);
|
|
@@ -256,21 +294,28 @@ class BasicMap extends PureComponent {
|
|
|
256
294
|
render() {
|
|
257
295
|
const { className, tabIndex, ariaLabel, style } = this.props;
|
|
258
296
|
const { node } = this.state;
|
|
259
|
-
return /* @__PURE__ */ React.createElement(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
297
|
+
return /* @__PURE__ */ React.createElement(
|
|
298
|
+
"div",
|
|
299
|
+
{
|
|
300
|
+
className,
|
|
301
|
+
ref: this.setNode,
|
|
302
|
+
role: "presentation",
|
|
303
|
+
"aria-label": ariaLabel,
|
|
304
|
+
tabIndex,
|
|
305
|
+
style
|
|
306
|
+
},
|
|
307
|
+
/* @__PURE__ */ React.createElement(
|
|
308
|
+
ResizeHandler,
|
|
309
|
+
{
|
|
310
|
+
maxHeightBrkpts: null,
|
|
311
|
+
maxWidthBrkpts: null,
|
|
312
|
+
observe: node,
|
|
313
|
+
onResize: () => {
|
|
314
|
+
this.map.updateSize();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
);
|
|
274
319
|
}
|
|
275
320
|
}
|
|
276
321
|
BasicMap.propTypes = propTypes;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/BasicMap/BasicMap.js"],
|
|
4
|
-
"sourcesContent": ["import React, { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\nimport { defaults as defaultInteractions } from 'ol/interaction';\nimport { equals } from 'ol/extent';\nimport OLMap from 'ol/Map';\nimport OLCollection from 'ol/Collection';\nimport View from 'ol/View';\nimport { unByKey } from 'ol/Observable';\nimport Interaction from 'ol/interaction/Interaction';\nimport { Layer } from 'mobility-toolbox-js/ol';\nimport ResizeHandler from '../ResizeHandler';\n\nconst propTypes = {\n /** Map animation options */\n animationOptions: PropTypes.shape({\n center: PropTypes.arrayOf(PropTypes.number),\n resolution: PropTypes.number,\n zoom: PropTypes.number,\n }),\n\n /** Center of the [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html). */\n center: PropTypes.arrayOf(PropTypes.number),\n\n /** Class name of the map container */\n className: PropTypes.string,\n\n /** Map extent */\n extent: PropTypes.arrayOf(PropTypes.number),\n\n /** Openlayers [fit options](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit) when extent is updated */\n fitOptions: PropTypes.object,\n\n /** Array of [ol/interaction](https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html). */\n interactions: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.instanceOf(Interaction)),\n PropTypes.instanceOf(OLCollection),\n ]),\n\n /** Array of [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers) to display. */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */\n map: PropTypes.instanceOf(OLMap),\n\n /**\n * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is clicked.\n * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n * @param {ol.MapBrowserEvent} event The singleclick [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:singleclick).\n */\n onFeaturesClick: PropTypes.func,\n\n /**\n * Optional options to pass on feature click. Passed to ol's 'getFeaturesAtPixel' method.\n * https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html#getFeaturesAtPixel\n */\n featuresClickOptions: PropTypes.shape({\n layerFilter: PropTypes.func,\n hitTolerance: PropTypes.number,\n checkWrapped: PropTypes.bool,\n }),\n\n /**\n * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is hovered.\n * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n * @param {ol.MapBrowserEvent} event The pointermove [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:pointermove).\n */\n onFeaturesHover: PropTypes.func,\n\n /**\n * Callback when the map was moved.\n * @param {ol.MapEvent} event The movend [ol/MapEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:moveend).\n */\n onMapMoved: PropTypes.func,\n\n /** Map resolution */\n resolution: PropTypes.number,\n\n /** The tabIndex of the map. */\n tabIndex: PropTypes.number,\n\n /** The style of the map. */\n style: PropTypes.object,\n\n /** HTML aria-label. */\n ariaLabel: PropTypes.string,\n\n /** [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html) constructor options */\n viewOptions: PropTypes.shape({\n minZoom: PropTypes.number,\n maxZoom: PropTypes.number,\n extent: PropTypes.array,\n projection: PropTypes.string,\n }),\n\n /** Map zoom level */\n zoom: PropTypes.number,\n};\n\nconst defaultProps = {\n animationOptions: undefined,\n center: [0, 0],\n className: 'rs-map',\n extent: undefined,\n fitOptions: {\n duration: 1000,\n padding: [20, 20, 20, 20],\n maxZoom: 23,\n },\n style: undefined,\n interactions: null,\n layers: [],\n map: null,\n onFeaturesClick: undefined,\n featuresClickOptions: {\n hitTolerance: 0,\n },\n onFeaturesHover: undefined,\n onMapMoved: undefined,\n resolution: undefined,\n tabIndex: undefined,\n ariaLabel: 'map',\n viewOptions: {\n minZoom: 0,\n maxZoom: 22,\n extent: undefined,\n projection: 'EPSG:3857',\n },\n zoom: 1,\n};\n\n/**\n * The BasicMap component renders an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n *\n * The map's view is created with the following parameters for the view:\n * - projection: 'EPSG:3857'\n * - zoom: 0\n * - minZoom: 0\n * - maxZoom: 22\n *\n * These options can be overridden using the viewOptions property.\n */\nclass BasicMap extends PureComponent {\n constructor(props) {\n super(props);\n const { map, interactions } = this.props;\n\n this.map =\n map ||\n new OLMap({\n controls: [],\n interactions:\n interactions ||\n defaultInteractions({\n altShiftDragRotate: false,\n pinchRotate: false,\n }),\n });\n\n this.state = {\n node: null,\n };\n\n this.layers = [];\n this.moveEndRef = null;\n this.singleClickRef = null;\n this.pointerMoveRef = null;\n this.setNode = this.setNode.bind(this);\n }\n\n componentDidMount() {\n const { layers, extent, viewOptions, center, zoom, resolution } =\n this.props;\n const { node } = this.state;\n this.map.setTarget(node);\n\n // We set the view here otherwise the map is not correctly zoomed.\n this.map.setView(new View({ ...viewOptions, center, zoom, resolution }));\n\n // // Since ol 6.1.0 touch-action is set to auto and creates a bad navigation experience on mobile,\n // // so we have to force it to none for mobile.\n // // https://github.com/openlayers/openlayers/pull/10187/files\n const viewPort = this.map.getViewport();\n viewPort.style.touchAction = 'none';\n viewPort.style.msTouchAction = 'none';\n viewPort.setAttribute('touch-action', 'none');\n\n // Fit only work if the map has a size.\n if (this.map.getSize() && extent) {\n this.map.getView().fit(extent);\n }\n\n this.setLayers(layers);\n this.listenMoveEnd();\n this.listenSingleClick();\n this.listenPointerMove();\n }\n\n componentDidUpdate(prevProps, prevState) {\n const {\n animationOptions,\n center,\n extent,\n fitOptions,\n layers,\n resolution,\n viewOptions,\n zoom,\n onMapMoved,\n onFeaturesClick,\n onFeaturesHover,\n } = this.props;\n const { node } = this.state;\n\n if (prevState.node !== node) {\n this.map.setTarget(node);\n\n // When the node is set we reinitialize the extent with the extent property.\n if (!prevState.node && node && extent) {\n this.map.getView().fit(extent);\n }\n }\n\n if (prevProps.layers !== layers) {\n this.setLayers(layers, prevProps.layers);\n }\n\n // Creates a new view if necessary before updating the others prop.\n if (\n viewOptions &&\n JSON.stringify(viewOptions) !== JSON.stringify(prevProps.viewOptions)\n ) {\n // Re-create a view, ol doesn't provide any method to setExtent of view.\n this.map.setView(\n new View({\n ...viewOptions,\n center,\n resolution,\n zoom,\n }),\n );\n }\n\n const view = this.map.getView();\n\n if (animationOptions && prevProps.animationOptions !== animationOptions) {\n view.animate(animationOptions);\n }\n\n if (prevProps.center !== center) {\n view.setCenter(center);\n }\n\n if (zoom !== prevProps.zoom) {\n view.setZoom(zoom);\n }\n\n if (resolution !== prevProps.resolution) {\n view.setResolution(resolution);\n }\n\n if (extent && !equals(extent, prevProps.extent || [])) {\n view.fit(extent, fitOptions);\n }\n\n if (onMapMoved !== prevProps.onMapMoved) {\n this.listenMoveEnd();\n }\n\n if (onFeaturesClick !== prevProps.onFeaturesClick) {\n this.listenSingleClick();\n }\n\n if (onFeaturesHover !== prevProps.onFeaturesHover) {\n this.listenPointerMove();\n }\n }\n\n componentWillUnmount() {\n unByKey([this.moveEndRef, this.singleClickRef, this.pointerMoveRef]);\n }\n\n setNode(node) {\n this.setState({ node });\n }\n\n setLayers(layers = [], prevLayers = []) {\n for (let i = 0; i < prevLayers.length; i += 1) {\n this.terminateLayer(prevLayers[i]);\n }\n for (let i = 0; i < layers.length; i += 1) {\n this.initLayer(layers[i]);\n }\n this.layers = layers;\n }\n\n initLayer(layer) {\n if (layer.attachToMap) {\n layer.attachToMap(this.map);\n }\n\n if (layer.init) {\n layer.init(this.map);\n }\n\n if (\n layer.olLayer &&\n this.map.getLayers() &&\n !this.map.getLayers().getArray().includes(layer.olLayer)\n ) {\n this.map.addLayer(layer.olLayer);\n }\n const layers = layer.children || [];\n for (let i = 0; i < layers.length; i += 1) {\n this.initLayer(layers[i]);\n }\n }\n\n terminateLayer(layer) {\n const layers = layer.children || [];\n for (let i = 0; i < layers.length; i += 1) {\n this.terminateLayer(layers[i]);\n }\n\n if (\n layer.olLayer &&\n this.map.getLayers() &&\n this.map.getLayers().getArray().includes(layer.olLayer)\n ) {\n this.map.removeLayer(layer.olLayer);\n }\n\n if (layer.terminate) {\n layer.terminate(this.map);\n }\n\n if (layer.detachFromMap) {\n layer.detachFromMap(this.map);\n }\n }\n\n listenMoveEnd() {\n const { onMapMoved } = this.props;\n unByKey(this.moveEndRef);\n\n if (!onMapMoved) {\n return;\n }\n\n this.moveEndRef = this.map.on('moveend', (evt) => {\n return onMapMoved(evt);\n });\n }\n\n listenSingleClick() {\n const { onFeaturesClick, featuresClickOptions } = this.props;\n unByKey(this.singleClickRef);\n\n if (!onFeaturesClick) {\n return;\n }\n\n this.singleClickRef = this.map.on('singleclick', (evt) => {\n const features = evt.map.getFeaturesAtPixel(\n evt.pixel,\n featuresClickOptions,\n );\n onFeaturesClick(features || [], evt);\n });\n }\n\n listenPointerMove() {\n const { onFeaturesHover } = this.props;\n unByKey(this.pointerMoveRef);\n\n if (!onFeaturesHover) {\n return;\n }\n\n this.pointerMoveRef = this.map.on('pointermove', (evt) => {\n const features = evt.map.getFeaturesAtPixel(evt.pixel);\n onFeaturesHover(features || [], evt);\n });\n }\n\n render() {\n const { className, tabIndex, ariaLabel, style } = this.props;\n const { node } = this.state;\n return (\n <div\n className={className}\n ref={this.setNode}\n role=\"presentation\"\n aria-label={ariaLabel}\n tabIndex={tabIndex}\n style={style}\n >\n <ResizeHandler\n maxHeightBrkpts={null}\n maxWidthBrkpts={null}\n observe={node}\n onResize={() => {\n this.map.updateSize();\n }}\n />\n </div>\n );\n }\n}\n\nBasicMap.propTypes = propTypes;\nBasicMap.defaultProps = defaultProps;\n\nexport default BasicMap;\n"],
|
|
5
|
-
"mappings": "AAAA,OAAO,SAAS,qBAAqB;AACrC,OAAO,eAAe;AACtB,SAAS,YAAY,2BAA2B;AAChD,SAAS,cAAc;AACvB,OAAO,WAAW;AAClB,OAAO,kBAAkB;AACzB,OAAO,UAAU;AACjB,SAAS,eAAe;AACxB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AQ,UAAU,UAAU,CAAC,CAAC,GAAG;AACrD,WAAK,IAAI,QAAQ,UAAU;AAAA,IAC7B;AAEA,QAAI,eAAe,UAAU,YAAY;AACvC,WAAK,cAAc;AAAA,IACrB;AAEA,QAAI,oBAAoB,UAAU,iBAAiB;AACjD,WAAK,kBAAkB;AAAA,IACzB;AAEA,QAAI,oBAAoB,UAAU,iBAAiB;AACjD,WAAK,kBAAkB;AAAA,IACzB;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,YAAQ,CAAC,KAAK,YAAY,KAAK,gBAAgB,KAAK,cAAc,CAAC;AAAA,EACrE;AAAA,EAEA,QAAQ,MAAM;AACZ,SAAK,SAAS,EAAE,KAAK,CAAC;AAAA,EACxB;AAAA,EAEA,UAAU,SAAS,CAAC,GAAG,aAAa,CAAC,GAAG;AACtC,aAAS,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK,GAAG;AAC7C,WAAK,eAAe,WAAW,
|
|
4
|
+
"sourcesContent": ["import React, { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\nimport { defaults as defaultInteractions } from 'ol/interaction';\nimport { equals } from 'ol/extent';\nimport OLMap from 'ol/Map';\nimport OLCollection from 'ol/Collection';\nimport View from 'ol/View';\nimport { unByKey } from 'ol/Observable';\nimport Interaction from 'ol/interaction/Interaction';\nimport { Layer } from 'mobility-toolbox-js/ol';\nimport ResizeHandler from '../ResizeHandler';\n\nconst propTypes = {\n /** Map animation options */\n animationOptions: PropTypes.shape({\n center: PropTypes.arrayOf(PropTypes.number),\n resolution: PropTypes.number,\n zoom: PropTypes.number,\n }),\n\n /** Center of the [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html). */\n center: PropTypes.arrayOf(PropTypes.number),\n\n /** Class name of the map container */\n className: PropTypes.string,\n\n /** Map extent */\n extent: PropTypes.arrayOf(PropTypes.number),\n\n /** Openlayers [fit options](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit) when extent is updated */\n fitOptions: PropTypes.object,\n\n /** Array of [ol/interaction](https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html). */\n interactions: PropTypes.oneOfType([\n PropTypes.arrayOf(PropTypes.instanceOf(Interaction)),\n PropTypes.instanceOf(OLCollection),\n ]),\n\n /** Array of [mobility-toolbox-js layers](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers) to display. */\n layers: PropTypes.arrayOf(PropTypes.instanceOf(Layer)),\n\n /** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */\n map: PropTypes.instanceOf(OLMap),\n\n /**\n * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is clicked.\n * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n * @param {ol.MapBrowserEvent} event The singleclick [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:singleclick).\n */\n onFeaturesClick: PropTypes.func,\n\n /**\n * Optional options to pass on feature click. Passed to ol's 'getFeaturesAtPixel' method.\n * https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html#getFeaturesAtPixel\n */\n featuresClickOptions: PropTypes.shape({\n layerFilter: PropTypes.func,\n hitTolerance: PropTypes.number,\n checkWrapped: PropTypes.bool,\n }),\n\n /**\n * Callback when a [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html) is hovered.\n * @param {OLFeature[]} features An array of [ol/Feature](https://openlayers.org/en/latest/apidoc/module-ol_Feature-Feature.html).\n * @param {ol.MapBrowserEvent} event The pointermove [ol/MapBrowserEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:pointermove).\n */\n onFeaturesHover: PropTypes.func,\n\n /**\n * Callback when the map was moved.\n * @param {ol.MapEvent} event The movend [ol/MapEvent](https://openlayers.org/en/latest/apidoc/module-ol_MapBrowserEvent-MapBrowserEvent.html#event:moveend).\n */\n onMapMoved: PropTypes.func,\n\n /** Map resolution */\n resolution: PropTypes.number,\n\n /** The tabIndex of the map. */\n tabIndex: PropTypes.number,\n\n /** The style of the map. */\n style: PropTypes.object,\n\n /** HTML aria-label. */\n ariaLabel: PropTypes.string,\n\n /** [ol/View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html) constructor options */\n viewOptions: PropTypes.shape({\n minZoom: PropTypes.number,\n maxZoom: PropTypes.number,\n extent: PropTypes.array,\n projection: PropTypes.string,\n }),\n\n /** Map zoom level */\n zoom: PropTypes.number,\n};\n\nconst defaultProps = {\n animationOptions: undefined,\n center: [0, 0],\n className: 'rs-map',\n extent: undefined,\n fitOptions: {\n duration: 1000,\n padding: [20, 20, 20, 20],\n maxZoom: 23,\n },\n style: undefined,\n interactions: null,\n layers: [],\n map: null,\n onFeaturesClick: undefined,\n featuresClickOptions: {\n hitTolerance: 0,\n },\n onFeaturesHover: undefined,\n onMapMoved: undefined,\n resolution: undefined,\n tabIndex: undefined,\n ariaLabel: 'map',\n viewOptions: {\n minZoom: 0,\n maxZoom: 22,\n extent: undefined,\n projection: 'EPSG:3857',\n },\n zoom: 1,\n};\n\n/**\n * The BasicMap component renders an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n *\n * The map's view is created with the following parameters for the view:\n * - projection: 'EPSG:3857'\n * - zoom: 0\n * - minZoom: 0\n * - maxZoom: 22\n *\n * These options can be overridden using the viewOptions property.\n */\nclass BasicMap extends PureComponent {\n constructor(props) {\n super(props);\n const { map, interactions } = this.props;\n\n this.map =\n map ||\n new OLMap({\n controls: [],\n interactions:\n interactions ||\n defaultInteractions({\n altShiftDragRotate: false,\n pinchRotate: false,\n }),\n });\n\n this.state = {\n node: null,\n };\n\n this.layers = [];\n this.moveEndRef = null;\n this.singleClickRef = null;\n this.pointerMoveRef = null;\n this.setNode = this.setNode.bind(this);\n }\n\n componentDidMount() {\n const { layers, extent, viewOptions, center, zoom, resolution } =\n this.props;\n const { node } = this.state;\n this.map.setTarget(node);\n\n // We set the view here otherwise the map is not correctly zoomed.\n this.map.setView(new View({ ...viewOptions, center, zoom, resolution }));\n\n // // Since ol 6.1.0 touch-action is set to auto and creates a bad navigation experience on mobile,\n // // so we have to force it to none for mobile.\n // // https://github.com/openlayers/openlayers/pull/10187/files\n const viewPort = this.map.getViewport();\n viewPort.style.touchAction = 'none';\n viewPort.style.msTouchAction = 'none';\n viewPort.setAttribute('touch-action', 'none');\n\n // Fit only work if the map has a size.\n if (this.map.getSize() && extent) {\n this.map.getView().fit(extent);\n }\n\n this.setLayers(layers);\n this.listenMoveEnd();\n this.listenSingleClick();\n this.listenPointerMove();\n }\n\n componentDidUpdate(prevProps, prevState) {\n const {\n animationOptions,\n center,\n extent,\n fitOptions,\n layers,\n resolution,\n viewOptions,\n zoom,\n onMapMoved,\n onFeaturesClick,\n onFeaturesHover,\n } = this.props;\n const { node } = this.state;\n\n if (prevState.node !== node) {\n if (zoom) {\n this.map.getView().setZoom(zoom);\n }\n\n if (resolution) {\n this.map.getView().setResolution(resolution);\n }\n this.map.setTarget(node);\n\n // When the node is set we reinitialize the extent with the extent property.\n if (!prevState.node && node && extent) {\n this.map.getView().fit(extent);\n }\n }\n\n if (prevProps.layers !== layers) {\n this.setLayers(layers, prevProps.layers);\n }\n\n // Creates a new view if necessary before updating the others prop.\n if (\n viewOptions &&\n JSON.stringify(viewOptions) !== JSON.stringify(prevProps.viewOptions)\n ) {\n // Re-create a view, ol doesn't provide any method to setExtent of view.\n this.map.setView(\n new View({\n ...viewOptions,\n center,\n resolution,\n zoom,\n }),\n );\n }\n\n const view = this.map.getView();\n\n if (animationOptions && prevProps.animationOptions !== animationOptions) {\n view.animate(animationOptions);\n }\n\n if (prevProps.center !== center) {\n view.setCenter(center);\n }\n\n if (zoom !== prevProps.zoom) {\n view.setZoom(zoom);\n }\n\n if (resolution !== prevProps.resolution) {\n view.setResolution(resolution);\n }\n\n if (extent && !equals(extent, prevProps.extent || [])) {\n view.fit(extent, fitOptions);\n }\n\n if (onMapMoved !== prevProps.onMapMoved) {\n this.listenMoveEnd();\n }\n\n if (onFeaturesClick !== prevProps.onFeaturesClick) {\n this.listenSingleClick();\n }\n\n if (onFeaturesHover !== prevProps.onFeaturesHover) {\n this.listenPointerMove();\n }\n }\n\n componentWillUnmount() {\n unByKey([this.moveEndRef, this.singleClickRef, this.pointerMoveRef]);\n }\n\n setNode(node) {\n this.setState({ node });\n }\n\n setLayers(layers = [], prevLayers = []) {\n for (let i = 0; i < prevLayers.length; i += 1) {\n this.terminateLayer(prevLayers[i]);\n }\n for (let i = 0; i < layers.length; i += 1) {\n this.initLayer(layers[i]);\n }\n this.layers = layers;\n }\n\n initLayer(layer) {\n if (layer.attachToMap) {\n layer.attachToMap(this.map);\n }\n\n if (layer.init) {\n layer.init(this.map);\n }\n\n if (\n layer.olLayer &&\n this.map.getLayers() &&\n !this.map.getLayers().getArray().includes(layer.olLayer)\n ) {\n this.map.addLayer(layer.olLayer);\n }\n const layers = layer.children || [];\n for (let i = 0; i < layers.length; i += 1) {\n this.initLayer(layers[i]);\n }\n }\n\n terminateLayer(layer) {\n const layers = layer.children || [];\n for (let i = 0; i < layers.length; i += 1) {\n this.terminateLayer(layers[i]);\n }\n\n if (\n layer.olLayer &&\n this.map.getLayers() &&\n this.map.getLayers().getArray().includes(layer.olLayer)\n ) {\n this.map.removeLayer(layer.olLayer);\n }\n\n if (layer.terminate) {\n layer.terminate(this.map);\n }\n\n if (layer.detachFromMap) {\n layer.detachFromMap(this.map);\n }\n }\n\n listenMoveEnd() {\n const { onMapMoved } = this.props;\n unByKey(this.moveEndRef);\n\n if (!onMapMoved) {\n return;\n }\n\n this.moveEndRef = this.map.on('moveend', (evt) => {\n return onMapMoved(evt);\n });\n }\n\n listenSingleClick() {\n const { onFeaturesClick, featuresClickOptions } = this.props;\n unByKey(this.singleClickRef);\n\n if (!onFeaturesClick) {\n return;\n }\n\n this.singleClickRef = this.map.on('singleclick', (evt) => {\n const features = evt.map.getFeaturesAtPixel(\n evt.pixel,\n featuresClickOptions,\n );\n onFeaturesClick(features || [], evt);\n });\n }\n\n listenPointerMove() {\n const { onFeaturesHover } = this.props;\n unByKey(this.pointerMoveRef);\n\n if (!onFeaturesHover) {\n return;\n }\n\n this.pointerMoveRef = this.map.on('pointermove', (evt) => {\n const features = evt.map.getFeaturesAtPixel(evt.pixel);\n onFeaturesHover(features || [], evt);\n });\n }\n\n render() {\n const { className, tabIndex, ariaLabel, style } = this.props;\n const { node } = this.state;\n return (\n <div\n className={className}\n ref={this.setNode}\n role=\"presentation\"\n aria-label={ariaLabel}\n tabIndex={tabIndex}\n style={style}\n >\n <ResizeHandler\n maxHeightBrkpts={null}\n maxWidthBrkpts={null}\n observe={node}\n onResize={() => {\n this.map.updateSize();\n }}\n />\n </div>\n );\n }\n}\n\nBasicMap.propTypes = propTypes;\nBasicMap.defaultProps = defaultProps;\n\nexport default BasicMap;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,SAAS,qBAAqB;AACrC,OAAO,eAAe;AACtB,SAAS,YAAY,2BAA2B;AAChD,SAAS,cAAc;AACvB,OAAO,WAAW;AAClB,OAAO,kBAAkB;AACzB,OAAO,UAAU;AACjB,SAAS,eAAe;AACxB,OAAO,iBAAiB;AACxB,SAAS,aAAa;AACtB,OAAO,mBAAmB;AAE1B,MAAM,YAAY;AAAA;AAAA,EAEhB,kBAAkB,UAAU,MAAM;AAAA,IAChC,QAAQ,UAAU,QAAQ,UAAU,MAAM;AAAA,IAC1C,YAAY,UAAU;AAAA,IACtB,MAAM,UAAU;AAAA,EAClB,CAAC;AAAA;AAAA,EAGD,QAAQ,UAAU,QAAQ,UAAU,MAAM;AAAA;AAAA,EAG1C,WAAW,UAAU;AAAA;AAAA,EAGrB,QAAQ,UAAU,QAAQ,UAAU,MAAM;AAAA;AAAA,EAG1C,YAAY,UAAU;AAAA;AAAA,EAGtB,cAAc,UAAU,UAAU;AAAA,IAChC,UAAU,QA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E,WAAW,UAAU,WAAW,MAAM,IAAI,KAAK;AACvD,UAAM,EAAE,KAAK,IAAI,KAAK;AACtB,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,KAAK,KAAK;AAAA,QACV,MAAK;AAAA,QACL,cAAY;AAAA,QACZ;AAAA,QACA;AAAA;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,iBAAiB;AAAA,UACjB,gBAAgB;AAAA,UAChB,SAAS;AAAA,UACT,UAAU,MAAM;AACd,iBAAK,IAAI,WAAW;AAAA,UACtB;AAAA;AAAA,MACF;AAAA,IACF;AAAA,EAEJ;AACF;AAEA,SAAS,YAAY;AACrB,SAAS,eAAe;AAExB,eAAe;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -11,16 +11,93 @@ const extraDataImgPropType = PropTypes.shape({
|
|
|
11
11
|
rotation: PropTypes.oneOfType([PropTypes.number, PropTypes.func]),
|
|
12
12
|
circled: PropTypes.bool
|
|
13
13
|
});
|
|
14
|
+
const CanvasPatternType = typeof CanvasPattern === "undefined" ? Function : CanvasPattern;
|
|
14
15
|
const propTypes = {
|
|
16
|
+
/**
|
|
17
|
+
* Automatically download the image saved.
|
|
18
|
+
*/
|
|
15
19
|
autoDownload: PropTypes.bool,
|
|
20
|
+
/**
|
|
21
|
+
* Children content of the button.
|
|
22
|
+
*/
|
|
16
23
|
children: PropTypes.node,
|
|
24
|
+
/**
|
|
25
|
+
* Output format of the image.
|
|
26
|
+
*/
|
|
17
27
|
format: PropTypes.oneOf(["image/jpeg", "image/png"]),
|
|
28
|
+
/** An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html). */
|
|
18
29
|
map: PropTypes.instanceOf(OLMap),
|
|
30
|
+
/**
|
|
31
|
+
* Extent for the export. If no extent is given, the whole map is exported.
|
|
32
|
+
*/
|
|
19
33
|
extent: PropTypes.arrayOf(PropTypes.number),
|
|
34
|
+
/**
|
|
35
|
+
* Array of 4 [ol/Coordinate](https://openlayers.org/en/latest/apidoc/module-ol_coordinate.html#~Coordinate).
|
|
36
|
+
* If no coordinates and no extent are given, the whole map is exported.
|
|
37
|
+
* This property must be used to export rotated map.
|
|
38
|
+
* If you don't need to export rotated map the extent property can be used as well.
|
|
39
|
+
* If extent is specified, coordinates property is ignored.
|
|
40
|
+
*/
|
|
20
41
|
coordinates: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
|
|
42
|
+
/**
|
|
43
|
+
* Scale the map for better quality. Possible values: 1, 2 or 3.
|
|
44
|
+
* WARNING: The tiled layer with a WMTS or XYZ source must provides an url
|
|
45
|
+
* for each scale in the config file.
|
|
46
|
+
*/
|
|
21
47
|
scale: PropTypes.number,
|
|
48
|
+
/**
|
|
49
|
+
* Function called before the dowload process begins.
|
|
50
|
+
*/
|
|
22
51
|
onSaveStart: PropTypes.func,
|
|
52
|
+
/**
|
|
53
|
+
* Function called after the dowload process ends.
|
|
54
|
+
*
|
|
55
|
+
* @param {object} error Error message the process fails.
|
|
56
|
+
*/
|
|
23
57
|
onSaveEnd: PropTypes.func,
|
|
58
|
+
/**
|
|
59
|
+
* Extra data, such as copyright, north arrow configuration.
|
|
60
|
+
* All extra data is optional.
|
|
61
|
+
*
|
|
62
|
+
* Example 1:
|
|
63
|
+
*
|
|
64
|
+
{
|
|
65
|
+
copyright: {
|
|
66
|
+
text: 'Example copyright', // Copyright text or function
|
|
67
|
+
font: '10px Arial', // Font, default is '12px Arial'
|
|
68
|
+
fillStyle: 'blue', // Fill style, default is 'black'
|
|
69
|
+
},
|
|
70
|
+
northArrow, // True if the north arrow
|
|
71
|
+
// should be placed with default configuration
|
|
72
|
+
// (default image, rotation=0, circled=false)
|
|
73
|
+
}
|
|
74
|
+
* Example 2:
|
|
75
|
+
*
|
|
76
|
+
{
|
|
77
|
+
northArrow: {
|
|
78
|
+
src: NorthArrowCustom,
|
|
79
|
+
width: 60, // Width in px, default is 80
|
|
80
|
+
height: 100, // Height in px, default is 80
|
|
81
|
+
rotation: 25, // Absolute rotation in degrees as number or function
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
* Example 3:
|
|
86
|
+
*
|
|
87
|
+
{
|
|
88
|
+
copyright: {
|
|
89
|
+
text: () => { // Copyright as function
|
|
90
|
+
return this.copyright;
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
northArrow: {
|
|
94
|
+
rotation: () => { // Rotation as function
|
|
95
|
+
return NorthArrow.radToDeg(this.map.getView().getRotation());
|
|
96
|
+
},
|
|
97
|
+
circled, // Display circle around the north arrow (Does not work for custom src)
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
*/
|
|
24
101
|
extraData: PropTypes.shape({
|
|
25
102
|
logo: extraDataImgPropType,
|
|
26
103
|
northArrow: extraDataImgPropType,
|
|
@@ -30,7 +107,7 @@ const propTypes = {
|
|
|
30
107
|
font: PropTypes.string,
|
|
31
108
|
fillStyle: PropTypes.oneOfType([
|
|
32
109
|
PropTypes.string,
|
|
33
|
-
PropTypes.instanceOf(
|
|
110
|
+
PropTypes.instanceOf(CanvasPatternType)
|
|
34
111
|
]),
|
|
35
112
|
background: PropTypes.bool
|
|
36
113
|
})
|
|
@@ -88,6 +165,7 @@ class CanvasSaveButton extends PureComponent {
|
|
|
88
165
|
const fileExt = format === "image/jpeg" ? "jpg" : "png";
|
|
89
166
|
return `${window.document.title.replace(/ /g, "_").toLowerCase()}.${fileExt}`;
|
|
90
167
|
}
|
|
168
|
+
// Ensure the font size fita with the image width.
|
|
91
169
|
decreaseFontSize(destContext, maxWidth, copyright, scale) {
|
|
92
170
|
const minFontSize = 8;
|
|
93
171
|
let sizeMatch;
|
|
@@ -102,6 +180,7 @@ class CanvasSaveButton extends PureComponent {
|
|
|
102
180
|
} while (fontSize - 1 > minFontSize && destContext.measureText(copyright).width * scale > maxWidth);
|
|
103
181
|
return destContext.font;
|
|
104
182
|
}
|
|
183
|
+
// eslint-disable-next-line class-methods-use-this
|
|
105
184
|
drawTextBackground(destContext, textMeasure, textX, textY, padding, styleOptions = {}) {
|
|
106
185
|
const { width, height, actualBoundingBoxAscent } = textMeasure;
|
|
107
186
|
destContext.save();
|
|
@@ -380,18 +459,22 @@ class CanvasSaveButton extends PureComponent {
|
|
|
380
459
|
delete other.coordinates;
|
|
381
460
|
delete other.autoDownload;
|
|
382
461
|
delete other.scale;
|
|
383
|
-
return /* @__PURE__ */ React.createElement(
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
462
|
+
return /* @__PURE__ */ React.createElement(
|
|
463
|
+
"div",
|
|
464
|
+
{
|
|
465
|
+
role: "button",
|
|
466
|
+
className: "rs-canvas-save-button",
|
|
467
|
+
tabIndex: 0,
|
|
468
|
+
...other,
|
|
469
|
+
onClick: (e) => {
|
|
470
|
+
return this.onClick(e);
|
|
471
|
+
},
|
|
472
|
+
onKeyPress: (e) => {
|
|
473
|
+
return e.which === 13 && this.onClick(e);
|
|
474
|
+
}
|
|
390
475
|
},
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
}, children);
|
|
476
|
+
children
|
|
477
|
+
);
|
|
395
478
|
}
|
|
396
479
|
}
|
|
397
480
|
CanvasSaveButton.propTypes = propTypes;
|