mobility-toolbox-js 2.0.0-beta.8 → 2.0.1-beta.13

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.
Files changed (304) hide show
  1. package/api/RoutingAPI.js +15 -0
  2. package/api/RoutingAPI.test.js +25 -0
  3. package/api/StopsAPI.js +12 -0
  4. package/api/StopsAPI.test.js +22 -0
  5. package/api/TralisAPI.js +359 -0
  6. package/api/TralisAPI.test.js +67 -0
  7. package/{src/api/tralis → api}/TralisAPIUtils.js +2 -32
  8. package/api/index.js +3 -0
  9. package/{index.html → api/typedefs.js} +0 -0
  10. package/common/Tracker.js +93 -0
  11. package/common/api/HttpAPI.js +30 -0
  12. package/common/api/HttpAPI.test.js +50 -0
  13. package/common/api/WebSocketAPI.js +175 -0
  14. package/{src/api/tralis/WebSocketConnector.test.js → common/api/WebSocketAPI.test.js} +100 -145
  15. package/common/controls/Control.js +81 -0
  16. package/{src/common → common}/controls/Control.test.js +32 -43
  17. package/common/index.js +4 -0
  18. package/common/layers/Layer.js +213 -0
  19. package/{src/common → common}/layers/Layer.test.js +185 -244
  20. package/common/mixins/CopyrightMixin.js +24 -0
  21. package/common/mixins/SearchMixin.js +110 -0
  22. package/common/mixins/TralisLayerMixin.js +479 -0
  23. package/common/styles/index.js +4 -0
  24. package/{src/common → common}/styles/trackerDefaultStyle.js +39 -175
  25. package/common/styles/trackerDelayStyle.js +8 -0
  26. package/{src/common → common}/styles/trackerSimpleStyle.js +4 -8
  27. package/{src/common → common}/trackerConfig.js +61 -99
  28. package/common/trackerConfig.test.js +23 -0
  29. package/{src/doc/examples/ol-mapbox-layer.md → common/typedefs.js} +0 -0
  30. package/common/utils/createTrackerFilters.js +56 -0
  31. package/common/utils/createTrackerFilters.test.js +79 -0
  32. package/{src/common → common}/utils/getMapboxMapCopyrights.js +3 -16
  33. package/common/utils/getMapboxMapCopyrights.test.js +40 -0
  34. package/{src/common → common}/utils/getMapboxStyleUrl.js +3 -13
  35. package/{src/common → common}/utils/getVehiclePosition.js +3 -33
  36. package/common/utils/index.js +5 -0
  37. package/common/utils/removeDuplicate.js +8 -0
  38. package/common/utils/removeDuplicate.test.js +19 -0
  39. package/{src/common → common}/utils/sortByDelay.js +2 -7
  40. package/common/utils/timeUtils.js +20 -0
  41. package/common/utils/timeUtils.test.js +10 -0
  42. package/index.js +8 -0
  43. package/mapbox/controls/CopyrightControl.js +29 -0
  44. package/mapbox/controls/index.js +1 -0
  45. package/mapbox/index.js +4 -0
  46. package/mapbox/layers/Layer.js +57 -0
  47. package/mapbox/layers/Layer.test.js +182 -0
  48. package/mapbox/layers/TralisLayer.js +182 -0
  49. package/{src/mapbox → mapbox}/layers/TralisLayer.test.js +12 -14
  50. package/mapbox/layers/index.js +2 -0
  51. package/{src/mapbox → mapbox}/utils.js +7 -21
  52. package/mbt.js +50444 -0
  53. package/mbt.js.map +7 -0
  54. package/mbt.min.js +1005 -0
  55. package/mbt.min.js.map +7 -0
  56. package/ol/controls/CopyrightControl.js +42 -0
  57. package/ol/controls/CopyrightControl.test.js +165 -0
  58. package/ol/controls/RoutingControl.js +387 -0
  59. package/ol/controls/RoutingControl.test.js +151 -0
  60. package/ol/controls/StopFinderControl.js +10 -0
  61. package/ol/controls/StopFinderControl.test.js +48 -0
  62. package/ol/controls/index.js +3 -0
  63. package/ol/index.js +5 -0
  64. package/ol/layers/Layer.js +88 -0
  65. package/ol/layers/Layer.test.js +174 -0
  66. package/ol/layers/MapboxLayer.js +203 -0
  67. package/{src/ol → ol}/layers/MapboxLayer.test.js +58 -84
  68. package/ol/layers/MapboxStyleLayer.js +187 -0
  69. package/{src/ol → ol}/layers/MapboxStyleLayer.test.js +97 -128
  70. package/ol/layers/MaplibreLayer.js +139 -0
  71. package/ol/layers/RoutingLayer.js +61 -0
  72. package/{src/ol → ol}/layers/RoutingLayer.test.js +15 -24
  73. package/ol/layers/TralisLayer.js +185 -0
  74. package/ol/layers/TralisLayer.test.js +79 -0
  75. package/ol/layers/VectorLayer.js +22 -0
  76. package/{src/ol → ol}/layers/VectorLayer.test.js +34 -45
  77. package/ol/layers/WMSLayer.js +38 -0
  78. package/ol/layers/WMSLayer.test.js +76 -0
  79. package/ol/layers/index.js +8 -0
  80. package/{src/ol → ol}/styles/fullTrajectoryDelayStyle.js +11 -15
  81. package/ol/styles/fullTrajectoryStyle.js +43 -0
  82. package/ol/styles/index.js +2 -0
  83. package/package.json +34 -74
  84. package/.babelrc +0 -6
  85. package/.esdoc.json +0 -17
  86. package/.eslintignore +0 -1
  87. package/.github/workflows/conventional-pr-title.yml +0 -21
  88. package/.github/workflows/cypress.yml +0 -29
  89. package/.github/workflows/nodejs.yml +0 -28
  90. package/.husky/commit-msg +0 -4
  91. package/.husky/post-checkout +0 -4
  92. package/.husky/post-merge +0 -4
  93. package/.husky/post-rebase +0 -4
  94. package/.husky/pre-commit +0 -4
  95. package/.neutrinorc.js +0 -176
  96. package/.nvmrc +0 -1
  97. package/CHANGELOG.md +0 -10
  98. package/LICENSE +0 -21
  99. package/__mocks__/mapbox-gl.js +0 -81
  100. package/__mocks__/maplibre-gl.js +0 -81
  101. package/commitlint.config.js +0 -1
  102. package/cypress/fixtures/example.json +0 -5
  103. package/cypress/integration/examples/api.spec.js +0 -7
  104. package/cypress/integration/examples/examples.spec.js +0 -7
  105. package/cypress/integration/examples/navigation.spec.js +0 -29
  106. package/cypress/plugins/index.js +0 -21
  107. package/cypress/support/commands.js +0 -25
  108. package/cypress/support/index.js +0 -20
  109. package/cypress.json +0 -4
  110. package/data/fetchRoute.json +0 -292
  111. package/data/fetchTrajectories.json +0 -18
  112. package/data/fetchTrajectoryById.json +0 -3
  113. package/data/fetchTrajectoryStations.json +0 -18
  114. package/data/stopsSearch.json +0 -15
  115. package/documentation.yml +0 -4
  116. package/esdoc/README.md +0 -27
  117. package/esdoc/plugins/MyPlugin.js +0 -69
  118. package/esdoc/plugins/dynamic-property-plugin/Plugin.js +0 -50
  119. package/esdoc/plugins/externals-plugin/Plugin.js +0 -45
  120. package/esdoc/plugins/externals-plugin/externals.js +0 -96
  121. package/global-setup.js +0 -3
  122. package/indexweb.html +0 -49
  123. package/jest.config.js +0 -5
  124. package/pull_request_template.md +0 -17
  125. package/renovate.json +0 -4
  126. package/scripts/read-pkg-json.js +0 -22
  127. package/src/api/index.js +0 -3
  128. package/src/api/routing/RoutingAPI.js +0 -44
  129. package/src/api/routing/RoutingAPI.test.js +0 -41
  130. package/src/api/stops/StopsAPI.js +0 -41
  131. package/src/api/stops/StopsAPI.test.js +0 -34
  132. package/src/api/tralis/TralisAPI.js +0 -731
  133. package/src/api/tralis/TralisAPI.test.js +0 -75
  134. package/src/api/tralis/WebSocketConnector.js +0 -338
  135. package/src/api/tralis/typedefs.js +0 -81
  136. package/src/assets/Lato-Black.ttf +0 -0
  137. package/src/assets/Lato-BlackItalic.ttf +0 -0
  138. package/src/assets/Lato-Bold.ttf +0 -0
  139. package/src/assets/Lato-BoldItalic.ttf +0 -0
  140. package/src/assets/Lato-Italic.ttf +0 -0
  141. package/src/assets/Lato-Light.ttf +0 -0
  142. package/src/assets/Lato-LightItalic.ttf +0 -0
  143. package/src/assets/Lato-Regular.ttf +0 -0
  144. package/src/assets/Lato-Thin.ttf +0 -0
  145. package/src/assets/Lato-ThinItalic.ttf +0 -0
  146. package/src/assets/OFL.txt +0 -93
  147. package/src/common/Tracker.js +0 -197
  148. package/src/common/api/api.js +0 -64
  149. package/src/common/api/api.test.js +0 -68
  150. package/src/common/controls/Control.js +0 -146
  151. package/src/common/index.js +0 -5
  152. package/src/common/layers/Layer.js +0 -404
  153. package/src/common/mixins/CopyrightMixin.js +0 -48
  154. package/src/common/mixins/SearchMixin.js +0 -176
  155. package/src/common/mixins/TralisLayerMixin.js +0 -930
  156. package/src/common/styles/index.js +0 -4
  157. package/src/common/styles/trackerDelayStyle.js +0 -17
  158. package/src/common/trackerConfig.test.js +0 -25
  159. package/src/common/typedefs.js +0 -23
  160. package/src/common/utils/createTrackerFilters.js +0 -87
  161. package/src/common/utils/createTrackerFilters.test.js +0 -95
  162. package/src/common/utils/getMapboxMapCopyrights.test.js +0 -47
  163. package/src/common/utils/index.js +0 -5
  164. package/src/common/utils/removeDuplicate.js +0 -22
  165. package/src/common/utils/removeDuplicate.test.js +0 -22
  166. package/src/common/utils/timeUtils.js +0 -44
  167. package/src/common/utils/timeUtils.test.js +0 -16
  168. package/src/doc/App.js +0 -116
  169. package/src/doc/App.scss +0 -51
  170. package/src/doc/_redirects +0 -2
  171. package/src/doc/components/CodeSandboxButton.js +0 -103
  172. package/src/doc/components/Documentation.js +0 -40
  173. package/src/doc/components/Esdoc/Anchor.js +0 -57
  174. package/src/doc/components/Esdoc/ClassDoc.js +0 -272
  175. package/src/doc/components/Esdoc/DeprecatedHTML.js +0 -16
  176. package/src/doc/components/Esdoc/DetailDocs.js +0 -281
  177. package/src/doc/components/Esdoc/DetailHTML.js +0 -33
  178. package/src/doc/components/Esdoc/DirectSubclassHTML.js +0 -30
  179. package/src/doc/components/Esdoc/DocBuilderUtils.js +0 -694
  180. package/src/doc/components/Esdoc/DocLinkHTML.js +0 -62
  181. package/src/doc/components/Esdoc/DocsLinkHTML.js +0 -38
  182. package/src/doc/components/Esdoc/Esdoc.js +0 -63
  183. package/src/doc/components/Esdoc/EsdocContent.js +0 -51
  184. package/src/doc/components/Esdoc/EsdocNavigation.js +0 -13
  185. package/src/doc/components/Esdoc/EsdocSearch.js +0 -81
  186. package/src/doc/components/Esdoc/ExperimentalHTML.js +0 -17
  187. package/src/doc/components/Esdoc/ExtendsChainHTML.js +0 -32
  188. package/src/doc/components/Esdoc/FileDocLinkHTML.js +0 -60
  189. package/src/doc/components/Esdoc/IdentifiersDoc.js +0 -113
  190. package/src/doc/components/Esdoc/IndirectSubclassHTML.js +0 -30
  191. package/src/doc/components/Esdoc/InheritedSummaryDoc.js +0 -70
  192. package/src/doc/components/Esdoc/InheritedSummaryHTML.js +0 -38
  193. package/src/doc/components/Esdoc/MixinClassesHTML.js +0 -29
  194. package/src/doc/components/Esdoc/NavDoc.js +0 -112
  195. package/src/doc/components/Esdoc/OverrideMethod.js +0 -44
  196. package/src/doc/components/Esdoc/OverrideMethodDescription.js +0 -35
  197. package/src/doc/components/Esdoc/Properties.js +0 -89
  198. package/src/doc/components/Esdoc/README.md +0 -45
  199. package/src/doc/components/Esdoc/SignatureHTML.js +0 -123
  200. package/src/doc/components/Esdoc/SingleDoc.js +0 -31
  201. package/src/doc/components/Esdoc/SummaryDoc.js +0 -160
  202. package/src/doc/components/Esdoc/SummaryHTML.js +0 -96
  203. package/src/doc/components/Esdoc/TypeDocLinkHTML.js +0 -249
  204. package/src/doc/components/Esdoc/css/identifiers.css +0 -38
  205. package/src/doc/components/Esdoc/css/search.css +0 -76
  206. package/src/doc/components/Esdoc/css/style.css +0 -603
  207. package/src/doc/components/Esdoc/index.js +0 -7
  208. package/src/doc/components/Example.js +0 -153
  209. package/src/doc/components/Examples.js +0 -183
  210. package/src/doc/components/Home.js +0 -106
  211. package/src/doc/components/TrackerExample.js +0 -38
  212. package/src/doc/examples/assets/tralis-live-map/index.js +0 -11
  213. package/src/doc/examples/assets/tralis-live-map/s1kreis.svg +0 -105
  214. package/src/doc/examples/assets/tralis-live-map/s20kreis.svg +0 -101
  215. package/src/doc/examples/assets/tralis-live-map/s2kreis.svg +0 -95
  216. package/src/doc/examples/assets/tralis-live-map/s3kreis.svg +0 -95
  217. package/src/doc/examples/assets/tralis-live-map/s4kreis.svg +0 -95
  218. package/src/doc/examples/assets/tralis-live-map/s6kreis.svg +0 -95
  219. package/src/doc/examples/assets/tralis-live-map/s7kreis.svg +0 -95
  220. package/src/doc/examples/assets/tralis-live-map/s8kreis.svg +0 -93
  221. package/src/doc/examples/assets/tralis-live-map/unknown.svg +0 -107
  222. package/src/doc/examples/mb-copyright.html +0 -26
  223. package/src/doc/examples/mb-copyright.js +0 -37
  224. package/src/doc/examples/mb-tracker.html +0 -1
  225. package/src/doc/examples/mb-tracker.js +0 -39
  226. package/src/doc/examples/mb-tracker.md +0 -1
  227. package/src/doc/examples/mb-tralis.html +0 -1
  228. package/src/doc/examples/mb-tralis.js +0 -34
  229. package/src/doc/examples/ol-copyright.html +0 -26
  230. package/src/doc/examples/ol-copyright.js +0 -43
  231. package/src/doc/examples/ol-mapbox-layer.html +0 -1
  232. package/src/doc/examples/ol-mapbox-layer.js +0 -28
  233. package/src/doc/examples/ol-mapbox-style-layer.html +0 -12
  234. package/src/doc/examples/ol-mapbox-style-layer.js +0 -44
  235. package/src/doc/examples/ol-query.html +0 -32
  236. package/src/doc/examples/ol-query.js +0 -83
  237. package/src/doc/examples/ol-routing.html +0 -26
  238. package/src/doc/examples/ol-routing.js +0 -59
  239. package/src/doc/examples/ol-routing.md +0 -1
  240. package/src/doc/examples/ol-stop-finder.html +0 -15
  241. package/src/doc/examples/ol-stop-finder.js +0 -31
  242. package/src/doc/examples/ol-stop-finder.md +0 -1
  243. package/src/doc/examples/ol-tracker.html +0 -1
  244. package/src/doc/examples/ol-tracker.js +0 -44
  245. package/src/doc/examples/ol-tracker.md +0 -1
  246. package/src/doc/examples/ol-tralis.html +0 -5
  247. package/src/doc/examples/ol-tralis.js +0 -57
  248. package/src/doc/examples/tralis-live-map.html +0 -1
  249. package/src/doc/examples/tralis-live-map.js +0 -51
  250. package/src/doc/examples/tralis-live-map.md +0 -3
  251. package/src/doc/examples.js +0 -107
  252. package/src/doc/img/examples/live_tracker_mb.jpg +0 -0
  253. package/src/doc/img/examples/live_tracker_munich.jpg +0 -0
  254. package/src/doc/img/examples/live_tracker_ol.jpg +0 -0
  255. package/src/doc/img/examples/mapbox.jpg +0 -0
  256. package/src/doc/img/examples/mapbox_style.jpg +0 -0
  257. package/src/doc/img/examples/ol-copyright.png +0 -0
  258. package/src/doc/img/examples/query_objects.jpg +0 -0
  259. package/src/doc/img/examples/routing.jpg +0 -0
  260. package/src/doc/img/examples/simple_map.jpg +0 -0
  261. package/src/doc/img/examples/stops.jpg +0 -0
  262. package/src/doc/img/favico.ico +0 -0
  263. package/src/doc/index.js +0 -21
  264. package/src/iife.js +0 -7
  265. package/src/index.js +0 -10
  266. package/src/mapbox/controls/CopyrightControl.js +0 -58
  267. package/src/mapbox/controls/index.js +0 -2
  268. package/src/mapbox/index.js +0 -4
  269. package/src/mapbox/layers/Layer.js +0 -118
  270. package/src/mapbox/layers/Layer.test.js +0 -202
  271. package/src/mapbox/layers/TralisLayer.js +0 -329
  272. package/src/mapbox/layers/index.js +0 -2
  273. package/src/ol/README.md +0 -0
  274. package/src/ol/controls/CopyrightControl.js +0 -80
  275. package/src/ol/controls/CopyrightControl.test.js +0 -211
  276. package/src/ol/controls/RoutingControl.js +0 -752
  277. package/src/ol/controls/RoutingControl.test.js +0 -216
  278. package/src/ol/controls/StopFinderControl.js +0 -38
  279. package/src/ol/controls/StopFinderControl.test.js +0 -59
  280. package/src/ol/controls/index.js +0 -3
  281. package/src/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
  282. package/src/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
  283. package/src/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
  284. package/src/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
  285. package/src/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
  286. package/src/ol/controls/snapshots/RoutingControlStation1.json +0 -60
  287. package/src/ol/controls/snapshots/RoutingControlStation2.json +0 -49
  288. package/src/ol/index.js +0 -5
  289. package/src/ol/layers/Layer.js +0 -193
  290. package/src/ol/layers/Layer.test.js +0 -197
  291. package/src/ol/layers/MapboxLayer.js +0 -378
  292. package/src/ol/layers/MapboxStyleLayer.js +0 -417
  293. package/src/ol/layers/MaplibreLayer.js +0 -280
  294. package/src/ol/layers/RoutingLayer.js +0 -91
  295. package/src/ol/layers/TralisLayer.js +0 -359
  296. package/src/ol/layers/TralisLayer.test.js +0 -97
  297. package/src/ol/layers/VectorLayer.js +0 -43
  298. package/src/ol/layers/WMSLayer.js +0 -80
  299. package/src/ol/layers/WMSLayer.test.js +0 -84
  300. package/src/ol/layers/index.js +0 -8
  301. package/src/ol/styles/fullTrajectoryStyle.js +0 -51
  302. package/src/ol/styles/index.js +0 -2
  303. package/src/setupTests.js +0 -15
  304. package/webpack.config.js +0 -6
@@ -1,153 +0,0 @@
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);
@@ -1,183 +0,0 @@
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;
@@ -1,106 +0,0 @@
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;
@@ -1,38 +0,0 @@
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;
@@ -1,11 +0,0 @@
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 };
@@ -1,105 +0,0 @@
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>