react-spatial 2.0.0-beta.6 → 2.0.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.
@@ -0,0 +1,43 @@
1
+ import OLControl from "ol/control/Control";
2
+ import OLMap from "ol/Map";
3
+ import PropTypes from "prop-types";
4
+ import React, { useEffect, useRef } from "react";
5
+ const propTypes = {
6
+ /**
7
+ * The class of the control to be created.
8
+ */
9
+ ControlClass: PropTypes.instanceOf(OLControl),
10
+ /**
11
+ * ol/map.
12
+ */
13
+ map: PropTypes.instanceOf(OLMap).isRequired,
14
+ /**
15
+ * Options for ol/control/Control.
16
+ * See https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-Control.html
17
+ */
18
+ options: PropTypes.object
19
+ };
20
+ const defaultProps = {
21
+ options: {}
22
+ };
23
+ function Control({
24
+ ControlClass,
25
+ map,
26
+ options = defaultProps.options,
27
+ ...other
28
+ }) {
29
+ const ref = useRef();
30
+ useEffect(() => {
31
+ const control = new ControlClass({
32
+ ...options,
33
+ ...{ target: ref.current }
34
+ });
35
+ map.addControl(control);
36
+ return () => {
37
+ map.removeControl(control);
38
+ };
39
+ }, [ControlClass, map, options]);
40
+ return /* @__PURE__ */ React.createElement("div", { ref, ...other });
41
+ }
42
+ Control.propTypes = propTypes;
43
+ export default React.memo(Control);
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Control/Control.js"],
4
+ "sourcesContent": ["import OLControl from \"ol/control/Control\";\nimport OLMap from \"ol/Map\";\nimport PropTypes from \"prop-types\";\nimport React, { useEffect, useRef } from \"react\";\n\nconst propTypes = {\n /**\n * The class of the control to be created.\n */\n ControlClass: PropTypes.instanceOf(OLControl),\n\n /**\n * ol/map.\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n\n /**\n * Options for ol/control/Control.\n * See https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-Control.html\n */\n options: PropTypes.object,\n};\n\nconst defaultProps = {\n options: {},\n};\n\n/**\n * The Control component creates an\n * [ol/control/Control](https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-Control.html)\n * for an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction Control({\n ControlClass,\n map,\n options = defaultProps.options,\n ...other\n}) {\n const ref = useRef();\n\n useEffect(() => {\n const control = new ControlClass({\n ...options,\n ...{ target: ref.current },\n });\n\n map.addControl(control);\n return () => {\n map.removeControl(control);\n };\n }, [ControlClass, map, options]);\n\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <div ref={ref} {...other} />;\n}\n\nControl.propTypes = propTypes;\n\nexport default React.memo(Control);\n"],
5
+ "mappings": "AAAA,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,SAAS,WAAW,cAAc;AAEzC,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,cAAc,UAAU,WAAW,SAAS;AAAA;AAAA;AAAA;AAAA,EAK5C,KAAK,UAAU,WAAW,KAAK,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjC,SAAS,UAAU;AACrB;AAEA,MAAM,eAAe;AAAA,EACnB,SAAS,CAAC;AACZ;AAOA,SAAS,QAAQ;AAAA,EACf;AAAA,EACA;AAAA,EACA,UAAU,aAAa;AAAA,EACvB,GAAG;AACL,GAAG;AACD,QAAM,MAAM,OAAO;AAEnB,YAAU,MAAM;AACd,UAAM,UAAU,IAAI,aAAa;AAAA,MAC/B,GAAG;AAAA,MACH,GAAG,EAAE,QAAQ,IAAI,QAAQ;AAAA,IAC3B,CAAC;AAED,QAAI,WAAW,OAAO;AACtB,WAAO,MAAM;AACX,UAAI,cAAc,OAAO;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,cAAc,KAAK,OAAO,CAAC;AAG/B,SAAO,oCAAC,SAAI,KAAW,GAAG,OAAO;AACnC;AAEA,QAAQ,YAAY;AAEpB,eAAe,MAAM,KAAK,OAAO;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./Control";
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/Control/index.js"],
4
+ "sourcesContent": ["export { default } from \"./Control\";\n"],
5
+ "mappings": "AAAA,SAAS,eAAe;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "react-spatial",
3
3
  "license": "MIT",
4
4
  "description": "Components to build React map apps.",
5
- "version": "2.0.0-beta.6",
5
+ "version": "2.0.0",
6
6
  "dependencies": {
7
7
  "@emotion/react": "^11.14.0",
8
8
  "@emotion/styled": "^11.14.1",