react-spatial 1.4.0 → 1.4.1
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/.github/workflows/conventional-pr-title.yml +21 -0
- package/.github/workflows/main.yml +28 -0
- package/.husky/commit-msg +4 -0
- package/.husky/post-checkout +4 -0
- package/.husky/post-merge +4 -0
- package/.husky/post-rebase +4 -0
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -0
- package/.whitesource +8 -0
- package/CHANGELOG.md +54 -0
- package/DEVELOP.md +113 -0
- package/README.md +1 -1
- package/__mocks__/mapbox-gl.js +11 -0
- package/__mocks__/resize-observer-polyfill.js +9 -0
- package/babel.config.js +3 -0
- package/commitlint.config.js +1 -0
- package/data/topic1.js +119 -0
- package/data/topic2.js +28 -0
- package/doc/README.md +21 -0
- package/doc/doc-config.json +4 -0
- package/netlify.toml +3 -0
- package/package.json +30 -41
- package/pull_request_template.md +16 -0
- package/renovate.json +4 -0
- package/scripts/read-pkg-json.js +17 -0
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.js +322 -0
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +69 -0
- package/src/components/BaseLayerSwitcher/README.md +61 -0
- package/src/components/BaseLayerSwitcher/__snapshots__/BaseLayerSwitcher.test.js.snap +88 -0
- package/src/components/BaseLayerSwitcher/index.js +1 -0
- package/src/components/BasicMap/BasicMap.js +413 -0
- package/src/components/BasicMap/BasicMap.test.js +281 -0
- package/src/components/BasicMap/README.md +18 -0
- package/src/components/BasicMap/index.js +1 -0
- package/{components → src/components}/CanvasSaveButton/CanvasSaveButton.js +320 -93
- package/src/components/CanvasSaveButton/CanvasSaveButton.test.js +148 -0
- package/src/components/CanvasSaveButton/README.md +76 -0
- package/src/components/CanvasSaveButton/__snapshots__/CanvasSaveButton.test.js.snap +76 -0
- package/src/components/CanvasSaveButton/index.js +1 -0
- package/src/components/Copyright/Copyright.js +89 -0
- package/src/components/Copyright/Copyright.test.js +134 -0
- package/src/components/Copyright/README.md +36 -0
- package/src/components/Copyright/index.js +1 -0
- package/src/components/FeatureExportButton/FeatureExportButton.js +118 -0
- package/src/components/FeatureExportButton/FeatureExportButton.test.js +417 -0
- package/src/components/FeatureExportButton/README.md +76 -0
- package/src/components/FeatureExportButton/__snapshots__/FeatureExportButton.test.js.snap +67 -0
- package/src/components/FeatureExportButton/index.js +1 -0
- package/src/components/FitExtent/FitExtent.js +62 -0
- package/src/components/FitExtent/FitExtent.test.js +48 -0
- package/src/components/FitExtent/README.md +34 -0
- package/src/components/FitExtent/__snapshots__/FitExtent.test.js.snap +13 -0
- package/src/components/FitExtent/index.js +1 -0
- package/{components → src/components}/Geolocation/Geolocation.js +144 -61
- package/src/components/Geolocation/Geolocation.test.js +267 -0
- package/src/components/Geolocation/README.md +25 -0
- package/src/components/Geolocation/__snapshots__/Geolocation.test.js.snap +92 -0
- package/src/components/Geolocation/index.js +1 -0
- package/src/components/LayerTree/LayerTree.js +487 -0
- package/src/components/LayerTree/LayerTree.test.js +337 -0
- package/src/components/LayerTree/README.md +92 -0
- package/src/components/LayerTree/__snapshots__/LayerTree.test.js.snap +1746 -0
- package/src/components/LayerTree/index.js +1 -0
- package/src/components/MousePosition/MousePosition.js +175 -0
- package/src/components/MousePosition/MousePosition.test.js +132 -0
- package/src/components/MousePosition/README.md +50 -0
- package/src/components/MousePosition/__snapshots__/MousePosition.test.js.snap +76 -0
- package/src/components/MousePosition/index.js +1 -0
- package/src/components/NorthArrow/NorthArrow.js +75 -0
- package/src/components/NorthArrow/NorthArrow.test.js +104 -0
- package/src/components/NorthArrow/README.md +59 -0
- package/src/components/NorthArrow/__snapshots__/NorthArrow.test.js.snap +117 -0
- package/src/components/NorthArrow/index.js +1 -0
- package/src/components/Overlay/Overlay.js +176 -0
- package/src/components/Overlay/Overlay.test.js +149 -0
- package/src/components/Overlay/README.md +59 -0
- package/src/components/Overlay/__snapshots__/Overlay.test.js.snap +9 -0
- package/src/components/Overlay/index.js +1 -0
- package/src/components/Permalink/Permalink.js +326 -0
- package/src/components/Permalink/Permalink.test.js +285 -0
- package/src/components/Permalink/README.md +105 -0
- package/src/components/Permalink/index.js +1 -0
- package/{components → src/components}/Popup/Popup.js +165 -55
- package/src/components/Popup/Popup.test.js +307 -0
- package/src/components/Popup/README.md +93 -0
- package/src/components/Popup/__snapshots__/Popup.test.js.snap +180 -0
- package/src/components/Popup/index.js +1 -0
- package/src/components/README.md +41 -0
- package/{components → src/components}/ResizeHandler/ResizeHandler.js +50 -15
- package/src/components/ResizeHandler/ResizeHandler.test.js +344 -0
- package/src/components/ResizeHandler/index.js +1 -0
- package/src/components/RouteSchedule/README.md +118 -0
- package/src/components/RouteSchedule/RouteSchedule.js +364 -0
- package/src/components/RouteSchedule/RouteSchedule.test.js +113 -0
- package/src/components/RouteSchedule/__snapshots__/RouteSchedule.test.js.snap +248 -0
- package/src/components/RouteSchedule/index.js +1 -0
- package/src/components/ScaleLine/README.md +29 -0
- package/src/components/ScaleLine/ScaleLine.js +50 -0
- package/src/components/ScaleLine/ScaleLine.test.js +30 -0
- package/src/components/ScaleLine/__snapshots__/ScaleLine.test.js.snap +7 -0
- package/src/components/ScaleLine/index.js +1 -0
- package/src/components/StopsFinder/README.md +50 -0
- package/src/components/StopsFinder/StopsFinder.js +284 -0
- package/src/components/StopsFinder/StopsFinder.test.js +17 -0
- package/src/components/StopsFinder/StopsFinderOption.js +61 -0
- package/src/components/StopsFinder/__snapshots__/StopsFinder.test.js.snap +133 -0
- package/src/components/StopsFinder/index.js +1 -0
- package/src/components/Zoom/README.md +25 -0
- package/src/components/Zoom/Zoom.js +180 -0
- package/src/components/Zoom/Zoom.test.js +141 -0
- package/src/components/Zoom/__snapshots__/Zoom.test.js.snap +201 -0
- package/src/components/Zoom/index.js +1 -0
- package/{propTypes.js → src/propTypes.js} +16 -12
- package/{setupTests.js → src/setupTests.js} +1 -1
- package/src/styleguidist/ComponentsList.js +52 -0
- package/src/styleguidist/StyleGuide.js +277 -0
- package/src/styleguidist/styleguidist.css +38 -0
- package/src/utils/GlobalsForOle.js +99 -0
- package/src/utils/KML.js +594 -0
- package/src/utils/KML.test.js +337 -0
- package/src/utils/KMLFormat.js +100 -0
- package/src/utils/KMLFormat.test.js +50 -0
- package/{utils → src/utils}/Styles.js +20 -14
- 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/{utils → src/utils}/getPolygonPattern.js +34 -6
- package/src/utils/getPolygonPattern.test.js +61 -0
- package/{utils → src/utils}/timeUtils.js +22 -5
- package/src/utils/timeUtils.test.js +30 -0
- package/styleguide.config.js +251 -0
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +0 -231
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +0 -7
- package/components/BaseLayerSwitcher/index.js +0 -1
- package/components/BaseLayerSwitcher/index.js.map +0 -7
- package/components/BasicMap/BasicMap.js +0 -278
- package/components/BasicMap/BasicMap.js.map +0 -7
- package/components/BasicMap/index.js +0 -1
- package/components/BasicMap/index.js.map +0 -7
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +0 -7
- package/components/CanvasSaveButton/index.js +0 -1
- package/components/CanvasSaveButton/index.js.map +0 -7
- package/components/Copyright/Copyright.js +0 -55
- package/components/Copyright/Copyright.js.map +0 -7
- package/components/Copyright/index.js +0 -1
- package/components/Copyright/index.js.map +0 -7
- package/components/FeatureExportButton/FeatureExportButton.js +0 -62
- package/components/FeatureExportButton/FeatureExportButton.js.map +0 -7
- package/components/FeatureExportButton/index.js +0 -1
- package/components/FeatureExportButton/index.js.map +0 -7
- package/components/FitExtent/FitExtent.js +0 -32
- package/components/FitExtent/FitExtent.js.map +0 -7
- package/components/FitExtent/index.js +0 -1
- package/components/FitExtent/index.js.map +0 -7
- package/components/Geolocation/Geolocation.js.map +0 -7
- package/components/Geolocation/index.js +0 -1
- package/components/Geolocation/index.js.map +0 -7
- package/components/LayerTree/LayerTree.js +0 -278
- package/components/LayerTree/LayerTree.js.map +0 -7
- package/components/LayerTree/index.js +0 -1
- package/components/LayerTree/index.js.map +0 -7
- package/components/MousePosition/MousePosition.js +0 -110
- package/components/MousePosition/MousePosition.js.map +0 -7
- package/components/MousePosition/index.js +0 -1
- package/components/MousePosition/index.js.map +0 -7
- package/components/NorthArrow/NorthArrow.js +0 -43
- package/components/NorthArrow/NorthArrow.js.map +0 -7
- package/components/NorthArrow/index.js +0 -1
- package/components/NorthArrow/index.js.map +0 -7
- package/components/Overlay/Overlay.js +0 -122
- package/components/Overlay/Overlay.js.map +0 -7
- package/components/Overlay/index.js +0 -1
- package/components/Overlay/index.js.map +0 -7
- package/components/Permalink/Permalink.js +0 -206
- package/components/Permalink/Permalink.js.map +0 -7
- package/components/Permalink/index.js +0 -1
- package/components/Permalink/index.js.map +0 -7
- package/components/Popup/Popup.js.map +0 -7
- package/components/Popup/index.js +0 -1
- package/components/Popup/index.js.map +0 -7
- package/components/ResizeHandler/ResizeHandler.js.map +0 -7
- package/components/ResizeHandler/index.js +0 -1
- package/components/ResizeHandler/index.js.map +0 -7
- package/components/RouteSchedule/RouteSchedule.js +0 -220
- package/components/RouteSchedule/RouteSchedule.js.map +0 -7
- package/components/RouteSchedule/index.js +0 -1
- package/components/RouteSchedule/index.js.map +0 -7
- package/components/ScaleLine/ScaleLine.js +0 -32
- package/components/ScaleLine/ScaleLine.js.map +0 -7
- package/components/ScaleLine/index.js +0 -1
- package/components/ScaleLine/index.js.map +0 -7
- package/components/StopsFinder/StopsFinder.js +0 -210
- package/components/StopsFinder/StopsFinder.js.map +0 -7
- package/components/StopsFinder/StopsFinderOption.js +0 -50
- package/components/StopsFinder/StopsFinderOption.js.map +0 -7
- package/components/StopsFinder/index.js +0 -1
- package/components/StopsFinder/index.js.map +0 -7
- package/components/Zoom/Zoom.js +0 -120
- package/components/Zoom/Zoom.js.map +0 -7
- package/components/Zoom/index.js +0 -1
- package/components/Zoom/index.js.map +0 -7
- package/propTypes.js.map +0 -7
- package/setupTests.js.map +0 -7
- package/utils/GlobalsForOle.js +0 -94
- package/utils/GlobalsForOle.js.map +0 -7
- package/utils/KML.js +0 -412
- package/utils/KML.js.map +0 -7
- package/utils/KMLFormat.js +0 -69
- package/utils/KMLFormat.js.map +0 -7
- package/utils/Styles.js.map +0 -7
- package/utils/getPolygonPattern.js.map +0 -7
- package/utils/timeUtils.js.map +0 -7
- /package/{components → src/components}/BaseLayerSwitcher/BaseLayerSwitcher.md.scss +0 -0
- /package/{components → src/components}/BaseLayerSwitcher/BaseLayerSwitcher.scss +0 -0
- /package/{components → src/components}/BasicMap/BasicMap.md.scss +0 -0
- /package/{components → src/components}/CanvasSaveButton/CanvasSaveButton.md.scss +0 -0
- /package/{components → src/components}/Copyright/Copyright.md.scss +0 -0
- /package/{components → src/components}/FeatureExportButton/FeatureExportButton.md.scss +0 -0
- /package/{components → src/components}/FitExtent/FitExtent.md.scss +0 -0
- /package/{components → src/components}/Geolocation/Geolocation.md.scss +0 -0
- /package/{components → src/components}/Geolocation/Geolocation.scss +0 -0
- /package/{components → src/components}/LayerTree/LayerTree.md.scss +0 -0
- /package/{components → src/components}/LayerTree/LayerTree.scss +0 -0
- /package/{components → src/components}/MousePosition/MousePosition.md.scss +0 -0
- /package/{components → src/components}/NorthArrow/NorthArrow.scss +0 -0
- /package/{components → src/components}/Overlay/Overlay.md.scss +0 -0
- /package/{components → src/components}/Overlay/Overlay.scss +0 -0
- /package/{components → src/components}/Permalink/Permalink.md.scss +0 -0
- /package/{components → src/components}/Popup/Popup.md.scss +0 -0
- /package/{components → src/components}/Popup/Popup.scss +0 -0
- /package/{components → src/components}/RouteSchedule/RouteSchedule.md.scss +0 -0
- /package/{components → src/components}/RouteSchedule/RouteSchedule.scss +0 -0
- /package/{components → src/components}/ScaleLine/ScaleLine.scss +0 -0
- /package/{components → src/components}/Zoom/Zoom.md.scss +0 -0
- /package/{components → src/components}/Zoom/Zoom.scss +0 -0
- /package/{images → src/images}/RouteSchedule/firstStation.png +0 -0
- /package/{images → src/images}/RouteSchedule/lastStation.png +0 -0
- /package/{images → src/images}/RouteSchedule/line.png +0 -0
- /package/{images → src/images}/RouteSchedule/station.png +0 -0
- /package/{images → src/images}/baselayer/baselayer.basebright.png +0 -0
- /package/{images → src/images}/baselayer/baselayer.osm.png +0 -0
- /package/{images → src/images}/baselayer/baselayer.travic.png +0 -0
- /package/{images → src/images}/baselayer/open.topo.map.png +0 -0
- /package/{images → src/images}/baselayer/osm.baselayer.hot.png +0 -0
- /package/{images → src/images}/baselayer/osm.baselayer.png +0 -0
- /package/{images → src/images}/favicon.png +0 -0
- /package/{images → src/images}/geops_logo.png +0 -0
- /package/{images → src/images}/geops_logo.svg +0 -0
- /package/{images → src/images}/geops_qr.png +0 -0
- /package/{images → src/images}/mots/bus_poi-blue-01.svg +0 -0
- /package/{images → src/images}/mots/bus_poi-grey-01.svg +0 -0
- /package/{images → src/images}/mots/bus_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/bus_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/bus_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/bus_square-grey-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_poi-blue-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_poi-grey-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/cable_car_square-grey-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_poi-blue-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_poi-grey-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/ferry_square-grey-01.svg +0 -0
- /package/{images → src/images}/mots/funicular_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/funicular_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/funicular_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/gondola_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/rail_poi-blue-01.svg +0 -0
- /package/{images → src/images}/mots/rail_poi-grey-01.svg +0 -0
- /package/{images → src/images}/mots/rail_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/rail_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/rail_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/rail_square-grey-01.svg +0 -0
- /package/{images → src/images}/mots/subway_round blue-01.svg +0 -0
- /package/{images → src/images}/mots/subway_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/tram_poi-blue-01.svg +0 -0
- /package/{images → src/images}/mots/tram_poi-grey-01.svg +0 -0
- /package/{images → src/images}/mots/tram_round-blue-01.svg +0 -0
- /package/{images → src/images}/mots/tram_round-grey-01.svg +0 -0
- /package/{images → src/images}/mots/tram_square-blue-01.svg +0 -0
- /package/{images → src/images}/mots/tram_square-grey-01.svg +0 -0
- /package/{images → src/images}/northArrow.svg +0 -0
- /package/{images → src/images}/northArrow.url.svg +0 -0
- /package/{images → src/images}/northArrowCircle.svg +0 -0
- /package/{images → src/images}/northArrowCircle.url.svg +0 -0
- /package/{themes → src/themes}/README.md +0 -0
- /package/{themes → src/themes}/default/components.scss +0 -0
- /package/{themes → src/themes}/default/examples.scss +0 -0
- /package/{themes → src/themes}/default/index.scss +0 -0
- /package/{themes → src/themes}/default/mixins.scss +0 -0
- /package/{themes → src/themes}/default/variables.scss +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './RouteSchedule';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
The following example demonstrates the use of ScaleLine.
|
|
3
|
+
|
|
4
|
+
```js
|
|
5
|
+
import React, { Component } 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 ScaleLine from 'react-spatial/components/ScaleLine';
|
|
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 style={{position:'relative'}}>
|
|
22
|
+
<BasicMap
|
|
23
|
+
map={map}
|
|
24
|
+
layers={layers}
|
|
25
|
+
tabIndex={0}
|
|
26
|
+
/>
|
|
27
|
+
<ScaleLine map={map} />
|
|
28
|
+
</div>
|
|
29
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import OLScaleLine from 'ol/control/ScaleLine';
|
|
4
|
+
import OLMap from 'ol/Map';
|
|
5
|
+
|
|
6
|
+
const propTypes = {
|
|
7
|
+
/**
|
|
8
|
+
* ol/map.
|
|
9
|
+
*/
|
|
10
|
+
map: PropTypes.instanceOf(OLMap).isRequired,
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Options for ol/control/ScaleLine.
|
|
14
|
+
* See https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-ScaleLine.html
|
|
15
|
+
*/
|
|
16
|
+
options: PropTypes.object,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const defaultProps = {
|
|
20
|
+
options: {},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The ScaleLine component creates an
|
|
25
|
+
* [ol/control/ScaleLine](https://openlayers.org/en/latest/apidoc/module-ol_control_ScaleLine-ScaleLine.html)
|
|
26
|
+
* for an [ol/map](https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html).
|
|
27
|
+
*/
|
|
28
|
+
function ScaleLine({ map, options, ...other }) {
|
|
29
|
+
const ref = useRef();
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const control = new OLScaleLine({
|
|
33
|
+
...options,
|
|
34
|
+
...{ target: ref.current },
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
map.addControl(control);
|
|
38
|
+
return () => {
|
|
39
|
+
map.removeControl(control);
|
|
40
|
+
};
|
|
41
|
+
}, [map, options]);
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
44
|
+
return <div className="rs-scale-line" ref={ref} {...other} />;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ScaleLine.propTypes = propTypes;
|
|
48
|
+
ScaleLine.defaultProps = defaultProps;
|
|
49
|
+
|
|
50
|
+
export default React.memo(ScaleLine);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import 'jest-canvas-mock';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { configure, mount } from 'enzyme';
|
|
4
|
+
import OLMap from 'ol/Map';
|
|
5
|
+
import OLView from 'ol/View';
|
|
6
|
+
import Adapter from '@cfaester/enzyme-adapter-react-18';
|
|
7
|
+
import renderer from 'react-test-renderer';
|
|
8
|
+
import ScaleLine from './ScaleLine';
|
|
9
|
+
|
|
10
|
+
configure({ adapter: new Adapter() });
|
|
11
|
+
|
|
12
|
+
describe('ScaleLine', () => {
|
|
13
|
+
test('matches snapshot', () => {
|
|
14
|
+
const map = new OLMap({ view: new OLView({ zoom: 7, center: [0, 0] }) });
|
|
15
|
+
const component = renderer.create(<ScaleLine map={map} />);
|
|
16
|
+
const tree = component.toJSON();
|
|
17
|
+
expect(tree).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('remove control on unmount.', () => {
|
|
21
|
+
const map = new OLMap({});
|
|
22
|
+
const spy = jest.spyOn(map, 'removeControl');
|
|
23
|
+
const spy2 = jest.spyOn(map, 'addControl');
|
|
24
|
+
const wrapper = mount(<ScaleLine map={map} />);
|
|
25
|
+
expect(spy).toHaveBeenCalledTimes(0);
|
|
26
|
+
wrapper.unmount();
|
|
27
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
28
|
+
expect(spy.mock.calls[0][0]).toBe(spy2.mock.calls[0][0]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ScaleLine';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
This demonstrates the use of the StopsFinder component.
|
|
3
|
+
|
|
4
|
+
```jsx
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Layer } from 'mobility-toolbox-js/ol';
|
|
7
|
+
import Map from 'ol/Map';
|
|
8
|
+
import Tile from 'ol/layer/Tile';
|
|
9
|
+
import { fromLonLat } from 'ol/proj';
|
|
10
|
+
import OSM from 'ol/source/OSM';
|
|
11
|
+
import BasicMap from 'react-spatial/components/BasicMap';
|
|
12
|
+
import StopsFinder from 'react-spatial/components/StopsFinder';
|
|
13
|
+
|
|
14
|
+
const map = new Map({ controls: [] });
|
|
15
|
+
|
|
16
|
+
const layers = [
|
|
17
|
+
new Layer({
|
|
18
|
+
olLayer: new Tile({
|
|
19
|
+
source: new OSM(),
|
|
20
|
+
}),
|
|
21
|
+
}),
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
// The `apiKey` used here is for demonstration purposes only.
|
|
25
|
+
// Please get your own api key at https://developer.geops.io/.
|
|
26
|
+
const { apiKey } = window;
|
|
27
|
+
|
|
28
|
+
<>
|
|
29
|
+
<BasicMap
|
|
30
|
+
map={map}
|
|
31
|
+
center={[951560, 6002550]}
|
|
32
|
+
zoom={14}
|
|
33
|
+
layers={layers}
|
|
34
|
+
tabIndex={0}
|
|
35
|
+
/>
|
|
36
|
+
|
|
37
|
+
<StopsFinder
|
|
38
|
+
map={map}
|
|
39
|
+
apiKey={apiKey}
|
|
40
|
+
onSelect={({ geometry }) => {
|
|
41
|
+
map.getView().setCenter(fromLonLat(geometry.coordinates));
|
|
42
|
+
}}
|
|
43
|
+
autocompleteProps={{
|
|
44
|
+
textFieldProps: {
|
|
45
|
+
label: 'Search for stops',
|
|
46
|
+
},
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
</>
|
|
50
|
+
```
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import React, { useMemo, useState, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Autocomplete } from '@material-ui/lab';
|
|
4
|
+
import { FaSearch } from 'react-icons/fa';
|
|
5
|
+
import TextField from '@material-ui/core/TextField';
|
|
6
|
+
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
7
|
+
import { StopFinderControl } from 'mobility-toolbox-js/ol';
|
|
8
|
+
import { Map } from 'ol';
|
|
9
|
+
import { makeStyles } from '@material-ui/core';
|
|
10
|
+
import StopsFinderOptions from './StopsFinderOption';
|
|
11
|
+
|
|
12
|
+
const useStyles = makeStyles(() => {
|
|
13
|
+
return {
|
|
14
|
+
popupIndicatorOpen: {
|
|
15
|
+
transform: 'rotate(0)',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function StopsFinder({
|
|
21
|
+
agencies,
|
|
22
|
+
apiKey,
|
|
23
|
+
autocompleteProps,
|
|
24
|
+
bbox,
|
|
25
|
+
field,
|
|
26
|
+
limit,
|
|
27
|
+
map,
|
|
28
|
+
mots,
|
|
29
|
+
onSelect,
|
|
30
|
+
radius,
|
|
31
|
+
refLocation,
|
|
32
|
+
renderAutocomplete,
|
|
33
|
+
url,
|
|
34
|
+
}) {
|
|
35
|
+
const classes = useStyles();
|
|
36
|
+
const [inputValue, setInputValue] = useState('');
|
|
37
|
+
const [suggestions, setSuggestions] = useState([]);
|
|
38
|
+
const [isLoading, setLoading] = useState(false);
|
|
39
|
+
const [isOpen, setOpen] = useState(false);
|
|
40
|
+
|
|
41
|
+
const control = useMemo(() => {
|
|
42
|
+
return new StopFinderControl({
|
|
43
|
+
url,
|
|
44
|
+
apiKey,
|
|
45
|
+
target: document.createElement('div'),
|
|
46
|
+
element: document.createElement('div'),
|
|
47
|
+
render(newSuggestions = { features: [] }) {
|
|
48
|
+
setSuggestions(newSuggestions.features);
|
|
49
|
+
setLoading(false);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}, [apiKey, url]);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!inputValue) {
|
|
56
|
+
setSuggestions([]);
|
|
57
|
+
setLoading(false);
|
|
58
|
+
return () => {};
|
|
59
|
+
}
|
|
60
|
+
const abortController = new AbortController();
|
|
61
|
+
setLoading(true);
|
|
62
|
+
control.apiParams = {
|
|
63
|
+
prefAgencies: agencies && agencies.toString(),
|
|
64
|
+
bbox: bbox && bbox.toString(),
|
|
65
|
+
field: field && field.toString(),
|
|
66
|
+
limit,
|
|
67
|
+
mots: mots && mots.toString(),
|
|
68
|
+
radius,
|
|
69
|
+
ref_location: refLocation && refLocation.toString(),
|
|
70
|
+
};
|
|
71
|
+
control.search(inputValue, abortController);
|
|
72
|
+
return () => {
|
|
73
|
+
abortController.abort();
|
|
74
|
+
};
|
|
75
|
+
}, [
|
|
76
|
+
agencies,
|
|
77
|
+
bbox,
|
|
78
|
+
control,
|
|
79
|
+
field,
|
|
80
|
+
inputValue,
|
|
81
|
+
limit,
|
|
82
|
+
mots,
|
|
83
|
+
radius,
|
|
84
|
+
refLocation,
|
|
85
|
+
]);
|
|
86
|
+
|
|
87
|
+
// Ensure the control is not associated to the wrong map
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (!control) {
|
|
90
|
+
return () => {};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
control.map = map;
|
|
94
|
+
|
|
95
|
+
return () => {
|
|
96
|
+
control.map = null;
|
|
97
|
+
};
|
|
98
|
+
}, [map, control]);
|
|
99
|
+
|
|
100
|
+
if (!control) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (renderAutocomplete) {
|
|
105
|
+
return renderAutocomplete(
|
|
106
|
+
suggestions,
|
|
107
|
+
inputValue,
|
|
108
|
+
setInputValue,
|
|
109
|
+
isOpen,
|
|
110
|
+
setOpen,
|
|
111
|
+
isLoading,
|
|
112
|
+
setLoading,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
const textFieldProps = {
|
|
116
|
+
...((autocompleteProps || {}).textFieldProps || {}),
|
|
117
|
+
};
|
|
118
|
+
const autocProps = { ...autocompleteProps };
|
|
119
|
+
delete autocProps.textFieldProps;
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<Autocomplete
|
|
123
|
+
fullWidth
|
|
124
|
+
autoComplete
|
|
125
|
+
autoHighlight
|
|
126
|
+
selectOnFocus
|
|
127
|
+
getOptionLabel={(option) => {
|
|
128
|
+
return option.properties.name;
|
|
129
|
+
}}
|
|
130
|
+
onChange={(evt, value, reason) => {
|
|
131
|
+
if (onSelect && reason === 'select-option') {
|
|
132
|
+
onSelect(value, evt);
|
|
133
|
+
}
|
|
134
|
+
}}
|
|
135
|
+
popupIcon={<FaSearch focusable={false} size={15} />}
|
|
136
|
+
renderInput={(params) => {
|
|
137
|
+
return (
|
|
138
|
+
<TextField
|
|
139
|
+
label="Search stops"
|
|
140
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
141
|
+
{...{
|
|
142
|
+
...params,
|
|
143
|
+
...textFieldProps,
|
|
144
|
+
}}
|
|
145
|
+
InputProps={{
|
|
146
|
+
...params.InputProps,
|
|
147
|
+
endAdornment: (
|
|
148
|
+
<>
|
|
149
|
+
{isLoading && <CircularProgress size={20} />}
|
|
150
|
+
{params.InputProps.endAdornment}
|
|
151
|
+
</>
|
|
152
|
+
),
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
);
|
|
156
|
+
}}
|
|
157
|
+
renderOption={(option) => {
|
|
158
|
+
return <StopsFinderOptions option={option} />;
|
|
159
|
+
}}
|
|
160
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
161
|
+
{...autocProps}
|
|
162
|
+
classes={{ ...classes, ...autocompleteProps.classes }}
|
|
163
|
+
inputValue={inputValue}
|
|
164
|
+
open={isOpen}
|
|
165
|
+
options={suggestions}
|
|
166
|
+
loading={isLoading}
|
|
167
|
+
onOpen={() => {
|
|
168
|
+
setOpen(true);
|
|
169
|
+
}}
|
|
170
|
+
onClose={() => {
|
|
171
|
+
setOpen(false);
|
|
172
|
+
}}
|
|
173
|
+
onInputChange={(evt, val) => {
|
|
174
|
+
setInputValue(val);
|
|
175
|
+
}}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
StopsFinder.propTypes = {
|
|
181
|
+
/**
|
|
182
|
+
* Array or a comma separated list of agencies which should be available.
|
|
183
|
+
* Order of these agencies chooses which agency will be preferred.
|
|
184
|
+
* Available values : sbb, db
|
|
185
|
+
*/
|
|
186
|
+
agencies: PropTypes.oneOfType([
|
|
187
|
+
PropTypes.string,
|
|
188
|
+
PropTypes.arrayOf(PropTypes.string),
|
|
189
|
+
]),
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* geOps api key to access the StopsFinder service.
|
|
193
|
+
*/
|
|
194
|
+
apiKey: PropTypes.string,
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Properties apply to the default [MUI Autocomplete component](https://material-ui.com/api/autocomplete/).
|
|
198
|
+
* We add a custom properties textFieldProps for the default [MUI TextField component](https://material-ui.com/api/text-field/) used by the Autocomplete.
|
|
199
|
+
*/
|
|
200
|
+
autocompleteProps: PropTypes.object,
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* minX,minY,maxX,maxY coordinates in WGS84 wherein the station should lie.
|
|
204
|
+
*/
|
|
205
|
+
bbox: PropTypes.oneOfType([
|
|
206
|
+
PropTypes.string,
|
|
207
|
+
PropTypes.arrayOf(PropTypes.number),
|
|
208
|
+
]),
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Array or a comma separated list of fields which should be used for look up.
|
|
212
|
+
* Available values : id, name, coords
|
|
213
|
+
*/
|
|
214
|
+
field: PropTypes.oneOfType([
|
|
215
|
+
PropTypes.string,
|
|
216
|
+
PropTypes.arrayOf(PropTypes.string),
|
|
217
|
+
]),
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Control how many matches will be returned.
|
|
221
|
+
*/
|
|
222
|
+
limit: PropTypes.number,
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* A map.
|
|
226
|
+
*/
|
|
227
|
+
map: PropTypes.instanceOf(Map).isRequired,
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Array or a comma separated list of mode of transpaorts which should be available.
|
|
231
|
+
* Available values : bus, ferry, gondola, tram, rail, funicular, cable_car, subway
|
|
232
|
+
*/
|
|
233
|
+
mots: PropTypes.oneOfType([
|
|
234
|
+
PropTypes.string,
|
|
235
|
+
PropTypes.arrayOf(PropTypes.string),
|
|
236
|
+
]),
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Function called when a suggestion is selected.
|
|
240
|
+
*/
|
|
241
|
+
onSelect: PropTypes.func,
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Radius around refLocation in meters that is most relevant.
|
|
245
|
+
* Used as granularity for location rank.
|
|
246
|
+
*/
|
|
247
|
+
radius: PropTypes.number,
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Coordinates in WGS84 (in lat,lon order) used to rank stops close to this position higher.
|
|
251
|
+
* Available values : id, name, coords
|
|
252
|
+
*/
|
|
253
|
+
refLocation: PropTypes.oneOfType([
|
|
254
|
+
PropTypes.string,
|
|
255
|
+
PropTypes.arrayOf(PropTypes.number),
|
|
256
|
+
]),
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Function to render a different autocomplete input than the default one.
|
|
260
|
+
*/
|
|
261
|
+
renderAutocomplete: PropTypes.func,
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Url of the geOps StopsFinder service.
|
|
265
|
+
*/
|
|
266
|
+
url: PropTypes.string,
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
StopsFinder.defaultProps = {
|
|
270
|
+
agencies: null,
|
|
271
|
+
apiKey: null,
|
|
272
|
+
autocompleteProps: {},
|
|
273
|
+
bbox: null,
|
|
274
|
+
field: null,
|
|
275
|
+
limit: null,
|
|
276
|
+
mots: null,
|
|
277
|
+
onSelect: null,
|
|
278
|
+
radius: null,
|
|
279
|
+
refLocation: null,
|
|
280
|
+
url: null,
|
|
281
|
+
renderAutocomplete: null,
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export default StopsFinder;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
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);
|
|
@@ -0,0 +1,133 @@
|
|
|
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
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './StopsFinder';
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
```
|