mobility-toolbox-js 2.0.0-beta.2 → 2.0.0-beta.8
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/.babelrc +6 -0
- package/.esdoc.json +17 -0
- package/.eslintignore +1 -0
- package/.github/workflows/conventional-pr-title.yml +21 -0
- package/.github/workflows/cypress.yml +29 -0
- package/.github/workflows/nodejs.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/.neutrinorc.js +176 -0
- package/.nvmrc +1 -0
- package/CHANGELOG.md +10 -0
- package/LICENSE +21 -0
- package/README.md +4 -1
- package/__mocks__/mapbox-gl.js +81 -0
- package/__mocks__/maplibre-gl.js +81 -0
- package/commitlint.config.js +1 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/integration/examples/api.spec.js +7 -0
- package/cypress/integration/examples/examples.spec.js +7 -0
- package/cypress/integration/examples/navigation.spec.js +29 -0
- package/cypress/plugins/index.js +21 -0
- package/cypress/support/commands.js +25 -0
- package/cypress/support/index.js +20 -0
- package/cypress.json +4 -0
- package/data/fetchRoute.json +292 -0
- package/data/fetchTrajectories.json +18 -0
- package/data/fetchTrajectoryById.json +3 -0
- package/data/fetchTrajectoryStations.json +18 -0
- package/data/stopsSearch.json +15 -0
- package/documentation.yml +4 -0
- package/esdoc/README.md +27 -0
- package/esdoc/plugins/MyPlugin.js +69 -0
- package/esdoc/plugins/dynamic-property-plugin/Plugin.js +50 -0
- package/esdoc/plugins/externals-plugin/Plugin.js +45 -0
- package/esdoc/plugins/externals-plugin/externals.js +96 -0
- package/global-setup.js +3 -0
- package/{ol/README.md → index.html} +0 -0
- package/indexweb.html +49 -0
- package/jest.config.js +5 -0
- package/package.json +29 -9
- package/pull_request_template.md +17 -0
- package/renovate.json +4 -0
- package/scripts/read-pkg-json.js +22 -0
- package/{api → src/api}/index.js +0 -0
- package/{api → src/api}/routing/RoutingAPI.js +0 -0
- package/{api → src/api}/routing/RoutingAPI.test.js +0 -0
- package/{api → src/api}/stops/StopsAPI.js +0 -0
- package/{api → src/api}/stops/StopsAPI.test.js +0 -0
- package/{api → src/api}/tralis/TralisAPI.js +0 -0
- package/{api → src/api}/tralis/TralisAPI.test.js +0 -0
- package/{api → src/api}/tralis/TralisAPIUtils.js +0 -0
- package/{api → src/api}/tralis/WebSocketConnector.js +0 -0
- package/{api → src/api}/tralis/WebSocketConnector.test.js +0 -0
- package/{api → src/api}/tralis/typedefs.js +0 -0
- package/src/assets/Lato-Black.ttf +0 -0
- package/src/assets/Lato-BlackItalic.ttf +0 -0
- package/src/assets/Lato-Bold.ttf +0 -0
- package/src/assets/Lato-BoldItalic.ttf +0 -0
- package/src/assets/Lato-Italic.ttf +0 -0
- package/src/assets/Lato-Light.ttf +0 -0
- package/src/assets/Lato-LightItalic.ttf +0 -0
- package/src/assets/Lato-Regular.ttf +0 -0
- package/src/assets/Lato-Thin.ttf +0 -0
- package/src/assets/Lato-ThinItalic.ttf +0 -0
- package/src/assets/OFL.txt +93 -0
- package/{common → src/common}/Tracker.js +0 -0
- package/{common → src/common}/api/api.js +0 -0
- package/{common → src/common}/api/api.test.js +0 -0
- package/{common → src/common}/controls/Control.js +0 -0
- package/{common → src/common}/controls/Control.test.js +0 -0
- package/src/common/index.js +5 -0
- package/{common → src/common}/layers/Layer.js +0 -0
- package/{common → src/common}/layers/Layer.test.js +0 -0
- package/{common → src/common}/mixins/CopyrightMixin.js +0 -0
- package/{common → src/common}/mixins/SearchMixin.js +0 -0
- package/{common → src/common}/mixins/TralisLayerMixin.js +0 -0
- package/{common → src/common}/styles/index.js +1 -1
- package/{common → src/common}/styles/trackerDefaultStyle.js +8 -8
- package/{common → src/common}/styles/trackerDelayStyle.js +0 -0
- package/{common → src/common}/styles/trackerSimpleStyle.js +0 -0
- package/{common → src/common}/trackerConfig.js +0 -0
- package/{common → src/common}/trackerConfig.test.js +0 -0
- package/{common → src/common}/typedefs.js +0 -0
- package/{common → src/common}/utils/createTrackerFilters.js +0 -0
- package/{common → src/common}/utils/createTrackerFilters.test.js +0 -0
- package/{common → src/common}/utils/getMapboxMapCopyrights.js +0 -0
- package/{common → src/common}/utils/getMapboxMapCopyrights.test.js +0 -0
- package/{common → src/common}/utils/getMapboxStyleUrl.js +0 -0
- package/{common → src/common}/utils/getVehiclePosition.js +0 -0
- package/{common → src/common}/utils/index.js +0 -1
- package/{common → src/common}/utils/removeDuplicate.js +0 -0
- package/{common → src/common}/utils/removeDuplicate.test.js +0 -0
- package/{common → src/common}/utils/sortByDelay.js +0 -0
- package/{common → src/common}/utils/timeUtils.js +0 -0
- package/{common → src/common}/utils/timeUtils.test.js +0 -0
- package/src/doc/App.js +116 -0
- package/src/doc/App.scss +51 -0
- package/src/doc/_redirects +2 -0
- package/src/doc/components/CodeSandboxButton.js +103 -0
- package/src/doc/components/Documentation.js +40 -0
- package/src/doc/components/Esdoc/Anchor.js +57 -0
- package/src/doc/components/Esdoc/ClassDoc.js +272 -0
- package/src/doc/components/Esdoc/DeprecatedHTML.js +16 -0
- package/src/doc/components/Esdoc/DetailDocs.js +281 -0
- package/src/doc/components/Esdoc/DetailHTML.js +33 -0
- package/src/doc/components/Esdoc/DirectSubclassHTML.js +30 -0
- package/src/doc/components/Esdoc/DocBuilderUtils.js +694 -0
- package/src/doc/components/Esdoc/DocLinkHTML.js +62 -0
- package/src/doc/components/Esdoc/DocsLinkHTML.js +38 -0
- package/src/doc/components/Esdoc/Esdoc.js +63 -0
- package/src/doc/components/Esdoc/EsdocContent.js +51 -0
- package/src/doc/components/Esdoc/EsdocNavigation.js +13 -0
- package/src/doc/components/Esdoc/EsdocSearch.js +81 -0
- package/src/doc/components/Esdoc/ExperimentalHTML.js +17 -0
- package/src/doc/components/Esdoc/ExtendsChainHTML.js +32 -0
- package/src/doc/components/Esdoc/FileDocLinkHTML.js +60 -0
- package/src/doc/components/Esdoc/IdentifiersDoc.js +113 -0
- package/src/doc/components/Esdoc/IndirectSubclassHTML.js +30 -0
- package/src/doc/components/Esdoc/InheritedSummaryDoc.js +70 -0
- package/src/doc/components/Esdoc/InheritedSummaryHTML.js +38 -0
- package/src/doc/components/Esdoc/MixinClassesHTML.js +29 -0
- package/src/doc/components/Esdoc/NavDoc.js +112 -0
- package/src/doc/components/Esdoc/OverrideMethod.js +44 -0
- package/src/doc/components/Esdoc/OverrideMethodDescription.js +35 -0
- package/src/doc/components/Esdoc/Properties.js +89 -0
- package/src/doc/components/Esdoc/README.md +45 -0
- package/src/doc/components/Esdoc/SignatureHTML.js +123 -0
- package/src/doc/components/Esdoc/SingleDoc.js +31 -0
- package/src/doc/components/Esdoc/SummaryDoc.js +160 -0
- package/src/doc/components/Esdoc/SummaryHTML.js +96 -0
- package/src/doc/components/Esdoc/TypeDocLinkHTML.js +249 -0
- package/src/doc/components/Esdoc/css/identifiers.css +38 -0
- package/src/doc/components/Esdoc/css/search.css +76 -0
- package/src/doc/components/Esdoc/css/style.css +603 -0
- package/src/doc/components/Esdoc/index.js +7 -0
- package/src/doc/components/Example.js +153 -0
- package/src/doc/components/Examples.js +183 -0
- package/src/doc/components/Home.js +106 -0
- package/src/doc/components/TrackerExample.js +38 -0
- package/src/doc/examples/assets/tralis-live-map/index.js +11 -0
- package/src/doc/examples/assets/tralis-live-map/s1kreis.svg +105 -0
- package/src/doc/examples/assets/tralis-live-map/s20kreis.svg +101 -0
- package/src/doc/examples/assets/tralis-live-map/s2kreis.svg +95 -0
- package/src/doc/examples/assets/tralis-live-map/s3kreis.svg +95 -0
- package/src/doc/examples/assets/tralis-live-map/s4kreis.svg +95 -0
- package/src/doc/examples/assets/tralis-live-map/s6kreis.svg +95 -0
- package/src/doc/examples/assets/tralis-live-map/s7kreis.svg +95 -0
- package/src/doc/examples/assets/tralis-live-map/s8kreis.svg +93 -0
- package/src/doc/examples/assets/tralis-live-map/unknown.svg +107 -0
- package/src/doc/examples/mb-copyright.html +26 -0
- package/src/doc/examples/mb-copyright.js +37 -0
- package/src/doc/examples/mb-tracker.html +1 -0
- package/src/doc/examples/mb-tracker.js +39 -0
- package/src/doc/examples/mb-tracker.md +1 -0
- package/src/doc/examples/mb-tralis.html +1 -0
- package/src/doc/examples/mb-tralis.js +34 -0
- package/src/doc/examples/ol-copyright.html +26 -0
- package/src/doc/examples/ol-copyright.js +43 -0
- package/src/doc/examples/ol-mapbox-layer.html +1 -0
- package/src/doc/examples/ol-mapbox-layer.js +28 -0
- package/src/doc/examples/ol-mapbox-layer.md +0 -0
- package/src/doc/examples/ol-mapbox-style-layer.html +12 -0
- package/src/doc/examples/ol-mapbox-style-layer.js +44 -0
- package/src/doc/examples/ol-query.html +32 -0
- package/src/doc/examples/ol-query.js +83 -0
- package/src/doc/examples/ol-routing.html +26 -0
- package/src/doc/examples/ol-routing.js +59 -0
- package/src/doc/examples/ol-routing.md +1 -0
- package/src/doc/examples/ol-stop-finder.html +15 -0
- package/src/doc/examples/ol-stop-finder.js +31 -0
- package/src/doc/examples/ol-stop-finder.md +1 -0
- package/src/doc/examples/ol-tracker.html +1 -0
- package/src/doc/examples/ol-tracker.js +44 -0
- package/src/doc/examples/ol-tracker.md +1 -0
- package/src/doc/examples/ol-tralis.html +5 -0
- package/src/doc/examples/ol-tralis.js +57 -0
- package/src/doc/examples/tralis-live-map.html +1 -0
- package/src/doc/examples/tralis-live-map.js +51 -0
- package/src/doc/examples/tralis-live-map.md +3 -0
- package/src/doc/examples.js +107 -0
- package/src/doc/img/examples/live_tracker_mb.jpg +0 -0
- package/src/doc/img/examples/live_tracker_munich.jpg +0 -0
- package/src/doc/img/examples/live_tracker_ol.jpg +0 -0
- package/src/doc/img/examples/mapbox.jpg +0 -0
- package/src/doc/img/examples/mapbox_style.jpg +0 -0
- package/src/doc/img/examples/ol-copyright.png +0 -0
- package/src/doc/img/examples/query_objects.jpg +0 -0
- package/src/doc/img/examples/routing.jpg +0 -0
- package/src/doc/img/examples/simple_map.jpg +0 -0
- package/src/doc/img/examples/stops.jpg +0 -0
- package/src/doc/img/favico.ico +0 -0
- package/src/doc/index.js +21 -0
- package/src/iife.js +7 -0
- package/src/index.js +10 -0
- package/{mapbox → src/mapbox}/controls/CopyrightControl.js +0 -0
- package/src/mapbox/controls/index.js +2 -0
- package/src/mapbox/index.js +4 -0
- package/{mapbox → src/mapbox}/layers/Layer.js +0 -0
- package/{mapbox → src/mapbox}/layers/Layer.test.js +0 -0
- package/{mapbox → src/mapbox}/layers/TralisLayer.js +0 -0
- package/{mapbox → src/mapbox}/layers/TralisLayer.test.js +0 -0
- package/src/mapbox/layers/index.js +2 -0
- package/{mapbox → src/mapbox}/utils.js +0 -0
- package/src/ol/README.md +0 -0
- package/{ol → src/ol}/controls/CopyrightControl.js +0 -0
- package/{ol → src/ol}/controls/CopyrightControl.test.js +0 -0
- package/{ol → src/ol}/controls/RoutingControl.js +0 -0
- package/{ol → src/ol}/controls/RoutingControl.test.js +0 -0
- package/{ol → src/ol}/controls/StopFinderControl.js +0 -0
- package/{ol → src/ol}/controls/StopFinderControl.test.js +0 -0
- package/src/ol/controls/index.js +3 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlRouteGen10.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlRouteGen100.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlRouteGen30.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlRouteGen5.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlRouteOSM.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlStation1.json +0 -0
- package/{ol → src/ol}/controls/snapshots/RoutingControlStation2.json +0 -0
- package/src/ol/index.js +5 -0
- package/{ol → src/ol}/layers/Layer.js +0 -0
- package/{ol → src/ol}/layers/Layer.test.js +0 -0
- package/{ol → src/ol}/layers/MapboxLayer.js +0 -0
- package/{ol → src/ol}/layers/MapboxLayer.test.js +0 -0
- package/{ol → src/ol}/layers/MapboxStyleLayer.js +0 -0
- package/{ol → src/ol}/layers/MapboxStyleLayer.test.js +0 -0
- package/{ol → src/ol}/layers/MaplibreLayer.js +0 -0
- package/{ol → src/ol}/layers/RoutingLayer.js +0 -0
- package/{ol → src/ol}/layers/RoutingLayer.test.js +0 -0
- package/{ol → src/ol}/layers/TralisLayer.js +0 -0
- package/{ol → src/ol}/layers/TralisLayer.test.js +0 -0
- package/{ol → src/ol}/layers/VectorLayer.js +0 -0
- package/{ol → src/ol}/layers/VectorLayer.test.js +0 -0
- package/{ol → src/ol}/layers/WMSLayer.js +0 -0
- package/{ol → src/ol}/layers/WMSLayer.test.js +0 -0
- package/src/ol/layers/index.js +8 -0
- package/{ol → src/ol}/styles/fullTrajectoryDelayStyle.js +0 -0
- package/{ol → src/ol}/styles/fullTrajectoryStyle.js +0 -0
- package/{ol → src/ol}/styles/index.js +0 -0
- package/src/setupTests.js +15 -0
- package/webpack.config.js +6 -0
- package/index.js +0 -2
- package/index.js.map +0 -1
- package/mapbox/index.js +0 -3
- package/module.js +0 -23
- package/ol/index.js +0 -13
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { Grid, Paper, Typography } from '@material-ui/core';
|
|
3
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
4
|
+
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
5
|
+
import { useParams } from 'react-router-dom';
|
|
6
|
+
import Markdown from 'react-markdown';
|
|
7
|
+
import CodeSandboxButton from './CodeSandboxButton';
|
|
8
|
+
import EXAMPLES from '../examples';
|
|
9
|
+
|
|
10
|
+
const useStyles = makeStyles((theme) => ({
|
|
11
|
+
root: {
|
|
12
|
+
padding: 12,
|
|
13
|
+
},
|
|
14
|
+
htmlContainer: {
|
|
15
|
+
height: 500,
|
|
16
|
+
},
|
|
17
|
+
noPointer: {
|
|
18
|
+
// Remove pointer events for mobile devices on load
|
|
19
|
+
[theme.breakpoints.down('xs')]: {
|
|
20
|
+
pointerEvents: 'none',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
paper: {
|
|
24
|
+
position: 'relative',
|
|
25
|
+
margin: '20px 0',
|
|
26
|
+
},
|
|
27
|
+
fileName: {
|
|
28
|
+
padding: '10px 0 5px 15px',
|
|
29
|
+
},
|
|
30
|
+
editButton: {
|
|
31
|
+
position: 'absolute',
|
|
32
|
+
right: 0,
|
|
33
|
+
top: 0,
|
|
34
|
+
paddingTop: 5,
|
|
35
|
+
paddingRight: 10,
|
|
36
|
+
},
|
|
37
|
+
readme: {
|
|
38
|
+
'& p': {
|
|
39
|
+
fontSize: 18,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
function Example() {
|
|
45
|
+
const classes = useStyles();
|
|
46
|
+
const { exampleKey } = useParams((params) => params);
|
|
47
|
+
const example = EXAMPLES.find((e) => e.key === exampleKey);
|
|
48
|
+
const [html, setHtml] = useState();
|
|
49
|
+
const [js, setJs] = useState();
|
|
50
|
+
const [readme, setReadme] = useState();
|
|
51
|
+
const [isNavigable, setIsNavigable] = useState(false);
|
|
52
|
+
const htmlFileName =
|
|
53
|
+
(example.files && example.files.html) || `${exampleKey}.html`;
|
|
54
|
+
const readmeFileName =
|
|
55
|
+
(example.files && example.files.readme) || `${exampleKey}.md`;
|
|
56
|
+
const jsFileName = (example.files && example.files.js) || `${exampleKey}.js`;
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
import(`../examples/${htmlFileName}`).then((h) => {
|
|
60
|
+
// Clean the html loaded by the previous example
|
|
61
|
+
setHtml(null);
|
|
62
|
+
// Load the new html
|
|
63
|
+
setHtml(h.default);
|
|
64
|
+
|
|
65
|
+
// const filePath = `../examples/${example.files.js}?dfdf=ocr`;
|
|
66
|
+
// We use this to avoid cache and re-execute the code of the module.
|
|
67
|
+
import(`../examples/${jsFileName}?`).then((module) => {
|
|
68
|
+
module.default();
|
|
69
|
+
|
|
70
|
+
fetch(`../examples/${jsFileName}`)
|
|
71
|
+
.then((res) => res.text())
|
|
72
|
+
.then((jsCode) => {
|
|
73
|
+
// Replace relative import by library import
|
|
74
|
+
setJs(
|
|
75
|
+
jsCode
|
|
76
|
+
.replace(/'\.\.\/\.\.\//gm, "'mobility-toolbox-js/")
|
|
77
|
+
.replace('export default () => {\n', '')
|
|
78
|
+
.replace(/^};\n$/gm, '')
|
|
79
|
+
.replace(/^ {2}/gm, ''),
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
fetch(`../examples/${readmeFileName}`)
|
|
85
|
+
.then((res) => res.status === 200 && res.text())
|
|
86
|
+
.then((md) => setReadme(md))
|
|
87
|
+
.catch(() => setReadme(''));
|
|
88
|
+
});
|
|
89
|
+
}, [example, htmlFileName, jsFileName, readmeFileName]);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div style={{ margin: 'auto', marginTop: 30 }}>
|
|
93
|
+
<Grid container direction="column" spacing={3}>
|
|
94
|
+
<Grid item xs={12}>
|
|
95
|
+
<Typography variant="h1" className="headline">
|
|
96
|
+
{example.name}
|
|
97
|
+
</Typography>
|
|
98
|
+
<Markdown className={classes.readme}>
|
|
99
|
+
{example.description || ''}
|
|
100
|
+
</Markdown>
|
|
101
|
+
<Markdown className={classes.readme}>{readme || ''}</Markdown>
|
|
102
|
+
</Grid>
|
|
103
|
+
<Grid item xs={12}>
|
|
104
|
+
<Paper className={classes.paper} onClick={() => setIsNavigable(true)}>
|
|
105
|
+
<div
|
|
106
|
+
className={`${classes.htmlContainer} ${
|
|
107
|
+
isNavigable ? '' : classes.noPointer
|
|
108
|
+
}`}
|
|
109
|
+
// eslint-disable-next-line react/no-danger
|
|
110
|
+
dangerouslySetInnerHTML={{ __html: html }}
|
|
111
|
+
/>
|
|
112
|
+
</Paper>
|
|
113
|
+
</Grid>
|
|
114
|
+
{js && html ? (
|
|
115
|
+
<>
|
|
116
|
+
<Grid item xs={12}>
|
|
117
|
+
<Paper className={classes.paper}>
|
|
118
|
+
<Typography className={classes.fileName}>
|
|
119
|
+
{jsFileName}
|
|
120
|
+
</Typography>
|
|
121
|
+
<SyntaxHighlighter language="javascript">
|
|
122
|
+
{js}
|
|
123
|
+
</SyntaxHighlighter>
|
|
124
|
+
<CodeSandboxButton
|
|
125
|
+
className={classes.editButton}
|
|
126
|
+
extraFiles={example.extraFiles || {}}
|
|
127
|
+
html={html}
|
|
128
|
+
js={js}
|
|
129
|
+
/>
|
|
130
|
+
</Paper>
|
|
131
|
+
</Grid>
|
|
132
|
+
<Grid item xs={12}>
|
|
133
|
+
<Paper className={classes.paper}>
|
|
134
|
+
<Typography className={classes.fileName}>
|
|
135
|
+
{htmlFileName}
|
|
136
|
+
</Typography>
|
|
137
|
+
<SyntaxHighlighter language="html">{html}</SyntaxHighlighter>
|
|
138
|
+
<CodeSandboxButton
|
|
139
|
+
className={classes.editButton}
|
|
140
|
+
html={html}
|
|
141
|
+
js={js}
|
|
142
|
+
extraFiles={{}}
|
|
143
|
+
/>
|
|
144
|
+
</Paper>
|
|
145
|
+
</Grid>
|
|
146
|
+
</>
|
|
147
|
+
) : null}
|
|
148
|
+
</Grid>
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default React.memo(Example);
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import Grid from '@material-ui/core/Grid';
|
|
3
|
+
import MuiCard from '@material-ui/core/Card';
|
|
4
|
+
import MuiCardMedia from '@material-ui/core/CardMedia';
|
|
5
|
+
import CardContent from '@material-ui/core/CardContent';
|
|
6
|
+
import CardActions from '@material-ui/core/CardActions';
|
|
7
|
+
import Icon from '@material-ui/core/Icon';
|
|
8
|
+
import Box from '@material-ui/core/Box';
|
|
9
|
+
import Typography from '@material-ui/core/Typography';
|
|
10
|
+
import { makeStyles, withStyles } from '@material-ui/core/styles';
|
|
11
|
+
import { CgArrowRight } from 'react-icons/cg';
|
|
12
|
+
import TextField from '@material-ui/core/TextField';
|
|
13
|
+
import Markdown from 'react-markdown';
|
|
14
|
+
import EXAMPLES from '../examples';
|
|
15
|
+
|
|
16
|
+
const Card = withStyles({
|
|
17
|
+
root: {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
height: '100%',
|
|
21
|
+
width: '100%',
|
|
22
|
+
boxShadow: 'none',
|
|
23
|
+
},
|
|
24
|
+
})(MuiCard);
|
|
25
|
+
|
|
26
|
+
const CardMedia = withStyles({
|
|
27
|
+
root: {
|
|
28
|
+
paddingTop: '56.25%',
|
|
29
|
+
},
|
|
30
|
+
})(MuiCardMedia);
|
|
31
|
+
|
|
32
|
+
const useStyles = makeStyles((theme) => ({
|
|
33
|
+
root: {
|
|
34
|
+
width: '100%',
|
|
35
|
+
padding: theme.spacing(2),
|
|
36
|
+
},
|
|
37
|
+
filterField: {
|
|
38
|
+
width: '100%',
|
|
39
|
+
},
|
|
40
|
+
example: {
|
|
41
|
+
'&.MuiGrid-item': {
|
|
42
|
+
padding: '0 !important',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
exampleLink: {
|
|
46
|
+
height: '100%',
|
|
47
|
+
width: '100%',
|
|
48
|
+
},
|
|
49
|
+
container: {
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flexDirection: 'column',
|
|
52
|
+
justifyContent: 'space-between',
|
|
53
|
+
height: '100%',
|
|
54
|
+
},
|
|
55
|
+
header: {
|
|
56
|
+
marginBottom: 40,
|
|
57
|
+
},
|
|
58
|
+
cardWrapper: {
|
|
59
|
+
position: 'relative',
|
|
60
|
+
height: '100%',
|
|
61
|
+
width: '100%',
|
|
62
|
+
'& .MuiIcon-root': {
|
|
63
|
+
width: 30,
|
|
64
|
+
height: 30,
|
|
65
|
+
'& svg': {
|
|
66
|
+
height: '100%',
|
|
67
|
+
width: '100%',
|
|
68
|
+
},
|
|
69
|
+
margin: 35,
|
|
70
|
+
transition: 'margin-left 500ms ease, color 800ms ease',
|
|
71
|
+
},
|
|
72
|
+
'&:hover': {
|
|
73
|
+
'& .MuiIcon-root': {
|
|
74
|
+
marginLeft: 60,
|
|
75
|
+
color: theme.colors.primaryGreen,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
cardOverlay: {
|
|
80
|
+
position: 'absolute',
|
|
81
|
+
display: 'flex',
|
|
82
|
+
alignItems: 'center',
|
|
83
|
+
height: '100%',
|
|
84
|
+
width: '100%',
|
|
85
|
+
boxSizing: 'border-box',
|
|
86
|
+
boxShadow:
|
|
87
|
+
'inset 0px 1px 3px 0px rgba(0, 0, 0, 0.12), inset 0px -1px 1px 0px rgba(0, 0, 0, 0.14)',
|
|
88
|
+
border: '15px solid white',
|
|
89
|
+
transition: 'border 500ms ease',
|
|
90
|
+
'&:hover': {
|
|
91
|
+
border: '5px solid white',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
const filterExamples = (str, examples) => {
|
|
97
|
+
const qry = str.toLowerCase();
|
|
98
|
+
return examples.filter(
|
|
99
|
+
(ex) =>
|
|
100
|
+
`${ex.name}`.toLowerCase().includes(qry) ||
|
|
101
|
+
(ex.tags || []).find((tag) => tag.toLowerCase().includes(qry)),
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// Get the public api key
|
|
106
|
+
fetch('https://backend.developer.geops.io/publickey')
|
|
107
|
+
.then((response) => response.json())
|
|
108
|
+
.then((data) => {
|
|
109
|
+
if (data && data.success) {
|
|
110
|
+
window.apiKey = data.key;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
function Examples() {
|
|
115
|
+
const classes = useStyles();
|
|
116
|
+
const [filter, setFilter] = useState('');
|
|
117
|
+
const [raisedExampe, setRaisedExample] = useState(null);
|
|
118
|
+
const filteredExamples = filterExamples(filter, EXAMPLES);
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<Grid container spacing={3}>
|
|
122
|
+
<Grid item xs={12} className={classes.filterField}>
|
|
123
|
+
<Typography variant="h1" className={classes.header}>
|
|
124
|
+
Examples
|
|
125
|
+
</Typography>
|
|
126
|
+
<TextField
|
|
127
|
+
placeholder="Filter..."
|
|
128
|
+
value={filter}
|
|
129
|
+
onChange={(e) => setFilter(e.target.value)}
|
|
130
|
+
/>
|
|
131
|
+
</Grid>
|
|
132
|
+
{!filteredExamples.length && (
|
|
133
|
+
<Grid item xs={12}>
|
|
134
|
+
Nothing found.
|
|
135
|
+
</Grid>
|
|
136
|
+
)}
|
|
137
|
+
{filteredExamples.map((ex) => (
|
|
138
|
+
<Grid
|
|
139
|
+
item
|
|
140
|
+
xs={12}
|
|
141
|
+
sm={6}
|
|
142
|
+
lg={4}
|
|
143
|
+
container
|
|
144
|
+
className={classes.example}
|
|
145
|
+
key={ex.key}
|
|
146
|
+
>
|
|
147
|
+
<a href={`/example/${ex.key}`} className={classes.exampleLink}>
|
|
148
|
+
<div className={classes.cardWrapper}>
|
|
149
|
+
<div className={classes.cardOverlay} />
|
|
150
|
+
<Card
|
|
151
|
+
raised={ex === raisedExampe}
|
|
152
|
+
className={classes.card}
|
|
153
|
+
onMouseOver={() => setRaisedExample(ex)}
|
|
154
|
+
onMouseOut={() => setRaisedExample(null)}
|
|
155
|
+
onFocus={() => setRaisedExample(ex)}
|
|
156
|
+
onBlur={() => setRaisedExample(null)}
|
|
157
|
+
>
|
|
158
|
+
<CardMedia image={ex.img} />
|
|
159
|
+
<Box className={classes.container}>
|
|
160
|
+
<CardContent className={classes.cardContent}>
|
|
161
|
+
<Typography variant="h3">{ex.name}</Typography>
|
|
162
|
+
<Typography>
|
|
163
|
+
<Markdown className={classes.readme}>
|
|
164
|
+
{ex.description || ''}
|
|
165
|
+
</Markdown>
|
|
166
|
+
</Typography>
|
|
167
|
+
</CardContent>
|
|
168
|
+
<CardActions>
|
|
169
|
+
<Icon>
|
|
170
|
+
<CgArrowRight />
|
|
171
|
+
</Icon>
|
|
172
|
+
</CardActions>
|
|
173
|
+
</Box>
|
|
174
|
+
</Card>
|
|
175
|
+
</div>
|
|
176
|
+
</a>
|
|
177
|
+
</Grid>
|
|
178
|
+
))}
|
|
179
|
+
</Grid>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export default Examples;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import Markdown from 'react-markdown';
|
|
3
|
+
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
4
|
+
import Typography from '@material-ui/core/Typography';
|
|
5
|
+
import TrackerExample from './TrackerExample';
|
|
6
|
+
|
|
7
|
+
const codeHtmlPage = `
|
|
8
|
+
<html>
|
|
9
|
+
<head>
|
|
10
|
+
<title>Realtime map</title>
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<div id="map" style="height: 300px; width: 100%" />
|
|
14
|
+
</body>
|
|
15
|
+
</html>
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
const codeMapObject = `
|
|
19
|
+
import { Map } from 'maplibre-gl;
|
|
20
|
+
import { TralisLayer } from 'mobility-toolbox-js/mapbox';
|
|
21
|
+
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
22
|
+
|
|
23
|
+
const map = new Map({
|
|
24
|
+
container: 'map',
|
|
25
|
+
style: 'https://maps.geops.io/styles/travic_v2/style.json?key=' + window.apiKey,
|
|
26
|
+
center: [7.4707, 46.95],
|
|
27
|
+
zoom: 12,
|
|
28
|
+
});
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const codeTracker = `
|
|
32
|
+
const tracker = new TralisLayer({
|
|
33
|
+
url: 'wss://api.geops.io/tracker-ws/v1/',
|
|
34
|
+
apiKey: window.apiKey,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
tracker.init(map);
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
function MarkdownHeading({ ...props }) {
|
|
41
|
+
// eslint-disable-next-line react/prop-types
|
|
42
|
+
const { level, children } = props;
|
|
43
|
+
return <Typography variant={`h${level}`}>{children}</Typography>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function Home() {
|
|
47
|
+
const [source, setSource] = useState(null);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
fetch('../../../README.md')
|
|
50
|
+
.then((response) => response.text())
|
|
51
|
+
.then((text) => {
|
|
52
|
+
// only show the 'Documentation and examples' section on GitHub
|
|
53
|
+
const noDocText = text.split('## Documentation')[0];
|
|
54
|
+
setSource(noDocText);
|
|
55
|
+
});
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
if (!source) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const renderers = {
|
|
63
|
+
heading: MarkdownHeading,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<Markdown renderers={renderers}>{source}</Markdown>
|
|
69
|
+
<br />
|
|
70
|
+
<h2>Quick Start</h2>
|
|
71
|
+
<TrackerExample />
|
|
72
|
+
<p>
|
|
73
|
+
This example shows how to draw real time vehicle positions on a{' '}
|
|
74
|
+
<a
|
|
75
|
+
href="https://maplibre.org/maplibre-gl-js-docs/"
|
|
76
|
+
rel="noreferrer"
|
|
77
|
+
target="_blank"
|
|
78
|
+
>
|
|
79
|
+
Maplibre GL JS
|
|
80
|
+
</a>{' '}
|
|
81
|
+
map. Check out the{' '}
|
|
82
|
+
<a href="/example/ol-tracker">Live Tracker with OpenLayers</a> example
|
|
83
|
+
to see how to use{' '}
|
|
84
|
+
<a href="https://openlayers.org/" target="_blank" rel="noreferrer">
|
|
85
|
+
OpenLayers
|
|
86
|
+
</a>{' '}
|
|
87
|
+
instead.
|
|
88
|
+
</p>
|
|
89
|
+
<p>First, create a HTML page with an empty map container.</p>
|
|
90
|
+
<SyntaxHighlighter language="html" code={codeHtmlPage.trim()} />
|
|
91
|
+
<p>Create a Maplibre map.</p>
|
|
92
|
+
<SyntaxHighlighter language="js" code={codeMapObject.trim()} />
|
|
93
|
+
<p>
|
|
94
|
+
Finally, add the <i>TralisLayer</i> for rendering real time vehicle
|
|
95
|
+
positions from our Realtime API. For more information about the backend
|
|
96
|
+
and for obtaining the required API-Key, visit our Developer Portal at{' '}
|
|
97
|
+
<a target="_blank" rel="noreferrer" href="https://geops.io">
|
|
98
|
+
https://geops.io
|
|
99
|
+
</a>
|
|
100
|
+
.
|
|
101
|
+
</p>
|
|
102
|
+
<SyntaxHighlighter language="js" code={codeTracker.trim()} />
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
export default Home;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
3
|
+
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
4
|
+
import { Map } from 'maplibre-gl';
|
|
5
|
+
import { TralisLayer } from '../../mapbox';
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles({
|
|
8
|
+
root: {
|
|
9
|
+
width: '100%',
|
|
10
|
+
height: 300,
|
|
11
|
+
pointerEvents: 'none',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function TrackerExample() {
|
|
16
|
+
const classes = useStyles();
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const map = new Map({
|
|
20
|
+
container: 'map',
|
|
21
|
+
style: `https://maps.geops.io/styles/travic_v2/style.json?key=${window.apiKey}`,
|
|
22
|
+
center: [7.4707, 46.95],
|
|
23
|
+
zoom: 12,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const tracker = new TralisLayer({
|
|
27
|
+
url: 'wss://api.geops.io/tracker-ws/v1/',
|
|
28
|
+
apiKey: window.apiKey,
|
|
29
|
+
isQueryable: false,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
tracker.init(map);
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
return <div id="map" className={classes.root} />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default TrackerExample;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import S1 from './s1kreis.svg';
|
|
2
|
+
import S20 from './s20kreis.svg';
|
|
3
|
+
import S2 from './s2kreis.svg';
|
|
4
|
+
import S3 from './s3kreis.svg';
|
|
5
|
+
import S4 from './s4kreis.svg';
|
|
6
|
+
import S6 from './s6kreis.svg';
|
|
7
|
+
import S7 from './s7kreis.svg';
|
|
8
|
+
import S8 from './s8kreis.svg';
|
|
9
|
+
import unknown from './unknown.svg';
|
|
10
|
+
|
|
11
|
+
export default { S1, S20, S2, S3, S4, S6, S7, S8, unknown };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<svg
|
|
3
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
4
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
|
5
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
6
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
9
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
10
|
+
width="25"
|
|
11
|
+
height="24.999998"
|
|
12
|
+
viewBox="0 0 25 24.999998"
|
|
13
|
+
version="1.1"
|
|
14
|
+
id="svg10"
|
|
15
|
+
sodipodi:docname="s1kreis.svg"
|
|
16
|
+
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)">
|
|
17
|
+
<metadata
|
|
18
|
+
id="metadata16">
|
|
19
|
+
<rdf:RDF>
|
|
20
|
+
<cc:Work
|
|
21
|
+
rdf:about="">
|
|
22
|
+
<dc:format>image/svg+xml</dc:format>
|
|
23
|
+
<dc:type
|
|
24
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
25
|
+
<dc:title></dc:title>
|
|
26
|
+
</cc:Work>
|
|
27
|
+
</rdf:RDF>
|
|
28
|
+
</metadata>
|
|
29
|
+
<defs
|
|
30
|
+
id="defs14" />
|
|
31
|
+
<sodipodi:namedview
|
|
32
|
+
pagecolor="#ffffff"
|
|
33
|
+
bordercolor="#666666"
|
|
34
|
+
borderopacity="1"
|
|
35
|
+
objecttolerance="10"
|
|
36
|
+
gridtolerance="10"
|
|
37
|
+
guidetolerance="10"
|
|
38
|
+
inkscape:pageopacity="0"
|
|
39
|
+
inkscape:pageshadow="2"
|
|
40
|
+
inkscape:window-width="2149"
|
|
41
|
+
inkscape:window-height="1712"
|
|
42
|
+
id="namedview12"
|
|
43
|
+
showgrid="false"
|
|
44
|
+
fit-margin-top="0"
|
|
45
|
+
fit-margin-left="0"
|
|
46
|
+
fit-margin-right="0"
|
|
47
|
+
fit-margin-bottom="0"
|
|
48
|
+
lock-margins="true"
|
|
49
|
+
inkscape:zoom="3.9126575"
|
|
50
|
+
inkscape:cx="54.716242"
|
|
51
|
+
inkscape:cy="165.95994"
|
|
52
|
+
inkscape:window-x="2391"
|
|
53
|
+
inkscape:window-y="0"
|
|
54
|
+
inkscape:window-maximized="0"
|
|
55
|
+
inkscape:current-layer="Gruppe_143" />
|
|
56
|
+
<rect
|
|
57
|
+
id="Rechteck_33"
|
|
58
|
+
data-name="Rechteck 33"
|
|
59
|
+
width="150"
|
|
60
|
+
height="150"
|
|
61
|
+
fill="none"
|
|
62
|
+
x="-36.299999"
|
|
63
|
+
y="-36.299999" />
|
|
64
|
+
<g
|
|
65
|
+
id="Gruppe_143"
|
|
66
|
+
data-name="Gruppe 143"
|
|
67
|
+
opacity="0.85"
|
|
68
|
+
transform="translate(-36.3,-36.3)">
|
|
69
|
+
<circle
|
|
70
|
+
id="Ellipse_17"
|
|
71
|
+
data-name="Ellipse 17"
|
|
72
|
+
cx="48.799999"
|
|
73
|
+
cy="48.799999"
|
|
74
|
+
r="12.499999"
|
|
75
|
+
fill="#00b6e2"
|
|
76
|
+
style="stroke-width: 0.322997;" />
|
|
77
|
+
<rect
|
|
78
|
+
id="Rechteck_43"
|
|
79
|
+
data-name="Rechteck 43"
|
|
80
|
+
width="150"
|
|
81
|
+
height="150"
|
|
82
|
+
transform="translate(-1,3)"
|
|
83
|
+
fill="none"
|
|
84
|
+
x="0"
|
|
85
|
+
y="0" />
|
|
86
|
+
</g>
|
|
87
|
+
<path
|
|
88
|
+
id="Pfad_473"
|
|
89
|
+
data-name="Pfad 473"
|
|
90
|
+
d="m 3.8435878,14.696072 h 2.196336 c 0.1937943,1.324261 0.8397756,1.808747 2.4547286,1.808747 1.1304671,0 2.0994386,-0.387588 2.0994386,-1.421158 0,-1.03357 -1.0335697,-1.227364 -2.6485227,-1.614953 -1.9056445,-0.484486 -3.7143918,-0.936672 -3.7143918,-3.229906 0,-2.1963362 1.7118502,-3.2299061 4.1665787,-3.2299061 2.4547288,0 4.0050838,1.2273643 4.1665788,3.4237001 H 10.464895 C 10.367998,9.3021292 9.5282222,8.8176433 8.3654562,8.8176433 c -1.1627662,0 -2.0025418,0.4844859 -2.0025418,1.2273637 0,0.839776 0.7751774,1.130467 2.3901305,1.518056 2.2932331,0.484486 4.0696821,1.03357 4.0696821,3.326804 0,2.196336 -1.808748,3.4237 -4.2634765,3.4237 -3.0038126,-0.0323 -4.6187655,-1.35656 -4.7156627,-3.617495 z"
|
|
91
|
+
fill="#ffffff"
|
|
92
|
+
style="stroke-width: 0.32299;" />
|
|
93
|
+
<path
|
|
94
|
+
id="Pfad_474"
|
|
95
|
+
data-name="Pfad 474"
|
|
96
|
+
d="M 17.409193,10.594091 H 15.148259 V 9.4636244 c 1.130467,0 2.260934,-0.3875887 2.648523,-1.9056445 h 1.905645 V 18.152072 h -2.260935 z"
|
|
97
|
+
fill="#ffffff"
|
|
98
|
+
style="stroke-width: 0.32299;" />
|
|
99
|
+
<path
|
|
100
|
+
id="Pfad_472"
|
|
101
|
+
data-name="Pfad 472"
|
|
102
|
+
d="M 12.499736,1.5180558 A 10.557917,10.557917 0 0 1 23.093828,12.039797 v 0.07235 c 0,5.684635 -4.909458,10.981681 -10.594092,10.981681 -5.6846348,0 -10.5940917,-4.909458 -10.5940917,-10.981681 v 0 A 10.578265,10.578265 0 0 1 12.467437,1.5180558 h 0.0323 M 12.499737,0 a 12.499736,12.499736 0 1 0 12.499736,12.499736 v 0 A 12.386043,12.386043 0 0 0 12.728413,0 Z"
|
|
103
|
+
fill="#00b6e2"
|
|
104
|
+
style="stroke-width: 0.32299;" />
|
|
105
|
+
</svg>
|