react-spatial 1.5.3 → 1.5.4
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 +231 -0
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -0
- package/components/BaseLayerSwitcher/index.js +1 -0
- package/components/BaseLayerSwitcher/index.js.map +7 -0
- package/components/BasicMap/BasicMap.js +278 -0
- package/components/BasicMap/BasicMap.js.map +7 -0
- package/components/BasicMap/index.js +1 -0
- package/components/BasicMap/index.js.map +7 -0
- package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.js +93 -320
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -0
- package/components/CanvasSaveButton/index.js +1 -0
- package/components/CanvasSaveButton/index.js.map +7 -0
- package/components/Copyright/Copyright.js +55 -0
- package/components/Copyright/Copyright.js.map +7 -0
- package/components/Copyright/index.js +1 -0
- package/components/Copyright/index.js.map +7 -0
- package/components/FeatureExportButton/FeatureExportButton.js +62 -0
- package/components/FeatureExportButton/FeatureExportButton.js.map +7 -0
- package/components/FeatureExportButton/index.js +1 -0
- package/components/FeatureExportButton/index.js.map +7 -0
- package/components/FitExtent/FitExtent.js +32 -0
- package/components/FitExtent/FitExtent.js.map +7 -0
- package/components/FitExtent/index.js +1 -0
- package/components/FitExtent/index.js.map +7 -0
- package/{src/components → components}/Geolocation/Geolocation.js +61 -144
- package/components/Geolocation/Geolocation.js.map +7 -0
- package/components/Geolocation/index.js +1 -0
- package/components/Geolocation/index.js.map +7 -0
- package/components/LayerTree/LayerTree.js +278 -0
- package/components/LayerTree/LayerTree.js.map +7 -0
- package/components/LayerTree/index.js +1 -0
- package/components/LayerTree/index.js.map +7 -0
- package/components/MousePosition/MousePosition.js +110 -0
- package/components/MousePosition/MousePosition.js.map +7 -0
- package/components/MousePosition/index.js +1 -0
- package/components/MousePosition/index.js.map +7 -0
- package/components/NorthArrow/NorthArrow.js +43 -0
- package/components/NorthArrow/NorthArrow.js.map +7 -0
- package/components/NorthArrow/index.js +1 -0
- package/components/NorthArrow/index.js.map +7 -0
- package/components/Overlay/Overlay.js +122 -0
- package/components/Overlay/Overlay.js.map +7 -0
- package/components/Overlay/index.js +1 -0
- package/components/Overlay/index.js.map +7 -0
- package/components/Permalink/Permalink.js +206 -0
- package/components/Permalink/Permalink.js.map +7 -0
- package/components/Permalink/index.js +1 -0
- package/components/Permalink/index.js.map +7 -0
- package/{src/components → components}/Popup/Popup.js +55 -165
- package/components/Popup/Popup.js.map +7 -0
- package/components/Popup/index.js +1 -0
- package/components/Popup/index.js.map +7 -0
- package/{src/components → components}/ResizeHandler/ResizeHandler.js +15 -50
- package/components/ResizeHandler/ResizeHandler.js.map +7 -0
- package/components/ResizeHandler/index.js +1 -0
- package/components/ResizeHandler/index.js.map +7 -0
- package/components/RouteSchedule/RouteSchedule.js +223 -0
- package/components/RouteSchedule/RouteSchedule.js.map +7 -0
- package/components/RouteSchedule/index.js +1 -0
- package/components/RouteSchedule/index.js.map +7 -0
- package/components/ScaleLine/ScaleLine.js +32 -0
- package/components/ScaleLine/ScaleLine.js.map +7 -0
- package/components/ScaleLine/index.js +1 -0
- package/components/ScaleLine/index.js.map +7 -0
- package/components/StopsFinder/StopsFinder.js +210 -0
- package/components/StopsFinder/StopsFinder.js.map +7 -0
- package/components/StopsFinder/StopsFinderOption.js +51 -0
- package/components/StopsFinder/StopsFinderOption.js.map +7 -0
- package/components/StopsFinder/index.js +1 -0
- package/components/StopsFinder/index.js.map +7 -0
- package/components/Zoom/Zoom.js +130 -0
- package/components/Zoom/Zoom.js.map +7 -0
- package/components/Zoom/index.js +1 -0
- package/components/Zoom/index.js.map +7 -0
- package/package.json +1 -1
- package/{src/propTypes.js → propTypes.js} +12 -16
- package/propTypes.js.map +7 -0
- package/{src/setupTests.js → setupTests.js} +1 -1
- package/setupTests.js.map +7 -0
- package/utils/GlobalsForOle.js +94 -0
- package/utils/GlobalsForOle.js.map +7 -0
- package/utils/KML.js +412 -0
- package/utils/KML.js.map +7 -0
- package/utils/KMLFormat.js +69 -0
- package/utils/KMLFormat.js.map +7 -0
- package/{src/utils → utils}/Styles.js +14 -20
- package/utils/Styles.js.map +7 -0
- package/{src/utils → utils}/getPolygonPattern.js +6 -34
- package/utils/getPolygonPattern.js.map +7 -0
- package/{src/utils → utils}/timeUtils.js +5 -22
- package/utils/timeUtils.js.map +7 -0
- package/.github/workflows/conventional-pr-title.yml +0 -21
- package/.github/workflows/main.yml +0 -28
- package/.husky/commit-msg +0 -4
- package/.husky/post-checkout +0 -4
- package/.husky/post-merge +0 -4
- package/.husky/post-rebase +0 -4
- package/.husky/pre-commit +0 -4
- package/.nvmrc +0 -1
- package/.whitesource +0 -8
- package/CHANGELOG.md +0 -65
- package/DEVELOP.md +0 -113
- package/__mocks__/mapbox-gl.js +0 -11
- package/__mocks__/resize-observer-polyfill.js +0 -9
- package/babel.config.js +0 -3
- package/commitlint.config.js +0 -1
- package/data/topic1.js +0 -119
- package/data/topic2.js +0 -28
- package/doc/README.md +0 -21
- package/doc/doc-config.json +0 -4
- package/pull_request_template.md +0 -16
- package/renovate.json +0 -4
- package/scripts/read-pkg-json.js +0 -17
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.js +0 -322
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -69
- package/src/components/BaseLayerSwitcher/README.md +0 -61
- package/src/components/BaseLayerSwitcher/__snapshots__/BaseLayerSwitcher.test.js.snap +0 -88
- package/src/components/BaseLayerSwitcher/index.js +0 -1
- package/src/components/BasicMap/BasicMap.js +0 -413
- package/src/components/BasicMap/BasicMap.test.js +0 -281
- package/src/components/BasicMap/README.md +0 -18
- package/src/components/BasicMap/index.js +0 -1
- package/src/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -148
- package/src/components/CanvasSaveButton/README.md +0 -76
- package/src/components/CanvasSaveButton/__snapshots__/CanvasSaveButton.test.js.snap +0 -76
- package/src/components/CanvasSaveButton/index.js +0 -1
- package/src/components/Copyright/Copyright.js +0 -89
- package/src/components/Copyright/Copyright.test.js +0 -134
- package/src/components/Copyright/README.md +0 -36
- package/src/components/Copyright/index.js +0 -1
- package/src/components/FeatureExportButton/FeatureExportButton.js +0 -118
- package/src/components/FeatureExportButton/FeatureExportButton.test.js +0 -417
- package/src/components/FeatureExportButton/README.md +0 -76
- package/src/components/FeatureExportButton/__snapshots__/FeatureExportButton.test.js.snap +0 -67
- package/src/components/FeatureExportButton/index.js +0 -1
- package/src/components/FitExtent/FitExtent.js +0 -62
- package/src/components/FitExtent/FitExtent.test.js +0 -48
- package/src/components/FitExtent/README.md +0 -34
- package/src/components/FitExtent/__snapshots__/FitExtent.test.js.snap +0 -13
- package/src/components/FitExtent/index.js +0 -1
- package/src/components/Geolocation/Geolocation.test.js +0 -267
- package/src/components/Geolocation/README.md +0 -25
- package/src/components/Geolocation/__snapshots__/Geolocation.test.js.snap +0 -92
- package/src/components/Geolocation/index.js +0 -1
- package/src/components/LayerTree/LayerTree.js +0 -487
- package/src/components/LayerTree/LayerTree.test.js +0 -337
- package/src/components/LayerTree/README.md +0 -92
- package/src/components/LayerTree/__snapshots__/LayerTree.test.js.snap +0 -1746
- package/src/components/LayerTree/index.js +0 -1
- package/src/components/MousePosition/MousePosition.js +0 -175
- package/src/components/MousePosition/MousePosition.test.js +0 -132
- package/src/components/MousePosition/README.md +0 -50
- package/src/components/MousePosition/__snapshots__/MousePosition.test.js.snap +0 -76
- package/src/components/MousePosition/index.js +0 -1
- package/src/components/NorthArrow/NorthArrow.js +0 -75
- package/src/components/NorthArrow/NorthArrow.test.js +0 -104
- package/src/components/NorthArrow/README.md +0 -59
- package/src/components/NorthArrow/__snapshots__/NorthArrow.test.js.snap +0 -117
- package/src/components/NorthArrow/index.js +0 -1
- package/src/components/Overlay/Overlay.js +0 -176
- package/src/components/Overlay/Overlay.test.js +0 -149
- package/src/components/Overlay/README.md +0 -59
- package/src/components/Overlay/__snapshots__/Overlay.test.js.snap +0 -9
- package/src/components/Overlay/index.js +0 -1
- package/src/components/Permalink/Permalink.js +0 -326
- package/src/components/Permalink/Permalink.test.js +0 -285
- package/src/components/Permalink/README.md +0 -105
- package/src/components/Permalink/index.js +0 -1
- package/src/components/Popup/Popup.test.js +0 -307
- package/src/components/Popup/README.md +0 -93
- package/src/components/Popup/__snapshots__/Popup.test.js.snap +0 -180
- package/src/components/Popup/index.js +0 -1
- package/src/components/README.md +0 -41
- package/src/components/ResizeHandler/ResizeHandler.test.js +0 -344
- package/src/components/ResizeHandler/index.js +0 -1
- package/src/components/RouteSchedule/README.md +0 -118
- package/src/components/RouteSchedule/RouteSchedule.js +0 -370
- package/src/components/RouteSchedule/RouteSchedule.test.js +0 -113
- package/src/components/RouteSchedule/__snapshots__/RouteSchedule.test.js.snap +0 -248
- package/src/components/RouteSchedule/index.js +0 -1
- package/src/components/ScaleLine/README.md +0 -29
- package/src/components/ScaleLine/ScaleLine.js +0 -50
- package/src/components/ScaleLine/ScaleLine.test.js +0 -30
- package/src/components/ScaleLine/__snapshots__/ScaleLine.test.js.snap +0 -7
- package/src/components/ScaleLine/index.js +0 -1
- package/src/components/StopsFinder/README.md +0 -50
- package/src/components/StopsFinder/StopsFinder.js +0 -284
- package/src/components/StopsFinder/StopsFinder.test.js +0 -17
- package/src/components/StopsFinder/StopsFinderOption.js +0 -61
- package/src/components/StopsFinder/__snapshots__/StopsFinder.test.js.snap +0 -133
- package/src/components/StopsFinder/index.js +0 -1
- package/src/components/Zoom/README.md +0 -25
- package/src/components/Zoom/Zoom.js +0 -180
- package/src/components/Zoom/Zoom.test.js +0 -141
- package/src/components/Zoom/__snapshots__/Zoom.test.js.snap +0 -201
- package/src/components/Zoom/index.js +0 -1
- package/src/styleguidist/ComponentsList.js +0 -52
- package/src/styleguidist/StyleGuide.js +0 -277
- package/src/styleguidist/styleguidist.css +0 -38
- package/src/utils/GlobalsForOle.js +0 -99
- package/src/utils/KML.js +0 -594
- package/src/utils/KML.test.js +0 -337
- package/src/utils/KMLFormat.js +0 -100
- package/src/utils/KMLFormat.test.js +0 -50
- package/src/utils/__snapshots__/KML.test.js.snap.KML-readFeatures()-and-writeFeatures()-should-read-and-write-lineDash-and-fillPattern-style-for-polygon.canvas-image.png +0 -0
- package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-2-(cross)-color-and-(light-blue)-opacity.canvas-image.png +0 -0
- package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-3-(diagonal-line-from-bottom-left-tot-top-right)-with-color-(light-blue)-and-opacity.canvas-image.png +0 -0
- package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-4-(diagonal-line-from-top-left-to-bottom-right)-with-color-(light-blue)-and-opacity.canvas-image.png +0 -0
- package/src/utils/getPolygonPattern.test.js +0 -61
- package/src/utils/timeUtils.test.js +0 -30
- package/styleguide.config.js +0 -251
- /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.md.scss +0 -0
- /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.scss +0 -0
- /package/{src/components → components}/BasicMap/BasicMap.md.scss +0 -0
- /package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.md.scss +0 -0
- /package/{src/components → components}/Copyright/Copyright.md.scss +0 -0
- /package/{src/components → components}/FeatureExportButton/FeatureExportButton.md.scss +0 -0
- /package/{src/components → components}/FitExtent/FitExtent.md.scss +0 -0
- /package/{src/components → components}/Geolocation/Geolocation.md.scss +0 -0
- /package/{src/components → components}/Geolocation/Geolocation.scss +0 -0
- /package/{src/components → components}/LayerTree/LayerTree.md.scss +0 -0
- /package/{src/components → components}/LayerTree/LayerTree.scss +0 -0
- /package/{src/components → components}/MousePosition/MousePosition.md.scss +0 -0
- /package/{src/components → components}/NorthArrow/NorthArrow.scss +0 -0
- /package/{src/components → components}/Overlay/Overlay.md.scss +0 -0
- /package/{src/components → components}/Overlay/Overlay.scss +0 -0
- /package/{src/components → components}/Permalink/Permalink.md.scss +0 -0
- /package/{src/components → components}/Popup/Popup.md.scss +0 -0
- /package/{src/components → components}/Popup/Popup.scss +0 -0
- /package/{src/components → components}/RouteSchedule/RouteSchedule.md.scss +0 -0
- /package/{src/components → components}/RouteSchedule/RouteSchedule.scss +0 -0
- /package/{src/components → components}/ScaleLine/ScaleLine.scss +0 -0
- /package/{src/components → components}/Zoom/Zoom.md.scss +0 -0
- /package/{src/components → components}/Zoom/Zoom.scss +0 -0
- /package/{src/images → images}/RouteSchedule/firstStation.png +0 -0
- /package/{src/images → images}/RouteSchedule/lastStation.png +0 -0
- /package/{src/images → images}/RouteSchedule/line.png +0 -0
- /package/{src/images → images}/RouteSchedule/station.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.basebright.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.osm.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.travic.png +0 -0
- /package/{src/images → images}/baselayer/open.topo.map.png +0 -0
- /package/{src/images → images}/baselayer/osm.baselayer.hot.png +0 -0
- /package/{src/images → images}/baselayer/osm.baselayer.png +0 -0
- /package/{src/images → images}/favicon.png +0 -0
- /package/{src/images → images}/geops_logo.png +0 -0
- /package/{src/images → images}/geops_logo.svg +0 -0
- /package/{src/images → images}/geops_qr.png +0 -0
- /package/{src/images → images}/mots/bus_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/bus_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/bus_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/gondola_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/rail_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/rail_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/subway_round blue-01.svg +0 -0
- /package/{src/images → images}/mots/subway_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/tram_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/tram_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_square-grey-01.svg +0 -0
- /package/{src/images → images}/northArrow.svg +0 -0
- /package/{src/images → images}/northArrow.url.svg +0 -0
- /package/{src/images → images}/northArrowCircle.svg +0 -0
- /package/{src/images → images}/northArrowCircle.url.svg +0 -0
- /package/{src/themes → themes}/README.md +0 -0
- /package/{src/themes → themes}/default/components.scss +0 -0
- /package/{src/themes → themes}/default/examples.scss +0 -0
- /package/{src/themes → themes}/default/index.scss +0 -0
- /package/{src/themes → themes}/default/mixins.scss +0 -0
- /package/{src/themes → themes}/default/variables.scss +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
import { Map } from 'ol';
|
|
4
|
-
import StopsFinder from '.';
|
|
5
|
-
|
|
6
|
-
describe('StopsFinder', () => {
|
|
7
|
-
let map;
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
map = new Map({});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('matches snapshots.', () => {
|
|
14
|
-
const component = renderer.create(<StopsFinder map={map} />);
|
|
15
|
-
expect(component.toJSON()).toMatchSnapshot();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import React, { lazy, Suspense } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { makeStyles } from '@material-ui/core';
|
|
4
|
-
|
|
5
|
-
const ext = '_round-blue-01.svg';
|
|
6
|
-
const iconForMot = {};
|
|
7
|
-
[
|
|
8
|
-
'bus',
|
|
9
|
-
'ferry',
|
|
10
|
-
'gondola',
|
|
11
|
-
'tram',
|
|
12
|
-
'rail',
|
|
13
|
-
'funicular',
|
|
14
|
-
'cable_car',
|
|
15
|
-
'subway',
|
|
16
|
-
].forEach((mot) => {
|
|
17
|
-
iconForMot[mot] = lazy(() => {
|
|
18
|
-
return import(`../../images/mots/${mot}${ext}`);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const useStyles = makeStyles((theme) => {
|
|
23
|
-
return {
|
|
24
|
-
flex: {
|
|
25
|
-
display: 'flex',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
},
|
|
28
|
-
icon: {
|
|
29
|
-
marginRight: theme.spacing(2),
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
function StopsFinderOption({ option }) {
|
|
35
|
-
const classes = useStyles();
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Suspense fallback={<div />}>
|
|
39
|
-
<div className={classes.flex}>
|
|
40
|
-
{Object.entries(option.properties.mot).map(([key, value]) => {
|
|
41
|
-
if (value) {
|
|
42
|
-
const MotIcon = iconForMot[key];
|
|
43
|
-
return (
|
|
44
|
-
<span className={classes.icon} key={key}>
|
|
45
|
-
<MotIcon />
|
|
46
|
-
</span>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return <></>;
|
|
50
|
-
})}
|
|
51
|
-
<span>{option.properties.name}</span>
|
|
52
|
-
</div>
|
|
53
|
-
</Suspense>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
StopsFinderOption.propTypes = {
|
|
58
|
-
option: PropTypes.object.isRequired,
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default React.memo(StopsFinderOption);
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`StopsFinder matches snapshots. 1`] = `
|
|
4
|
-
<div
|
|
5
|
-
aria-expanded={false}
|
|
6
|
-
aria-owns={null}
|
|
7
|
-
className="MuiAutocomplete-root MuiAutocomplete-fullWidth MuiAutocomplete-hasClearIcon MuiAutocomplete-hasPopupIcon"
|
|
8
|
-
onClick={[Function]}
|
|
9
|
-
onKeyDown={[Function]}
|
|
10
|
-
onMouseDown={[Function]}
|
|
11
|
-
role="combobox"
|
|
12
|
-
>
|
|
13
|
-
<div
|
|
14
|
-
className="MuiFormControl-root MuiTextField-root MuiFormControl-fullWidth"
|
|
15
|
-
>
|
|
16
|
-
<label
|
|
17
|
-
className="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated"
|
|
18
|
-
data-shrink={false}
|
|
19
|
-
id="undefined-label"
|
|
20
|
-
>
|
|
21
|
-
Search stops
|
|
22
|
-
</label>
|
|
23
|
-
<div
|
|
24
|
-
className="MuiInputBase-root MuiInput-root MuiInput-underline MuiAutocomplete-inputRoot MuiInputBase-fullWidth MuiInput-fullWidth MuiInputBase-formControl MuiInput-formControl MuiInputBase-adornedEnd"
|
|
25
|
-
onClick={[Function]}
|
|
26
|
-
>
|
|
27
|
-
<input
|
|
28
|
-
aria-activedescendant={null}
|
|
29
|
-
aria-autocomplete="both"
|
|
30
|
-
aria-controls={null}
|
|
31
|
-
aria-invalid={false}
|
|
32
|
-
autoCapitalize="none"
|
|
33
|
-
autoComplete="off"
|
|
34
|
-
autoFocus={false}
|
|
35
|
-
className="MuiInputBase-input MuiInput-input MuiAutocomplete-input MuiAutocomplete-inputFocused MuiInputBase-inputAdornedEnd"
|
|
36
|
-
disabled={false}
|
|
37
|
-
onAnimationStart={[Function]}
|
|
38
|
-
onBlur={[Function]}
|
|
39
|
-
onChange={[Function]}
|
|
40
|
-
onFocus={[Function]}
|
|
41
|
-
onMouseDown={[Function]}
|
|
42
|
-
required={false}
|
|
43
|
-
spellCheck="false"
|
|
44
|
-
type="text"
|
|
45
|
-
value=""
|
|
46
|
-
/>
|
|
47
|
-
<div
|
|
48
|
-
className="MuiAutocomplete-endAdornment"
|
|
49
|
-
>
|
|
50
|
-
<button
|
|
51
|
-
aria-label="Clear"
|
|
52
|
-
className="MuiButtonBase-root MuiIconButton-root MuiAutocomplete-clearIndicator"
|
|
53
|
-
disabled={false}
|
|
54
|
-
onBlur={[Function]}
|
|
55
|
-
onClick={[Function]}
|
|
56
|
-
onDragLeave={[Function]}
|
|
57
|
-
onFocus={[Function]}
|
|
58
|
-
onKeyDown={[Function]}
|
|
59
|
-
onKeyUp={[Function]}
|
|
60
|
-
onMouseDown={[Function]}
|
|
61
|
-
onMouseLeave={[Function]}
|
|
62
|
-
onMouseUp={[Function]}
|
|
63
|
-
onTouchEnd={[Function]}
|
|
64
|
-
onTouchMove={[Function]}
|
|
65
|
-
onTouchStart={[Function]}
|
|
66
|
-
tabIndex={-1}
|
|
67
|
-
title="Clear"
|
|
68
|
-
type="button"
|
|
69
|
-
>
|
|
70
|
-
<span
|
|
71
|
-
className="MuiIconButton-label"
|
|
72
|
-
>
|
|
73
|
-
<svg
|
|
74
|
-
aria-hidden={true}
|
|
75
|
-
className="MuiSvgIcon-root MuiSvgIcon-fontSizeSmall"
|
|
76
|
-
focusable="false"
|
|
77
|
-
viewBox="0 0 24 24"
|
|
78
|
-
>
|
|
79
|
-
<path
|
|
80
|
-
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
|
|
81
|
-
/>
|
|
82
|
-
</svg>
|
|
83
|
-
</span>
|
|
84
|
-
</button>
|
|
85
|
-
<button
|
|
86
|
-
aria-label="Open"
|
|
87
|
-
className="MuiButtonBase-root MuiIconButton-root MuiAutocomplete-popupIndicator"
|
|
88
|
-
disabled={false}
|
|
89
|
-
onBlur={[Function]}
|
|
90
|
-
onClick={[Function]}
|
|
91
|
-
onDragLeave={[Function]}
|
|
92
|
-
onFocus={[Function]}
|
|
93
|
-
onKeyDown={[Function]}
|
|
94
|
-
onKeyUp={[Function]}
|
|
95
|
-
onMouseDown={[Function]}
|
|
96
|
-
onMouseLeave={[Function]}
|
|
97
|
-
onMouseUp={[Function]}
|
|
98
|
-
onTouchEnd={[Function]}
|
|
99
|
-
onTouchMove={[Function]}
|
|
100
|
-
onTouchStart={[Function]}
|
|
101
|
-
tabIndex={-1}
|
|
102
|
-
title="Open"
|
|
103
|
-
type="button"
|
|
104
|
-
>
|
|
105
|
-
<span
|
|
106
|
-
className="MuiIconButton-label"
|
|
107
|
-
>
|
|
108
|
-
<svg
|
|
109
|
-
fill="currentColor"
|
|
110
|
-
focusable={false}
|
|
111
|
-
height={15}
|
|
112
|
-
stroke="currentColor"
|
|
113
|
-
strokeWidth="0"
|
|
114
|
-
style={
|
|
115
|
-
{
|
|
116
|
-
"color": undefined,
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
viewBox="0 0 512 512"
|
|
120
|
-
width={15}
|
|
121
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
122
|
-
>
|
|
123
|
-
<path
|
|
124
|
-
d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"
|
|
125
|
-
/>
|
|
126
|
-
</svg>
|
|
127
|
-
</span>
|
|
128
|
-
</button>
|
|
129
|
-
</div>
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
</div>
|
|
133
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './StopsFinder';
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
The following example demonstrates the use of Zoom.
|
|
3
|
-
|
|
4
|
-
```jsx
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { MapboxLayer } from 'mobility-toolbox-js/ol';
|
|
7
|
-
import Tile from 'ol/layer/Tile';
|
|
8
|
-
import OSM from 'ol/source/OSM';
|
|
9
|
-
import Map from 'ol/Map';
|
|
10
|
-
import BasicMap from 'react-spatial/components/BasicMap';
|
|
11
|
-
import Zoom from 'react-spatial/components/Zoom';
|
|
12
|
-
|
|
13
|
-
const map = new Map({ controls: [] });
|
|
14
|
-
|
|
15
|
-
const layers = [
|
|
16
|
-
new MapboxLayer({
|
|
17
|
-
url: `https://maps.geops.io/styles/travic_v2/style.json?key=${apiKey}`,
|
|
18
|
-
})
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
<div className="rs-zoom-example">
|
|
22
|
-
<BasicMap map={map} layers={layers} tabIndex={0} />
|
|
23
|
-
<Zoom map={map} zoomSlider />
|
|
24
|
-
</div>
|
|
25
|
-
```
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useEffect,
|
|
3
|
-
useRef,
|
|
4
|
-
useCallback,
|
|
5
|
-
useState,
|
|
6
|
-
useMemo,
|
|
7
|
-
} from 'react';
|
|
8
|
-
import PropTypes from 'prop-types';
|
|
9
|
-
import { FaPlus, FaMinus } from 'react-icons/fa';
|
|
10
|
-
import { ZoomSlider } from 'ol/control';
|
|
11
|
-
import OLMap from 'ol/Map';
|
|
12
|
-
import { easeOut } from 'ol/easing';
|
|
13
|
-
import { unByKey } from 'ol/Observable';
|
|
14
|
-
|
|
15
|
-
const propTypes = {
|
|
16
|
-
/**
|
|
17
|
-
* An [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
18
|
-
*/
|
|
19
|
-
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* The zoom delta applied on each click.
|
|
23
|
-
*/
|
|
24
|
-
delta: PropTypes.number,
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Titles HTML attribtues for button.
|
|
28
|
-
*/
|
|
29
|
-
titles: PropTypes.shape({
|
|
30
|
-
zoomIn: PropTypes.string,
|
|
31
|
-
zoomOut: PropTypes.string,
|
|
32
|
-
}),
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Children content of the zoom in button.
|
|
36
|
-
*/
|
|
37
|
-
zoomInChildren: PropTypes.node,
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Children content of the zoom out button.
|
|
41
|
-
*/
|
|
42
|
-
zoomOutChildren: PropTypes.node,
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Display a slider to zoom.
|
|
46
|
-
*/
|
|
47
|
-
zoomSlider: PropTypes.bool,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const defaultProps = {
|
|
51
|
-
titles: {
|
|
52
|
-
zoomIn: 'Zoom in',
|
|
53
|
-
zoomOut: 'Zoom out',
|
|
54
|
-
},
|
|
55
|
-
zoomInChildren: <FaPlus focusable={false} />,
|
|
56
|
-
zoomOutChildren: <FaMinus focusable={false} />,
|
|
57
|
-
zoomSlider: false,
|
|
58
|
-
delta: 1,
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const updateZoom = (map, delta) => {
|
|
62
|
-
const view = map.getView();
|
|
63
|
-
const currentZoom = view.getZoom();
|
|
64
|
-
const newZoom = currentZoom + delta;
|
|
65
|
-
const constrainedZoom = view.getConstrainedZoom(newZoom);
|
|
66
|
-
if (view.getAnimating()) {
|
|
67
|
-
view.cancelAnimations();
|
|
68
|
-
}
|
|
69
|
-
view.animate({
|
|
70
|
-
zoom: constrainedZoom,
|
|
71
|
-
duration: 250,
|
|
72
|
-
easing: easeOut,
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The Zoom component creates a zoom wrapper containing zoom-in and zoom-out buttons
|
|
78
|
-
* and an optional [ol/ZoomSlider](https://openlayers.org/en/latest/apidoc/module-ol_control_ZoomSlider-ZoomSlider.html).
|
|
79
|
-
*/
|
|
80
|
-
function Zoom({
|
|
81
|
-
map,
|
|
82
|
-
titles,
|
|
83
|
-
zoomInChildren,
|
|
84
|
-
zoomOutChildren,
|
|
85
|
-
zoomSlider,
|
|
86
|
-
delta,
|
|
87
|
-
...other
|
|
88
|
-
}) {
|
|
89
|
-
const ref = useRef();
|
|
90
|
-
const [currentZoom, setZoom] = useState();
|
|
91
|
-
|
|
92
|
-
const zoomIn = useCallback(
|
|
93
|
-
(evt) => {
|
|
94
|
-
if (!evt.which || evt.which === 13) {
|
|
95
|
-
updateZoom(map, delta);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
[delta, map],
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const zoomOut = useCallback(
|
|
102
|
-
(evt) => {
|
|
103
|
-
if (!evt.which || evt.which === 13) {
|
|
104
|
-
updateZoom(map, -delta);
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
[delta, map],
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
const zoomInDisabled = useMemo(() => {
|
|
111
|
-
return (
|
|
112
|
-
currentZoom >=
|
|
113
|
-
map.getView().getConstrainedZoom(map.getView().getMaxZoom())
|
|
114
|
-
);
|
|
115
|
-
}, [currentZoom, map]);
|
|
116
|
-
|
|
117
|
-
const zoomOutDisabled = useMemo(() => {
|
|
118
|
-
return (
|
|
119
|
-
currentZoom <=
|
|
120
|
-
map.getView().getConstrainedZoom(map.getView().getMinZoom())
|
|
121
|
-
);
|
|
122
|
-
}, [currentZoom, map]);
|
|
123
|
-
|
|
124
|
-
useEffect(() => {
|
|
125
|
-
// Trigger zoom update to disable zooms on max and min
|
|
126
|
-
const listenerKey = map.on('moveend', () => {
|
|
127
|
-
setZoom(map.getView().getZoom());
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
let control;
|
|
131
|
-
if (zoomSlider && ref.current) {
|
|
132
|
-
control = new ZoomSlider();
|
|
133
|
-
// We don't want to navigate to the zoom slider using TAB navigation.
|
|
134
|
-
control.element.firstElementChild.tabIndex = -1;
|
|
135
|
-
// Set the zoom slider in the custom control wrapper.
|
|
136
|
-
control.setTarget(ref.current);
|
|
137
|
-
map.addControl(control);
|
|
138
|
-
}
|
|
139
|
-
return () => {
|
|
140
|
-
unByKey(listenerKey);
|
|
141
|
-
if (control) {
|
|
142
|
-
map.removeControl(control);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}, [map, zoomSlider]);
|
|
146
|
-
|
|
147
|
-
return (
|
|
148
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
149
|
-
<div className="rs-zooms-bar" {...other}>
|
|
150
|
-
<button
|
|
151
|
-
type="button"
|
|
152
|
-
tabIndex={0}
|
|
153
|
-
className="rs-zoom-in"
|
|
154
|
-
title={titles.zoomIn}
|
|
155
|
-
onClick={zoomIn}
|
|
156
|
-
onKeyPress={zoomIn}
|
|
157
|
-
disabled={zoomInDisabled}
|
|
158
|
-
>
|
|
159
|
-
{zoomInChildren}
|
|
160
|
-
</button>
|
|
161
|
-
{zoomSlider ? <div className="rs-zoomslider-wrapper" ref={ref} /> : null}
|
|
162
|
-
<button
|
|
163
|
-
type="button"
|
|
164
|
-
tabIndex={0}
|
|
165
|
-
className="rs-zoom-out"
|
|
166
|
-
title={titles.zoomOut}
|
|
167
|
-
onClick={zoomOut}
|
|
168
|
-
onKeyPress={zoomOut}
|
|
169
|
-
disabled={zoomOutDisabled}
|
|
170
|
-
>
|
|
171
|
-
{zoomOutChildren}
|
|
172
|
-
</button>
|
|
173
|
-
</div>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
Zoom.propTypes = propTypes;
|
|
178
|
-
Zoom.defaultProps = defaultProps;
|
|
179
|
-
|
|
180
|
-
export default React.memo(Zoom);
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
import { configure, shallow, mount } from 'enzyme';
|
|
4
|
-
import Adapter from '@cfaester/enzyme-adapter-react-18';
|
|
5
|
-
import { act } from 'react-dom/test-utils';
|
|
6
|
-
import MapEvent from 'ol/MapEvent';
|
|
7
|
-
import OLView from 'ol/View';
|
|
8
|
-
import OLMap from 'ol/Map';
|
|
9
|
-
import Zoom from './Zoom';
|
|
10
|
-
|
|
11
|
-
configure({ adapter: new Adapter() });
|
|
12
|
-
|
|
13
|
-
describe('Zoom', () => {
|
|
14
|
-
test('should match snapshot.', () => {
|
|
15
|
-
const map = new OLMap({});
|
|
16
|
-
const component = renderer.create(<Zoom map={map} />);
|
|
17
|
-
const tree = component.toJSON();
|
|
18
|
-
expect(tree).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('should match snapshot with custom attributes', () => {
|
|
22
|
-
const map = new OLMap({});
|
|
23
|
-
const component = renderer.create(
|
|
24
|
-
<Zoom map={map} className="foo" tabIndex={-1} title="bar" />,
|
|
25
|
-
);
|
|
26
|
-
const tree = component.toJSON();
|
|
27
|
-
expect(tree).toMatchSnapshot();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('should match snapshot with zoom slider', () => {
|
|
31
|
-
const map = new OLMap({});
|
|
32
|
-
const component = renderer.create(<Zoom map={map} zoomSlider />);
|
|
33
|
-
const tree = component.toJSON();
|
|
34
|
-
expect(tree).toMatchSnapshot();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
[
|
|
38
|
-
['click', {}],
|
|
39
|
-
['keypress', { which: 13 }],
|
|
40
|
-
].forEach((evt) => {
|
|
41
|
-
test(`should zoom in on ${evt[0]}.`, () => {
|
|
42
|
-
const map = new OLMap({ view: new OLView({ zoom: 5 }) });
|
|
43
|
-
const zooms = shallow(<Zoom map={map} />);
|
|
44
|
-
zooms
|
|
45
|
-
.find('.rs-zoom-in')
|
|
46
|
-
.first()
|
|
47
|
-
.simulate(...evt);
|
|
48
|
-
|
|
49
|
-
expect(map.getView().getZoom()).toBe(6);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test(`should zoom in on ${evt[0]} (delta: 0.3).`, () => {
|
|
53
|
-
const map = new OLMap({ view: new OLView({ zoom: 5 }) });
|
|
54
|
-
const zooms = shallow(<Zoom map={map} delta={0.3} />);
|
|
55
|
-
zooms
|
|
56
|
-
.find('.rs-zoom-in')
|
|
57
|
-
.first()
|
|
58
|
-
.simulate(...evt);
|
|
59
|
-
|
|
60
|
-
expect(map.getView().getZoom()).toBe(5.3);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test(`should zoom out on ${evt[0]}.`, () => {
|
|
64
|
-
const map = new OLMap({ view: new OLView({ zoom: 5 }) });
|
|
65
|
-
const zooms = shallow(<Zoom map={map} />);
|
|
66
|
-
zooms
|
|
67
|
-
.find('.rs-zoom-out')
|
|
68
|
-
.first()
|
|
69
|
-
.simulate(...evt);
|
|
70
|
-
|
|
71
|
-
expect(map.getView().getZoom()).toBe(4);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test(`should zoom out on ${evt[0]} (delta: 0.3).`, () => {
|
|
75
|
-
const map = new OLMap({ view: new OLView({ zoom: 5 }) });
|
|
76
|
-
const zooms = shallow(<Zoom map={map} delta={0.3} />);
|
|
77
|
-
zooms
|
|
78
|
-
.find('.rs-zoom-out')
|
|
79
|
-
.first()
|
|
80
|
-
.simulate(...evt);
|
|
81
|
-
|
|
82
|
-
expect(map.getView().getZoom()).toBe(4.7);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test('should remove zoomSlider control on unmount.', () => {
|
|
87
|
-
const map = new OLMap({});
|
|
88
|
-
const spy = jest.spyOn(map, 'removeControl');
|
|
89
|
-
const spy2 = jest.spyOn(map, 'addControl');
|
|
90
|
-
const wrapper = mount(<Zoom map={map} zoomSlider />);
|
|
91
|
-
expect(spy).toHaveBeenCalledTimes(0);
|
|
92
|
-
wrapper.unmount();
|
|
93
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
94
|
-
expect(spy.mock.calls[0][0]).toBe(spy2.mock.calls[0][0]);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
test('should disable zoom-in button on mount with max zoom..', () => {
|
|
98
|
-
const map = new OLMap({
|
|
99
|
-
view: new OLView({ maxZoom: 20, zoom: 20 }),
|
|
100
|
-
});
|
|
101
|
-
const spy = jest.spyOn(map.getView(), 'setZoom');
|
|
102
|
-
const wrapper = mount(<Zoom map={map} />);
|
|
103
|
-
act(() => {
|
|
104
|
-
map.dispatchEvent(new MapEvent('moveend', map));
|
|
105
|
-
});
|
|
106
|
-
wrapper.update();
|
|
107
|
-
expect(wrapper.find('.rs-zoom-in').prop('disabled')).toEqual(true);
|
|
108
|
-
wrapper.find('.rs-zoom-in').first().simulate('click');
|
|
109
|
-
expect(spy).toHaveBeenCalledTimes(0);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
test('should disable zoom-out button on mount with min zoom.', () => {
|
|
113
|
-
const map = new OLMap({
|
|
114
|
-
view: new OLView({ minZoom: 2, zoom: 2 }),
|
|
115
|
-
});
|
|
116
|
-
const spy = jest.spyOn(map.getView(), 'setZoom');
|
|
117
|
-
const wrapper = mount(<Zoom map={map} />);
|
|
118
|
-
act(() => {
|
|
119
|
-
map.dispatchEvent(new MapEvent('moveend', map));
|
|
120
|
-
});
|
|
121
|
-
wrapper.update();
|
|
122
|
-
expect(wrapper.find('.rs-zoom-out').prop('disabled')).toEqual(true);
|
|
123
|
-
wrapper.find('.rs-zoom-out').first().simulate('click');
|
|
124
|
-
expect(spy).toHaveBeenCalledTimes(0);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test('should disable zoom-out button when reaching min zoom.', () => {
|
|
129
|
-
const map = new OLMap({
|
|
130
|
-
view: new OLView({ minZoom: 2, zoom: 3 }),
|
|
131
|
-
});
|
|
132
|
-
const spy = jest.spyOn(map.getView(), 'setZoom');
|
|
133
|
-
const wrapper = mount(<Zoom map={map} />);
|
|
134
|
-
wrapper.find('.rs-zoom-out').first().simulate('click');
|
|
135
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
136
|
-
act(() => {
|
|
137
|
-
map.dispatchEvent(new MapEvent('moveend', map));
|
|
138
|
-
});
|
|
139
|
-
wrapper.update();
|
|
140
|
-
expect(wrapper.find('.rs-zoom-out').prop('disabled')).toEqual(true);
|
|
141
|
-
});
|