mobility-toolbox-js 2.0.0-beta.3 → 2.0.0-beta.6
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/Layer.js +2 -0
- package/Layer.js.map +7 -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/{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 +0 -0
- 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 -0
- 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/components/esm.min.js +2 -0
- package/src/doc/components/examples/assets/tralis-live-map/index.js +11 -0
- package/src/doc/components/examples/assets/tralis-live-map/s1kreis.svg +105 -0
- package/src/doc/components/examples/assets/tralis-live-map/s20kreis.svg +101 -0
- package/src/doc/components/examples/assets/tralis-live-map/s2kreis.svg +95 -0
- package/src/doc/components/examples/assets/tralis-live-map/s3kreis.svg +95 -0
- package/src/doc/components/examples/assets/tralis-live-map/s4kreis.svg +95 -0
- package/src/doc/components/examples/assets/tralis-live-map/s6kreis.svg +95 -0
- package/src/doc/components/examples/assets/tralis-live-map/s7kreis.svg +95 -0
- package/src/doc/components/examples/assets/tralis-live-map/s8kreis.svg +93 -0
- package/src/doc/components/examples/assets/tralis-live-map/unknown.svg +107 -0
- package/src/doc/components/examples/mb-copyright.html +26 -0
- package/src/doc/components/examples/mb-copyright.js +37 -0
- package/src/doc/components/examples/mb-tracker.html +1 -0
- package/src/doc/components/examples/mb-tracker.js +39 -0
- package/src/doc/components/examples/mb-tracker.md +1 -0
- package/src/doc/components/examples/mb-tralis.html +1 -0
- package/src/doc/components/examples/mb-tralis.js +34 -0
- package/src/doc/components/examples/ol-copyright.html +26 -0
- package/src/doc/components/examples/ol-copyright.js +43 -0
- package/src/doc/components/examples/ol-mapbox-layer.html +1 -0
- package/src/doc/components/examples/ol-mapbox-layer.js +28 -0
- package/src/doc/components/examples/ol-mapbox-layer.md +0 -0
- package/src/doc/components/examples/ol-mapbox-style-layer.html +12 -0
- package/src/doc/components/examples/ol-mapbox-style-layer.js +44 -0
- package/src/doc/components/examples/ol-query.html +32 -0
- package/src/doc/components/examples/ol-query.js +83 -0
- package/src/doc/components/examples/ol-routing.html +26 -0
- package/src/doc/components/examples/ol-routing.js +59 -0
- package/src/doc/components/examples/ol-routing.md +1 -0
- package/src/doc/components/examples/ol-stop-finder.html +15 -0
- package/src/doc/components/examples/ol-stop-finder.js +31 -0
- package/src/doc/components/examples/ol-stop-finder.md +1 -0
- package/src/doc/components/examples/ol-tracker.html +1 -0
- package/src/doc/components/examples/ol-tracker.js +44 -0
- package/src/doc/components/examples/ol-tracker.md +1 -0
- package/src/doc/components/examples/ol-tralis.html +5 -0
- package/src/doc/components/examples/ol-tralis.js +57 -0
- package/src/doc/components/examples/tralis-live-map.html +1 -0
- package/src/doc/components/examples/tralis-live-map.js +51 -0
- package/src/doc/components/examples/tralis-live-map.md +3 -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/{module.js → src/index.js} +2 -0
- package/{mapbox → src/mapbox}/controls/CopyrightControl.js +0 -0
- package/{mapbox → src/mapbox}/index.js +0 -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/{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/{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/{ol → src/ol}/index.js +0 -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/{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
|
@@ -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;
|