react-spatial 2.0.0-beta.1 → 2.0.0-beta.2
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/README.md +5 -10
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +243 -220
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -1
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.scss +6 -5
- package/components/BaseLayerSwitcher/index.js +1 -3
- package/components/BaseLayerSwitcher/index.js.map +7 -1
- package/components/BasicMap/BasicMap.js +165 -285
- package/components/BasicMap/BasicMap.js.map +7 -1
- package/components/BasicMap/index.js +1 -3
- package/components/BasicMap/index.js.map +7 -1
- package/components/CanvasSaveButton/CanvasSaveButton.js +434 -556
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -1
- package/components/CanvasSaveButton/CanvasSaveButton.md.scss +1 -1
- package/components/CanvasSaveButton/index.js +1 -3
- package/components/CanvasSaveButton/index.js.map +7 -1
- package/components/Copyright/Copyright.js +44 -77
- package/components/Copyright/Copyright.js.map +7 -1
- package/components/Copyright/index.js +1 -3
- package/components/Copyright/index.js.map +7 -1
- package/components/FeatureExportButton/FeatureExportButton.js +44 -92
- package/components/FeatureExportButton/FeatureExportButton.js.map +7 -1
- package/components/FeatureExportButton/index.js +1 -3
- package/components/FeatureExportButton/index.js.map +7 -1
- package/components/FitExtent/FitExtent.js +31 -46
- package/components/FitExtent/FitExtent.js.map +7 -1
- package/components/FitExtent/index.js +1 -3
- package/components/FitExtent/index.js.map +7 -1
- package/components/Geolocation/Geolocation.js +158 -228
- package/components/Geolocation/Geolocation.js.map +7 -1
- package/components/Geolocation/Geolocation.scss +7 -5
- package/components/Geolocation/index.js +1 -3
- package/components/Geolocation/index.js.map +7 -1
- package/components/LayerTree/LayerTree.js +359 -357
- package/components/LayerTree/LayerTree.js.map +7 -1
- package/components/LayerTree/LayerTree.scss +4 -6
- package/components/LayerTree/index.js +1 -3
- package/components/LayerTree/index.js.map +7 -1
- package/components/MousePosition/MousePosition.js +71 -109
- package/components/MousePosition/MousePosition.js.map +7 -1
- package/components/MousePosition/index.js +1 -3
- package/components/MousePosition/index.js.map +7 -1
- package/components/NorthArrow/NorthArrow.js +37 -61
- package/components/NorthArrow/NorthArrow.js.map +7 -1
- package/components/NorthArrow/index.js +1 -3
- package/components/NorthArrow/index.js.map +7 -1
- package/components/Overlay/Overlay.js +93 -123
- package/components/Overlay/Overlay.js.map +7 -1
- package/components/Overlay/index.js +1 -3
- package/components/Overlay/index.js.map +7 -1
- package/components/Permalink/Permalink.js +194 -229
- package/components/Permalink/Permalink.js.map +7 -1
- package/components/Permalink/index.js +1 -3
- package/components/Permalink/index.js.map +7 -1
- package/components/Popup/Popup.js +139 -215
- package/components/Popup/Popup.js.map +7 -1
- package/components/Popup/Popup.md.scss +1 -0
- package/components/Popup/Popup.scss +3 -1
- package/components/Popup/index.js +1 -3
- package/components/Popup/index.js.map +7 -1
- package/components/ResizeHandler/ResizeHandler.js +88 -137
- package/components/ResizeHandler/ResizeHandler.js.map +7 -1
- package/components/ResizeHandler/index.js +1 -3
- package/components/ResizeHandler/index.js.map +7 -1
- package/components/RouteSchedule/RouteSchedule.js +227 -277
- package/components/RouteSchedule/RouteSchedule.js.map +7 -1
- package/components/RouteSchedule/RouteSchedule.md.scss +4 -2
- package/components/RouteSchedule/RouteSchedule.scss +12 -23
- package/components/RouteSchedule/index.js +1 -3
- package/components/RouteSchedule/index.js.map +7 -1
- package/components/ScaleLine/ScaleLine.js +17 -39
- package/components/ScaleLine/ScaleLine.js.map +7 -1
- package/components/ScaleLine/ScaleLine.scss +6 -4
- package/components/ScaleLine/index.js +1 -3
- package/components/ScaleLine/index.js.map +7 -1
- package/components/StopsFinder/StopsFinder.js +134 -162
- package/components/StopsFinder/StopsFinder.js.map +7 -1
- package/components/StopsFinder/StopsFinderOption.js +30 -60
- package/components/StopsFinder/StopsFinderOption.js.map +7 -1
- package/components/StopsFinder/index.js +1 -3
- package/components/StopsFinder/index.js.map +7 -1
- package/components/Zoom/Zoom.js +102 -106
- package/components/Zoom/Zoom.js.map +7 -1
- package/components/Zoom/Zoom.md.scss +3 -1
- package/components/Zoom/Zoom.scss +7 -5
- package/components/Zoom/index.js +1 -3
- package/components/Zoom/index.js.map +7 -1
- package/images/geops_qr.png +0 -0
- package/package.json +88 -182
- package/propTypes.js +36 -24
- package/propTypes.js.map +7 -1
- package/setupTests.js +21 -4
- package/setupTests.js.map +7 -1
- package/themes/README.md +26 -0
- package/themes/default/components.scss +9 -14
- package/themes/default/examples.scss +20 -20
- package/themes/default/index.scss +3 -3
- package/themes/default/mixins.scss +7 -5
- package/themes/default/variables.scss +27 -25
- package/utils/GlobalsForOle.js +72 -73
- package/utils/GlobalsForOle.js.map +7 -1
- package/utils/KML.js +320 -381
- package/utils/KML.js.map +7 -1
- package/utils/Styles.js +25 -33
- package/utils/Styles.js.map +7 -1
- package/utils/getLayersAsFlatArray.js +14 -0
- package/utils/getLayersAsFlatArray.js.map +7 -0
- package/utils/getPolygonPattern.js +11 -44
- package/utils/getPolygonPattern.js.map +7 -1
- package/utils/timeUtils.js +20 -35
- package/utils/timeUtils.js.map +7 -1
- package/LayerService.js +0 -193
- package/LayerService.js.map +0 -1
- package/LayerService.test.js +0 -160
- package/LayerService.test.js.map +0 -1
- package/Projections.js +0 -16
- package/Projections.js.map +0 -1
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -88
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js.map +0 -1
- package/components/BaseLayerToggler/BaseLayerToggler.js +0 -490
- package/components/BaseLayerToggler/BaseLayerToggler.js.map +0 -1
- package/components/BaseLayerToggler/BaseLayerToggler.md.scss +0 -9
- package/components/BaseLayerToggler/BaseLayerToggler.scss +0 -49
- package/components/BaseLayerToggler/BaseLayerToggler.test.js +0 -127
- package/components/BaseLayerToggler/BaseLayerToggler.test.js.map +0 -1
- package/components/BaseLayerToggler/index.js +0 -3
- package/components/BaseLayerToggler/index.js.map +0 -1
- package/components/BasicMap/BasicMap.test.js +0 -288
- package/components/BasicMap/BasicMap.test.js.map +0 -1
- package/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -173
- package/components/CanvasSaveButton/CanvasSaveButton.test.js.map +0 -1
- package/components/Copyright/Copyright.test.js +0 -133
- package/components/Copyright/Copyright.test.js.map +0 -1
- package/components/FeatureExportButton/FeatureExportButton.test.js +0 -407
- package/components/FeatureExportButton/FeatureExportButton.test.js.map +0 -1
- package/components/FilterButton/FilterButton.js +0 -131
- package/components/FilterButton/FilterButton.js.map +0 -1
- package/components/FilterButton/FilterButton.scss +0 -36
- package/components/FilterButton/FilterButton.test.js +0 -48
- package/components/FilterButton/FilterButton.test.js.map +0 -1
- package/components/FilterButton/index.js +0 -3
- package/components/FilterButton/index.js.map +0 -1
- package/components/FitExtent/FitExtent.test.js +0 -44
- package/components/FitExtent/FitExtent.test.js.map +0 -1
- package/components/FollowButton/FollowButton.js +0 -143
- package/components/FollowButton/FollowButton.js.map +0 -1
- package/components/FollowButton/FollowButton.scss +0 -36
- package/components/FollowButton/FollowButton.test.js +0 -57
- package/components/FollowButton/FollowButton.test.js.map +0 -1
- package/components/FollowButton/index.js +0 -3
- package/components/FollowButton/index.js.map +0 -1
- package/components/Geolocation/Geolocation.test.js +0 -263
- package/components/Geolocation/Geolocation.test.js.map +0 -1
- package/components/LayerTree/LayerTree.test.js +0 -323
- package/components/LayerTree/LayerTree.test.js.map +0 -1
- package/components/MousePosition/MousePosition.test.js +0 -125
- package/components/MousePosition/MousePosition.test.js.map +0 -1
- package/components/NorthArrow/NorthArrow.test.js +0 -106
- package/components/NorthArrow/NorthArrow.test.js.map +0 -1
- package/components/Overlay/Overlay.test.js +0 -145
- package/components/Overlay/Overlay.test.js.map +0 -1
- package/components/Permalink/Permalink.test.js +0 -267
- package/components/Permalink/Permalink.test.js.map +0 -1
- package/components/Popup/Popup.test.js +0 -291
- package/components/Popup/Popup.test.js.map +0 -1
- package/components/ResizeHandler/ResizeHandler.test.js +0 -410
- package/components/ResizeHandler/ResizeHandler.test.js.map +0 -1
- package/components/RouteSchedule/RouteSchedule.test.js +0 -102
- package/components/RouteSchedule/RouteSchedule.test.js.map +0 -1
- package/components/ScaleLine/ScaleLine.test.js +0 -32
- package/components/ScaleLine/ScaleLine.test.js.map +0 -1
- package/components/Search/Search.js +0 -230
- package/components/Search/Search.js.map +0 -1
- package/components/Search/Search.md.scss +0 -4
- package/components/Search/Search.scss +0 -78
- package/components/Search/Search.test.js +0 -15
- package/components/Search/Search.test.js.map +0 -1
- package/components/Search/SearchService.js +0 -72
- package/components/Search/SearchService.js.map +0 -1
- package/components/Search/engines/Engine.js +0 -26
- package/components/Search/engines/Engine.js.map +0 -1
- package/components/Search/engines/StopFinder.js +0 -47
- package/components/Search/engines/StopFinder.js.map +0 -1
- package/components/Search/index.js +0 -6
- package/components/Search/index.js.map +0 -1
- package/components/StopsFinder/StopsFinder.test.js +0 -19
- package/components/StopsFinder/StopsFinder.test.js.map +0 -1
- package/components/TrackerControl/TrackerControl.js +0 -171
- package/components/TrackerControl/TrackerControl.js.map +0 -1
- package/components/TrackerControl/TrackerControl.scss +0 -30
- package/components/TrackerControl/TrackerControl.test.js +0 -17
- package/components/TrackerControl/TrackerControl.test.js.map +0 -1
- package/components/TrackerControl/index.js +0 -3
- package/components/TrackerControl/index.js.map +0 -1
- package/components/Zoom/Zoom.test.js +0 -150
- package/components/Zoom/Zoom.test.js.map +0 -1
- package/images/FilterButton/filter.svg +0 -1
- package/images/FollowButton/follow.svg +0 -1
- package/images/baselayer/osm.baselayer.hot.png +0 -0
- package/images/baselayer/osm.baselayer.png +0 -0
- package/styleguidist/ComponentsList.js +0 -52
- package/styleguidist/ComponentsList.js.map +0 -1
- package/styleguidist/StyleGuide.js +0 -253
- package/styleguidist/StyleGuide.js.map +0 -1
- package/utils/KML.test.js +0 -163
- package/utils/KML.test.js.map +0 -1
- package/utils/KMLFormat.js +0 -105
- package/utils/KMLFormat.js.map +0 -1
- package/utils/KMLFormat.test.js +0 -22
- package/utils/KMLFormat.test.js.map +0 -1
- package/utils/getPolygonPattern.test.js +0 -66
- package/utils/getPolygonPattern.test.js.map +0 -1
- package/utils/timeUtils.test.js +0 -32
- package/utils/timeUtils.test.js.map +0 -1
|
@@ -1,65 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var propTypes = {
|
|
1
|
+
import OLMap from "ol/Map";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import React from "react";
|
|
4
|
+
const propTypes = {
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The extent to be zoomed.
|
|
6
|
+
* Button content.
|
|
14
7
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
children: PropTypes.node.isRequired,
|
|
17
9
|
/**
|
|
18
10
|
* CSS class for the fitExtent button.
|
|
19
11
|
*/
|
|
20
12
|
className: PropTypes.string,
|
|
21
|
-
|
|
22
13
|
/**
|
|
23
|
-
*
|
|
14
|
+
* The extent to be zoomed.
|
|
24
15
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
extent: PropTypes.arrayOf(PropTypes.number).isRequired,
|
|
17
|
+
/**
|
|
18
|
+
* An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
19
|
+
*/
|
|
20
|
+
map: PropTypes.instanceOf(OLMap).isRequired
|
|
30
21
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var className = ref.className;
|
|
40
|
-
var children = ref.children;
|
|
41
|
-
var rest = objectWithoutProperties( ref, ["map", "extent", "className", "children"] );
|
|
42
|
-
var other = rest;
|
|
43
|
-
|
|
44
|
-
var fit = function (evt) {
|
|
22
|
+
function FitExtent({
|
|
23
|
+
children,
|
|
24
|
+
className = "rs-fit-extent",
|
|
25
|
+
extent,
|
|
26
|
+
map,
|
|
27
|
+
...other
|
|
28
|
+
}) {
|
|
29
|
+
const fit = (evt) => {
|
|
45
30
|
if (evt.which && evt.which !== 13) {
|
|
46
31
|
return;
|
|
47
32
|
}
|
|
48
33
|
map.getView().cancelAnimations();
|
|
49
34
|
map.getView().fit(extent, map.getSize());
|
|
50
35
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
36
|
+
return /* @__PURE__ */ React.createElement(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
className,
|
|
40
|
+
onClick: fit,
|
|
41
|
+
onKeyPress: fit,
|
|
42
|
+
role: "button",
|
|
43
|
+
tabIndex: "0",
|
|
44
|
+
...other
|
|
45
|
+
},
|
|
46
|
+
children
|
|
57
47
|
);
|
|
58
48
|
}
|
|
59
|
-
|
|
60
49
|
FitExtent.propTypes = propTypes;
|
|
61
|
-
FitExtent.defaultProps = defaultProps;
|
|
62
|
-
|
|
63
50
|
export default FitExtent;
|
|
64
|
-
|
|
65
|
-
//# sourceMappingURL=FitExtent.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/FitExtent/FitExtent.js"],
|
|
4
|
+
"sourcesContent": ["import OLMap from \"ol/Map\";\nimport PropTypes from \"prop-types\";\nimport React from \"react\";\n\nconst propTypes = {\n /**\n * Button content.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * CSS class for the fitExtent button.\n */\n className: PropTypes.string,\n\n /**\n * The extent to be zoomed.\n */\n extent: PropTypes.arrayOf(PropTypes.number).isRequired,\n\n /**\n * An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\n map: PropTypes.instanceOf(OLMap).isRequired,\n};\n\n/**\n * The FitExtent component creates a button that updates the current extent of\n * an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).\n */\nfunction FitExtent({\n children,\n className = \"rs-fit-extent\",\n extent,\n map,\n ...other\n}) {\n const fit = (evt) => {\n if (evt.which && evt.which !== 13) {\n return;\n }\n map.getView().cancelAnimations();\n map.getView().fit(extent, map.getSize());\n };\n\n return (\n <div\n className={className}\n onClick={fit}\n onKeyPress={fit}\n role=\"button\"\n tabIndex=\"0\"\n // eslint-disable-next-line react/jsx-props-no-spreading\n {...other}\n >\n {children}\n </div>\n );\n}\n\nFitExtent.propTypes = propTypes;\n\nexport default FitExtent;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,WAAW;AAClB,OAAO,eAAe;AACtB,OAAO,WAAW;AAElB,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA,EAIhB,UAAU,UAAU,KAAK;AAAA;AAAA;AAAA;AAAA,EAKzB,WAAW,UAAU;AAAA;AAAA;AAAA;AAAA,EAKrB,QAAQ,UAAU,QAAQ,UAAU,MAAM,EAAE;AAAA;AAAA;AAAA;AAAA,EAK5C,KAAK,UAAU,WAAW,KAAK,EAAE;AACnC;AAMA,SAAS,UAAU;AAAA,EACjB;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,QAAM,MAAM,CAAC,QAAQ;AACnB,QAAI,IAAI,SAAS,IAAI,UAAU,IAAI;AACjC;AAAA,IACF;AACA,QAAI,QAAQ,EAAE,iBAAiB;AAC/B,QAAI,QAAQ,EAAE,IAAI,QAAQ,IAAI,QAAQ,CAAC;AAAA,EACzC;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,SAAS;AAAA,MACT,YAAY;AAAA,MACZ,MAAK;AAAA,MACL,UAAS;AAAA,MAER,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEJ;AAEA,UAAU,YAAY;AAEtB,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/FitExtent/index.js"],
|
|
4
|
+
"sourcesContent": ["export { default } from \"./FitExtent\";\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,233 +1,150 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import OLMap from
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import VectorSource from 'ol/source/Vector';
|
|
17
|
-
|
|
18
|
-
import { FaRegDotCircle } from 'react-icons/fa';
|
|
19
|
-
|
|
20
|
-
var propTypes = {
|
|
1
|
+
import Feature from "ol/Feature";
|
|
2
|
+
import Point from "ol/geom/Point";
|
|
3
|
+
import VectorLayer from "ol/layer/Vector";
|
|
4
|
+
import OLMap from "ol/Map";
|
|
5
|
+
import { unByKey } from "ol/Observable";
|
|
6
|
+
import { transform } from "ol/proj";
|
|
7
|
+
import VectorSource from "ol/source/Vector";
|
|
8
|
+
import Circle from "ol/style/Circle";
|
|
9
|
+
import Fill from "ol/style/Fill";
|
|
10
|
+
import Stroke from "ol/style/Stroke";
|
|
11
|
+
import Style from "ol/style/Style";
|
|
12
|
+
import PropTypes from "prop-types";
|
|
13
|
+
import React, { PureComponent } from "react";
|
|
14
|
+
import { FaRegDotCircle } from "react-icons/fa";
|
|
15
|
+
const propTypes = {
|
|
21
16
|
/**
|
|
22
|
-
*
|
|
17
|
+
* If true, the map will center once on the position then will constantly recenter to the current Position.
|
|
18
|
+
* If false, the map will center once on the position then will never recenter if the position changes.
|
|
23
19
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
alwaysRecenterToPosition: PropTypes.bool,
|
|
26
21
|
/**
|
|
27
22
|
* Children content of the Geolocation button.
|
|
28
23
|
*/
|
|
29
24
|
children: PropTypes.node,
|
|
30
|
-
|
|
25
|
+
/**
|
|
26
|
+
* CSS class of the button.
|
|
27
|
+
*/
|
|
28
|
+
className: PropTypes.string,
|
|
29
|
+
/**
|
|
30
|
+
* Color (Number array with rgb values) or style function.
|
|
31
|
+
* If a color is given, the style is animated.
|
|
32
|
+
*/
|
|
33
|
+
colorOrStyleFunc: PropTypes.oneOfType([
|
|
34
|
+
PropTypes.arrayOf(PropTypes.number),
|
|
35
|
+
PropTypes.func
|
|
36
|
+
]),
|
|
31
37
|
/**
|
|
32
38
|
* An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
33
39
|
*/
|
|
34
40
|
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
35
|
-
|
|
36
41
|
/**
|
|
37
|
-
*
|
|
42
|
+
* If true, the map will never center to the current position
|
|
38
43
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
neverCenterToPosition: PropTypes.bool,
|
|
41
45
|
/**
|
|
42
|
-
*
|
|
46
|
+
* If true, the map is not centered after it has been dragged once.
|
|
43
47
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
noCenterAfterDrag: PropTypes.bool,
|
|
46
49
|
/**
|
|
47
50
|
* Function triggered after the geolocation is activated. Takes the ol/map and the component instance as arguments.
|
|
48
51
|
*/
|
|
49
52
|
onActivate: PropTypes.func,
|
|
50
|
-
|
|
51
53
|
/**
|
|
52
54
|
* Function triggered after the geolocation is deactivated. Takes the ol/map and the component instance as arguments..
|
|
53
55
|
*/
|
|
54
56
|
onDeactivate: PropTypes.func,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* If true, the map is not centered after it has been dragged once.
|
|
58
|
-
*/
|
|
59
|
-
noCenterAfterDrag: PropTypes.bool,
|
|
60
|
-
|
|
61
57
|
/**
|
|
62
|
-
*
|
|
58
|
+
* Function triggered when geolocating is not successful.
|
|
63
59
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
onError: PropTypes.func,
|
|
66
61
|
/**
|
|
67
|
-
*
|
|
68
|
-
* If a color is given, the style is animated.
|
|
62
|
+
* Function triggered after successful geoLocation calls. Takes the ol/map, the current lat/lon coordinate and the component instance as arguments.
|
|
69
63
|
*/
|
|
70
|
-
|
|
71
|
-
PropTypes.arrayOf(PropTypes.number),
|
|
72
|
-
PropTypes.func ]),
|
|
64
|
+
onSuccess: PropTypes.func
|
|
73
65
|
};
|
|
74
|
-
|
|
75
|
-
var defaultProps = {
|
|
76
|
-
className: 'rs-geolocation',
|
|
77
|
-
children: React.createElement( FaRegDotCircle, { focusable: false }),
|
|
78
|
-
onError: function () {},
|
|
79
|
-
onSuccess: function () {},
|
|
80
|
-
onActivate: function () {},
|
|
81
|
-
onDeactivate: function () {},
|
|
82
|
-
noCenterAfterDrag: false,
|
|
66
|
+
const defaultProps = {
|
|
83
67
|
alwaysRecenterToPosition: true,
|
|
68
|
+
children: /* @__PURE__ */ React.createElement(FaRegDotCircle, { focusable: false }),
|
|
69
|
+
className: "rs-geolocation",
|
|
84
70
|
colorOrStyleFunc: [235, 0, 0],
|
|
71
|
+
neverCenterToPosition: false,
|
|
72
|
+
noCenterAfterDrag: false,
|
|
73
|
+
onActivate: () => {
|
|
74
|
+
},
|
|
75
|
+
onDeactivate: () => {
|
|
76
|
+
},
|
|
77
|
+
onError: () => {
|
|
78
|
+
},
|
|
79
|
+
onSuccess: () => {
|
|
80
|
+
}
|
|
85
81
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
* [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
90
|
-
*/
|
|
91
|
-
var Geolocation = /*@__PURE__*/(function (PureComponent) {
|
|
92
|
-
function Geolocation(props) {
|
|
93
|
-
PureComponent.call(this, props);
|
|
94
|
-
|
|
82
|
+
class Geolocation extends PureComponent {
|
|
83
|
+
constructor(props) {
|
|
84
|
+
super(props);
|
|
95
85
|
this.layer = new VectorLayer({
|
|
96
|
-
source: new VectorSource()
|
|
86
|
+
source: new VectorSource()
|
|
97
87
|
});
|
|
98
|
-
|
|
99
88
|
this.isRecenteringToPosition = true;
|
|
100
|
-
|
|
101
89
|
this.state = {
|
|
102
|
-
active: false
|
|
90
|
+
active: false
|
|
103
91
|
};
|
|
104
|
-
this.point =
|
|
92
|
+
this.point = void 0;
|
|
105
93
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Geolocation.prototype = Object.create( PureComponent && PureComponent.prototype );
|
|
109
|
-
Geolocation.prototype.constructor = Geolocation;
|
|
110
|
-
|
|
111
|
-
Geolocation.prototype.componentWillUnmount = function componentWillUnmount () {
|
|
112
|
-
this.deactivate();
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
Geolocation.prototype.toggle = function toggle () {
|
|
116
|
-
var ref = this.state;
|
|
117
|
-
var active = ref.active;
|
|
118
|
-
var ref$1 = this.props;
|
|
119
|
-
var onError = ref$1.onError;
|
|
120
|
-
var geolocation = 'geolocation' in navigator;
|
|
121
|
-
|
|
122
|
-
if (!geolocation) {
|
|
123
|
-
onError();
|
|
124
|
-
} else if (!active) {
|
|
125
|
-
this.activate();
|
|
126
|
-
} else {
|
|
127
|
-
this.deactivate();
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
Geolocation.prototype.error = function error () {
|
|
132
|
-
var ref = this.props;
|
|
133
|
-
var onError = ref.onError;
|
|
134
|
-
|
|
135
|
-
this.deactivate();
|
|
136
|
-
onError();
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
Geolocation.prototype.deactivate = function deactivate () {
|
|
140
|
-
var ref = this.props;
|
|
141
|
-
var map = ref.map;
|
|
142
|
-
var onDeactivate = ref.onDeactivate;
|
|
143
|
-
window.clearInterval(this.interval);
|
|
144
|
-
this.layer.setMap(null);
|
|
145
|
-
navigator.geolocation.clearWatch(this.watch);
|
|
146
|
-
|
|
147
|
-
this.setState({
|
|
148
|
-
active: false,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
this.isRecenteringToPosition = true;
|
|
152
|
-
this.point = undefined;
|
|
153
|
-
onDeactivate(map, this);
|
|
154
|
-
unByKey(this.dragListener);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
Geolocation.prototype.activate = function activate () {
|
|
158
|
-
var this$1 = this;
|
|
159
|
-
|
|
160
|
-
var ref = this.props;
|
|
161
|
-
var map = ref.map;
|
|
162
|
-
var noCenterAfterDrag = ref.noCenterAfterDrag;
|
|
163
|
-
var onActivate = ref.onActivate;
|
|
164
|
-
|
|
94
|
+
activate() {
|
|
95
|
+
const { map, noCenterAfterDrag, onActivate } = this.props;
|
|
165
96
|
this.projection = map.getView().getProjection().getCode();
|
|
166
97
|
this.point = new Point([0, 0]);
|
|
167
98
|
this.highlight();
|
|
168
99
|
this.layer.setMap(map);
|
|
169
100
|
this.setState({ active: true });
|
|
170
|
-
|
|
171
101
|
this.watch = navigator.geolocation.watchPosition(
|
|
172
102
|
this.update.bind(this),
|
|
173
103
|
this.error.bind(this),
|
|
174
104
|
{
|
|
175
|
-
enableHighAccuracy: true
|
|
105
|
+
enableHighAccuracy: true
|
|
176
106
|
}
|
|
177
107
|
);
|
|
178
|
-
|
|
179
108
|
if (noCenterAfterDrag) {
|
|
180
|
-
this.dragListener = map.on(
|
|
181
|
-
this
|
|
109
|
+
this.dragListener = map.on("pointerdrag", () => {
|
|
110
|
+
this.isRecenteringToPosition = false;
|
|
182
111
|
});
|
|
183
112
|
}
|
|
184
|
-
|
|
185
113
|
onActivate(map, this);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
onSuccess(map, [latitude, longitude], this);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
Geolocation.prototype.highlight = function highlight () {
|
|
216
|
-
var ref = this.props;
|
|
217
|
-
var colorOrStyleFunc = ref.colorOrStyleFunc;
|
|
218
|
-
var feature = new Feature({
|
|
219
|
-
geometry: this.point,
|
|
114
|
+
}
|
|
115
|
+
componentWillUnmount() {
|
|
116
|
+
this.deactivate();
|
|
117
|
+
}
|
|
118
|
+
deactivate() {
|
|
119
|
+
const { map, onDeactivate } = this.props;
|
|
120
|
+
window.clearInterval(this.interval);
|
|
121
|
+
this.layer.setMap(null);
|
|
122
|
+
navigator.geolocation.clearWatch(this.watch);
|
|
123
|
+
this.setState({
|
|
124
|
+
active: false
|
|
125
|
+
});
|
|
126
|
+
this.isRecenteringToPosition = true;
|
|
127
|
+
this.point = void 0;
|
|
128
|
+
onDeactivate(map, this);
|
|
129
|
+
unByKey(this.dragListener);
|
|
130
|
+
}
|
|
131
|
+
error(error) {
|
|
132
|
+
const { onError } = this.props;
|
|
133
|
+
this.deactivate();
|
|
134
|
+
onError(error);
|
|
135
|
+
}
|
|
136
|
+
highlight() {
|
|
137
|
+
const { colorOrStyleFunc } = this.props;
|
|
138
|
+
const feature = new Feature({
|
|
139
|
+
geometry: this.point
|
|
220
140
|
});
|
|
221
|
-
|
|
222
141
|
if (Array.isArray(colorOrStyleFunc)) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
var rotation = 0;
|
|
228
|
-
|
|
142
|
+
const color = colorOrStyleFunc;
|
|
143
|
+
let decrease = true;
|
|
144
|
+
let opacity = 0.5;
|
|
145
|
+
let rotation = 0;
|
|
229
146
|
window.clearInterval(this.interval);
|
|
230
|
-
this.interval = window.setInterval(
|
|
147
|
+
this.interval = window.setInterval(() => {
|
|
231
148
|
rotation += 0.03;
|
|
232
149
|
decrease = opacity < 0.1 ? false : decrease;
|
|
233
150
|
decrease = opacity > 0.5 ? true : decrease;
|
|
@@ -236,79 +153,92 @@ var Geolocation = /*@__PURE__*/(function (PureComponent) {
|
|
|
236
153
|
feature.changed();
|
|
237
154
|
}
|
|
238
155
|
}, 50);
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
var circleStyle = new Style({
|
|
156
|
+
feature.setStyle(() => {
|
|
157
|
+
const circleStyle = new Style({
|
|
242
158
|
image: new Circle({
|
|
243
|
-
radius: 20,
|
|
244
|
-
rotation: rotation,
|
|
245
159
|
fill: new Fill({
|
|
246
|
-
color:
|
|
160
|
+
color: "rgba(255, 255, 255, 0.01)"
|
|
247
161
|
}),
|
|
162
|
+
radius: 20,
|
|
163
|
+
rotation,
|
|
248
164
|
stroke: new Stroke({
|
|
165
|
+
color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, ${opacity})`,
|
|
249
166
|
lineDash: [30, 10],
|
|
250
|
-
width: 6
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}),
|
|
167
|
+
width: 6
|
|
168
|
+
})
|
|
169
|
+
})
|
|
254
170
|
});
|
|
255
|
-
|
|
256
171
|
circleStyle.getImage().setRotation(rotation);
|
|
257
|
-
|
|
258
172
|
return [
|
|
259
173
|
new Style({
|
|
260
174
|
image: new Circle({
|
|
261
|
-
radius: 10,
|
|
262
175
|
fill: new Fill({
|
|
263
|
-
color:
|
|
176
|
+
color: `rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.5)`
|
|
264
177
|
}),
|
|
265
|
-
|
|
178
|
+
radius: 10
|
|
179
|
+
})
|
|
266
180
|
}),
|
|
267
|
-
circleStyle
|
|
181
|
+
circleStyle
|
|
182
|
+
];
|
|
268
183
|
});
|
|
269
184
|
} else {
|
|
270
185
|
feature.setStyle(colorOrStyleFunc);
|
|
271
186
|
}
|
|
272
|
-
|
|
273
187
|
this.layer.getSource().clear();
|
|
274
188
|
this.layer.getSource().addFeature(feature);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
var ref = this.props;
|
|
281
|
-
var children = ref.children;
|
|
282
|
-
var className = ref.className;
|
|
283
|
-
// Remove component props from other HTML props.
|
|
284
|
-
var other = Object.entries(this.props).reduce(function (props, ref) {
|
|
285
|
-
var obj;
|
|
286
|
-
|
|
287
|
-
var key = ref[0];
|
|
288
|
-
var value = ref[1];
|
|
289
|
-
return propTypes[key] ? props : Object.assign({}, props, ( obj = {}, obj[key] = value, obj ));
|
|
189
|
+
}
|
|
190
|
+
render() {
|
|
191
|
+
const { children, className } = this.props;
|
|
192
|
+
const other = Object.entries(this.props).reduce((props, [key, value]) => {
|
|
193
|
+
return propTypes[key] ? props : { ...props, [key]: value };
|
|
290
194
|
}, {});
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
return this
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
195
|
+
const { active } = this.state;
|
|
196
|
+
return /* @__PURE__ */ React.createElement(
|
|
197
|
+
"div",
|
|
198
|
+
{
|
|
199
|
+
className: `${className} ${active ? "rs-active" : ""}`,
|
|
200
|
+
onClick: () => {
|
|
201
|
+
return this.toggle();
|
|
202
|
+
},
|
|
203
|
+
onKeyPress: (e) => {
|
|
204
|
+
return e.which === 13 && this.toggle();
|
|
205
|
+
},
|
|
206
|
+
role: "button",
|
|
207
|
+
tabIndex: "0",
|
|
208
|
+
...other
|
|
209
|
+
},
|
|
210
|
+
children
|
|
303
211
|
);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
|
|
212
|
+
}
|
|
213
|
+
toggle() {
|
|
214
|
+
const { active } = this.state;
|
|
215
|
+
const { onError } = this.props;
|
|
216
|
+
const geolocation = "geolocation" in navigator;
|
|
217
|
+
if (!geolocation) {
|
|
218
|
+
onError(new Error("Geolocation not supported"));
|
|
219
|
+
} else if (!active) {
|
|
220
|
+
this.activate();
|
|
221
|
+
} else {
|
|
222
|
+
this.deactivate();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
update({ coords: { latitude, longitude } }) {
|
|
226
|
+
const { alwaysRecenterToPosition, map, neverCenterToPosition, onSuccess } = this.props;
|
|
227
|
+
const position = transform(
|
|
228
|
+
[longitude, latitude],
|
|
229
|
+
"EPSG:4326",
|
|
230
|
+
this.projection
|
|
231
|
+
);
|
|
232
|
+
this.point.setCoordinates(position);
|
|
233
|
+
if (!neverCenterToPosition && this.isRecenteringToPosition) {
|
|
234
|
+
map.getView().setCenter(position);
|
|
235
|
+
if (!alwaysRecenterToPosition) {
|
|
236
|
+
this.isRecenteringToPosition = false;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
onSuccess(map, [latitude, longitude], this);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
309
242
|
Geolocation.propTypes = propTypes;
|
|
310
243
|
Geolocation.defaultProps = defaultProps;
|
|
311
|
-
|
|
312
244
|
export default Geolocation;
|
|
313
|
-
|
|
314
|
-
//# sourceMappingURL=Geolocation.js.map
|