@geops/rvf-mobility-web-component 0.1.10 → 0.1.11

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 (66) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/docutils.js +198 -0
  3. package/index.html +48 -217
  4. package/index.js +627 -87
  5. package/input.css +11 -1
  6. package/jest-setup.js +3 -2
  7. package/package.json +4 -3
  8. package/scripts/dev.mjs +1 -1
  9. package/search.html +38 -69
  10. package/src/GeolocationButton/GeolocationButton.tsx +6 -5
  11. package/src/LayerTree/LayerTree.tsx +44 -0
  12. package/src/LayerTree/TreeItem/TreeItem.tsx +145 -0
  13. package/src/LayerTree/TreeItem/index.tsx +1 -0
  14. package/src/LayerTree/TreeItemContainer/TreeItemContainer.tsx +16 -0
  15. package/src/LayerTree/TreeItemContainer/index.tsx +1 -0
  16. package/src/LayerTree/index.tsx +1 -0
  17. package/src/LayerTree/layersTreeContext.ts +4 -0
  18. package/src/LayerTree/layersTreeReducer.ts +156 -0
  19. package/src/Map/Map.tsx +1 -0
  20. package/src/MobilityMap/MobilityMap.tsx +10 -9
  21. package/src/MobilityMap/index.css +0 -13
  22. package/src/RealtimeLayer/RealtimeLayer.tsx +1 -1
  23. package/src/RvfButton/RvfButton.tsx +28 -21
  24. package/src/RvfExportMenu/RvfExportMenu.tsx +95 -0
  25. package/src/RvfExportMenu/index.tsx +1 -0
  26. package/src/RvfExportMenuButton/RvfExportMenuButton.tsx +27 -0
  27. package/src/RvfExportMenuButton/index.tsx +1 -0
  28. package/src/RvfFeatureDetails/RvfFeatureDetails.tsx +29 -0
  29. package/src/RvfFeatureDetails/index.tsx +1 -0
  30. package/src/RvfIconButton/RvfIconButton.tsx +35 -0
  31. package/src/RvfIconButton/index.tsx +1 -0
  32. package/src/RvfMobilityMap/RvfMobilityMap.tsx +117 -83
  33. package/src/RvfMobilityMap/index.css +0 -13
  34. package/src/RvfModal/RvfModal.tsx +52 -0
  35. package/src/RvfModal/index.tsx +1 -0
  36. package/src/RvfPoisLayer/RvfPoisLayer.tsx +39 -0
  37. package/src/RvfPoisLayer/index.tsx +1 -0
  38. package/src/RvfSharedMobilityLayerGroup/RvfSharedMobilityLayerGroup.tsx +88 -0
  39. package/src/RvfSharedMobilityLayerGroup/index.tsx +1 -0
  40. package/src/RvfSingleClickListener/RvfSingleClickListener.tsx +137 -0
  41. package/src/RvfSingleClickListener/index.tsx +1 -0
  42. package/src/RvfZoomButtons/RvfZoomButtons.tsx +36 -29
  43. package/src/Search/Search.tsx +11 -9
  44. package/src/SingleClickListener/index.tsx +1 -1
  45. package/src/StationsLayer/StationsLayer.tsx +0 -1
  46. package/src/StopsSearch/StopsSearch.tsx +38 -6
  47. package/src/TopicMenu/TopicMenu.tsx +143 -0
  48. package/src/TopicMenu/index.tsx +1 -0
  49. package/src/icons/Cancel/Cancel.tsx +21 -0
  50. package/src/icons/Cancel/cancel.svg +7 -0
  51. package/src/icons/Cancel/index.tsx +1 -0
  52. package/src/icons/Download/Download.tsx +20 -0
  53. package/src/icons/Download/download.svg +15 -0
  54. package/src/icons/Download/index.tsx +1 -0
  55. package/src/icons/Elevator/Elevator.tsx +1 -1
  56. package/src/icons/Menu/Menu.tsx +32 -0
  57. package/src/icons/Menu/index.tsx +1 -0
  58. package/src/icons/Menu/menu.svg +9 -0
  59. package/src/utils/constants.ts +9 -0
  60. package/src/utils/createMobiDataBwWfsLayer.ts +120 -0
  61. package/src/utils/exportPdf.ts +677 -0
  62. package/src/utils/hooks/useRvfContext.tsx +37 -0
  63. package/src/utils/hooks/useUpdatePermalink.tsx +2 -9
  64. package/tailwind.config.mjs +41 -0
  65. package/src/RvfSharedMobilityLayer/RvfSharedMobilityLayer.tsx +0 -147
  66. package/src/RvfSharedMobilityLayer/index.tsx +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.11](https://github.com/geops/rvf-mobility-web-component/compare/v0.1.10...v0.1.11) (2024-12-17)
6
+
7
+
8
+ ### Features
9
+
10
+ * add and hide pois layer ([f99d82a](https://github.com/geops/rvf-mobility-web-component/commit/f99d82a944d9daeb0acae9b0c3519cb8bbb608d7))
11
+ * add copyright in export and add feature details on click ([#10](https://github.com/geops/rvf-mobility-web-component/issues/10)) ([3e2ed59](https://github.com/geops/rvf-mobility-web-component/commit/3e2ed597c374e2edfb2d1a8e4b3afe0e4dc80e0a))
12
+ * add custom click listener ([74de9e4](https://github.com/geops/rvf-mobility-web-component/commit/74de9e42125ee068147d67a17324ba06fd1727a1))
13
+ * add export pdf ([#7](https://github.com/geops/rvf-mobility-web-component/issues/7)) ([3409f8b](https://github.com/geops/rvf-mobility-web-component/commit/3409f8baf257dcacc3c823355209e3c44214a31b))
14
+ * add rvf context and rvf print menu button ([37f6ddf](https://github.com/geops/rvf-mobility-web-component/commit/37f6ddfcec4a950539c41178575dc841c5824252))
15
+ * added layers tree component ([#9](https://github.com/geops/rvf-mobility-web-component/issues/9)) ([ceb0220](https://github.com/geops/rvf-mobility-web-component/commit/ceb022025eeb7b4cf25ff9a38afe8950b7d1d651))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * add better types ([c5ddf70](https://github.com/geops/rvf-mobility-web-component/commit/c5ddf7041036ab1c5e702b6d6c702bf9747df396))
21
+ * add lonlat to singleclick event ([786c79b](https://github.com/geops/rvf-mobility-web-component/commit/786c79bdd2fae619c522f635217684c05347bfe9))
22
+ * add mobidata bw layers as a group ([2aab2a5](https://github.com/geops/rvf-mobility-web-component/commit/2aab2a570c3e6214830895c146a5a95836a75516))
23
+ * add selected state ([ea6e84e](https://github.com/geops/rvf-mobility-web-component/commit/ea6e84ee265d734a502e5e2299571bd977133433))
24
+ * create a correct layer tree ([1d886b5](https://github.com/geops/rvf-mobility-web-component/commit/1d886b588821467db431bddc45821ba21b471946))
25
+ * dispatch event on html element ([e36f61d](https://github.com/geops/rvf-mobility-web-component/commit/e36f61d8295193896aba57694a4de0141aa8d0f8))
26
+ * display the copyright after an export ([cb957b7](https://github.com/geops/rvf-mobility-web-component/commit/cb957b71a528a2ad466e8bc0f0a1ddf8eb844920))
27
+ * hide print menu for now ([43dc47f](https://github.com/geops/rvf-mobility-web-component/commit/43dc47fc3ba17f8af10b057d61cce33268ffdba6))
28
+ * improve demo ([3ca67ea](https://github.com/geops/rvf-mobility-web-component/commit/3ca67eacf74b89cd396a66706b111d0e9d8963a0))
29
+ * improve demo ([1ed0b7e](https://github.com/geops/rvf-mobility-web-component/commit/1ed0b7e078b23c1bc3d1bbe1743d45b318b129b5))
30
+ * make realtime use the map pixel ratio ([dce1004](https://github.com/geops/rvf-mobility-web-component/commit/dce1004f9d945d5cd260e41660a71d49ce684e18))
31
+ * manage boolean attributes ([be816a9](https://github.com/geops/rvf-mobility-web-component/commit/be816a9f005a6979af1b0bf02034e9fe1bb22218))
32
+ * memoize onselect callback ([1d7e739](https://github.com/geops/rvf-mobility-web-component/commit/1d7e739e08da0d8d2ebb6594f83abdf9a655e658))
33
+ * remove useless xyz ([926cca7](https://github.com/geops/rvf-mobility-web-component/commit/926cca7e235265ccc6ab1ffb8241aa65454500e0))
34
+ * use also input.css for components ([1284687](https://github.com/geops/rvf-mobility-web-component/commit/128468703b3e1f50b851050870205364f43e5def))
35
+ * use memo ([0a3f107](https://github.com/geops/rvf-mobility-web-component/commit/0a3f1074bbc75b371c6375f91a9c9975a9627ed4))
36
+ * use proper rendercomplete event ([8cd5136](https://github.com/geops/rvf-mobility-web-component/commit/8cd51362b012bd7ce482355a11a6007ca705a12a))
37
+
5
38
  ### [0.1.10](https://github.com/geops/rvf-mobility-web-component/compare/v0.1.9...v0.1.10) (2024-12-05)
6
39
 
7
40
 
package/docutils.js ADDED
@@ -0,0 +1,198 @@
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3
+ function applyPermalinkParameters(wc) {
4
+ const params = new URLSearchParams(window.location.search);
5
+
6
+ // Apply fullscreen mode
7
+ if (params.get("fullscreen") === "true") {
8
+ wc.parentElement.removeChild(wc);
9
+ wc.className = "absolute w-full h-full inset-0";
10
+ document.body.appendChild(wc);
11
+ document.body.style = "padding:0;";
12
+ } else {
13
+ const doc = document.querySelectorAll("#doc");
14
+ doc.forEach((d) => {
15
+ return (d.style.display = "block");
16
+ });
17
+ }
18
+ // Apply x,y,z
19
+ if (
20
+ params.get("permalink") === "true" &&
21
+ params.get("x") &&
22
+ params.get("y")
23
+ ) {
24
+ wc.setAttribute("center", `${params.get("x")},${params.get("y")}`);
25
+ params.delete("x");
26
+ params.delete("y");
27
+ }
28
+
29
+ if (params.get("permalink") === "true" && params.get("z")) {
30
+ wc.setAttribute("zoom", params.get("z"));
31
+ params.delete("z");
32
+ }
33
+
34
+ // Apply all url parameters as attribute of the web component and fill the input fields.
35
+ params.forEach((value, key) => {
36
+ wc.setAttribute(key, value);
37
+ const input = document.querySelector(`[name=${key}]`);
38
+ if (input) {
39
+ if (input.type === "checkbox") {
40
+ input.checked = value !== "false";
41
+ } else {
42
+ input.value = value;
43
+ }
44
+ }
45
+ });
46
+
47
+ // Get an apikey if there is none defined
48
+ if (!wc.getAttribute("apikey")) {
49
+ fetch("https://backend.developer.geops.io/publickey")
50
+ .then((response) => {
51
+ return response.json();
52
+ })
53
+ .then((data) => {
54
+ if (data && data.success) {
55
+ wc.setAttribute("apikey", data.key);
56
+ }
57
+ });
58
+ }
59
+ }
60
+
61
+ // Generates a HTML table with all attributes of a web component
62
+ function generateAttributesTable(wc, attrs, booleanAttrs = []) {
63
+ let innerHMTL = `<table class="table-auto w-full" >
64
+ <thead>
65
+ <tr>
66
+ <th class="border px-4 py-2">Name</th>
67
+ <!--th class="border px-4 py-2">Default</th>
68
+ <th class="border px-4 py-2">Description</th-->
69
+ <th class="border px-4 py-2">Value</th>
70
+ </tr>
71
+ </thead>
72
+ <tbody>`;
73
+ innerHMTL += attrs
74
+ .sort()
75
+ .map((key) => {
76
+ const isBoolean = booleanAttrs.includes(key);
77
+ return `
78
+ <tr>
79
+ <td class="border px-4 py-2">${key}</td>
80
+ <!--td class="border px-4 py-2"></td>
81
+ <td class="border px-4 py-2"></td-->
82
+ <td class="border px-4 py-2">
83
+ <div class="flex gap-4">
84
+ ${
85
+ isBoolean
86
+ ? `<input
87
+ type="checkbox"
88
+ class="border"
89
+ name="${key}"
90
+ ${wc.getAttribute(key) === "true" ? "checked" : ""}
91
+ onchange="document.querySelector('${wc.localName}').setAttribute('${key}', this.checked);onAttributeUpdate(document.querySelector('${wc.localName}'),this.name, this.checked);"
92
+ />`
93
+ : `
94
+ <input
95
+ type="text"
96
+ class="border"
97
+ name="${key}"
98
+ value="${wc.getAttribute(key) || ""}"
99
+ />
100
+ <button class="border p-2 bg-black hover:bg-gray-700 text-white" onclick="document.querySelector('${wc.localName}').setAttribute('${key}', this.previousElementSibling.value);onAttributeUpdate(document.querySelector('${wc.localName}'),this.previousElementSibling.name, this.previousElementSibling.value);">Update</button>`
101
+ }
102
+ </div>
103
+ </td>
104
+ </tr>
105
+ `;
106
+ })
107
+ .join("");
108
+
109
+ innerHMTL += `</tbody>
110
+ </table>`;
111
+ return innerHMTL;
112
+ }
113
+
114
+ // Generates a code text for the web component
115
+ function generateCodeText(
116
+ wc,
117
+ attrs,
118
+ pkgSrc = "https://www.unpkg.com/@geops/mobility-web-component",
119
+ ) {
120
+ let codeText = "";
121
+ codeText = `&lt;script\n\ttype="module"\n\tsrc="${pkgSrc}"&gt;
122
+ &lt;/script&gt;
123
+ &lt;${wc.localName} style="display:block;width:100%;height:500px;"`;
124
+
125
+ attrs.forEach((key) => {
126
+ const attributeValue = wc.getAttribute(key);
127
+ const inputValue = document.querySelector(`[name=${key}]`).value;
128
+ if (attributeValue !== null && attributeValue === inputValue) {
129
+ codeText += `\n\t${[key, '"' + wc.getAttribute(key) + '"'].join("=")}`;
130
+ }
131
+ });
132
+
133
+ return codeText + `&gt;\n&lt;/${wc.localName}&gt;`;
134
+ }
135
+
136
+ // Generates a HTML table with all events of a web component
137
+ function generateEventsTable(wc, events) {
138
+ let innerHMTL = `<table class="table-auto w-full" >
139
+ <thead>
140
+ <tr>
141
+ <th class="border px-4 py-2">Name</th>
142
+ <th class="border px-4 py-2">Last data received</th>
143
+ </tr>
144
+ </thead>
145
+ <tbody>`;
146
+ innerHMTL += events
147
+ .sort()
148
+ .map((key) => {
149
+ wc.addEventListener(key, (event) => {
150
+ let stringify;
151
+ try {
152
+ stringify = JSON.stringify(event, undefined, 4);
153
+ } catch (e) {
154
+ stringify =
155
+ "Object not stringifyable, open the console (F12) to see the object received.";
156
+ console.log(key + " event", event);
157
+ }
158
+ if (key === "singleclick") {
159
+ stringify = "event.data.lonlat:\n";
160
+ stringify += JSON.stringify(event.data.lonlat, undefined, 4);
161
+ stringify += "\n";
162
+ stringify += "event.data.features:\n";
163
+ stringify += JSON.stringify(event.data.features, undefined, 4);
164
+ }
165
+
166
+ document.querySelector(`[name='${key}']`).value = stringify.toString();
167
+ });
168
+ return `
169
+ <tr>
170
+ <td class="border px-4 py-2">${key}</td>
171
+ <td class="border px-4 py-2">
172
+ <div class="flex gap-4">
173
+ <textarea
174
+ type="text"
175
+ class="border w-full h-300"
176
+ style="height:300px;"
177
+ name="${key}"
178
+ ></textarea>
179
+ </div>
180
+ </td>
181
+ </tr>
182
+ `;
183
+ })
184
+ .join("");
185
+
186
+ innerHMTL += `</tbody>
187
+ </table>`;
188
+
189
+ return innerHMTL;
190
+ }
191
+
192
+ // Update url on attributes update via inputs
193
+ function onAttributeUpdate(wc, key, value) {
194
+ const params = new URLSearchParams(window.location.search);
195
+ params.set(key, value);
196
+ wc.setAttribute(key, value);
197
+ window.history.replaceState({}, "", `${window.location.pathname}?${params}`);
198
+ }
package/index.html CHANGED
@@ -18,10 +18,12 @@
18
18
  }
19
19
  </script>
20
20
  <script type="module" src="./index.js"></script>
21
+ <script src="./docutils.js"></script>
21
22
  <link rel="stylesheet" type="text/css" href="./output.css" />
22
23
  <style>
23
24
  ::-webkit-scrollbar {
24
- width: 3px;
25
+ width: 10px;
26
+ height: 10px;
25
27
  }
26
28
  a {
27
29
  text-decoration: underline;
@@ -29,248 +31,77 @@
29
31
  </style>
30
32
  </head>
31
33
  <body class="p-8">
32
- <div id="doc" style="display: none" class="mx-auto max-w-5xl space-y-4">
34
+ <!-- tailwind hack to add class used in docutils -->
35
+ <div class="border px-4 py-2 table-auto w-full flex gap-4 p-2 bg-black text-white hover:bg-gray-700" style="display:none;"></div>
36
+ <div id="doc" style="display: none" class="mx-auto max-w-3xl space-y-4">
33
37
  <h1 class="flex gap-4"><img src="./Logo.svg">Mobility Web Component</h1>
34
38
  <p>This is a demo of the Mobility Web Component.</p>
35
39
  <h2>Usage example</h2>
36
40
  <pre id="code" class="bg-slate-800 text-slate-200 p-4 rounded"></pre>
37
41
 
38
- <!-- Default -->
39
42
  <geops-mobility
40
43
  class="h-96 block resize overflow-auto w-full"
41
44
  ></geops-mobility>
42
45
 
43
46
  <br />
44
- <!-- <h2 class="text-xl font-bold">Attributes</h2> -->
45
- <!-- <button
46
- class="border rounded p-2 hover:bg-slate-200"
47
- onclick="toggleBooleanAttribute('search')"
48
- >
49
- Toggle search
50
- </button> -->
51
-
52
- <!-- <table class="table-auto w-full" >
53
- <thead>
54
- <tr>
55
- <th class="border px-4 py-2">Name</th>
56
- <th class="border px-4 py-2">Default</th>
57
- <th class="border px-4 py-2">Description</th>
58
- <th class="border px-4 py-2">Selected</th>
59
- </tr>
60
- </thead>
61
- <tbody>
62
- <tr>
63
- <td class="border px-4 py-2">apikey</td>
64
- <td class="border px-4 py-2"></td>
65
- <td class="border px-4 py-2"></td>
66
- <td class="border px-4 py-2">
67
- <input
68
- type="text"
69
- class="border"
70
- value=""
71
- onchange="map.setAttribute('apikey', this.value)"/>
72
- </td>
73
- </tr>
74
-
75
- <tr>
76
- <td class="border px-4 py-2">search</td>
77
- <td class="border px-4 py-2">true</td>
78
- <td class="border px-4 py-2"></td>
79
- <td class="border px-4 py-2">
80
- <select
81
- class="border px-4 py-2"
82
- name="baselayer"
83
- onchange="map.setAttribute(this.name, this.value)">
84
- <option value="travic_v2">travic_v2</option>
85
- <option value="base_dark_v2">base_dark_v2</option>
86
- </select>
87
- </td>
88
- </tr>
89
-
90
- <tr>
91
- <td class="border px-4 py-2">realtime</td>
92
- <td class="border px-4 py-2">true</td>
93
- <td class="border px-4 py-2"></td>
94
- <td class="border px-4 py-2">
95
- <input
96
- name="realtime"
97
- type="checkbox"
98
- checked
99
- onchange="toggleBooleanAttribute(this.name)"/>
100
- </td>
101
- </tr>
102
- <tr>
103
- <td class="border px-4 py-2">search</td>
104
- <td class="border px-4 py-2">true</td>
105
- <td class="border px-4 py-2"></td>
106
- <td class="border px-4 py-2">
107
- <input
108
- name="search"
109
- type="checkbox"
110
- checked
111
- onchange="toggleBooleanAttribute(this.name)"/>
112
- </td>
113
- </tr>
114
- </tbody>
115
- </table> -->
116
-
117
- <!-- <br />
47
+ <h2 class="text-xl font-bold">Attributes</h2>
48
+ <div id="attributes"></div>
49
+ <h2 class="text-xl font-bold">Events</h2>
50
+ <div id="events"></div>
51
+ <br />
118
52
  <br />
119
- <h1 class="text-xl font-bold">More mobility web components</h1>
53
+ <!--h1 class="text-xl font-bold">More mobility web components</h1>
120
54
  <p>
121
55
  <a href="search.html" target="_blank"
122
56
  >&gt;&gt; Usage example Search Component</a
123
57
  >
124
58
  </p> -->
125
59
  </div>
126
-
127
60
  <br />
128
61
  <br />
129
62
  <script type="text/javascript">
130
- params = new URLSearchParams(window.location.search);
131
-
132
- // There should be only on map on the html page at this point
133
- const doc = document.querySelectorAll("#doc");
134
- const map = document.querySelector("geops-mobility");
135
-
136
- if (params.get("fullscreen") === "true") {
137
- map.parentElement.removeChild(map);
138
- map.className = "absolute w-full h-full inset-0";
139
- document.body.appendChild(map);
140
- document.body.style = "padding:0;";
141
- } else {
142
- doc.forEach((d) => (d.style.display = "block"));
143
- }
144
- params.delete("fullscreen");
63
+ const pkgSrc = "https://www.unpkg.com/@geops/rvf-mobility-web-component";
64
+ const wc = document.querySelector("geops-mobility");
145
65
 
146
- if (
147
- params.get("permalink") !== "false" &&
148
- params.get("x") &&
149
- params.get("y")
150
- ) {
151
- map.setAttribute("center", `${params.get("x")},${params.get("y")}`);
152
- params.delete("x");
153
- params.delete("y");
154
- }
155
-
156
- if (params.get("permalink") !== "false" && params.get("z")) {
157
- map.setAttribute("zoom", params.get("z"));
158
- params.delete("z");
159
- }
160
-
161
- // Apply all url parameters as attribute of the web component
162
- params.forEach((value, key) => {
163
- map.setAttribute(key, value);
164
- const input = document.querySelector(`input[name=${key}]`);
165
- if (input) {
166
- if (input.type === "checkbox") {
167
- input.checked = value !== "false";
168
- } else {
169
- input.value = value;
170
- }
171
- }
172
- });
173
-
174
- // if (!map.getAttribute("apikey")) {
175
- // fetch("https://backend.developer.geops.io/publickey")
176
- // .then((response) => response.json())
177
- // .then((data) => {
178
- // if (data && data.success) {
179
- // map.setAttribute("apikey", data.key);
180
- // }
181
- // });
182
- // }
183
-
184
- // Listen StopsSearch event
185
- window.addEventListener("mwc:stopssearchselect", (event) => {
186
- console.log("mwc:stopssearchselect event: ", event.data);
187
- // window.top.postMessage(event.data, "*");
188
- });
189
-
190
- // Send url search params to parent window
191
- window.addEventListener("mwc:attribute", (event) => {
192
- console.log("mwc:attribute event: ", event.data);
193
- window.top.postMessage(new URLSearchParams(event.data).toString(), "*");
194
- });
195
-
196
- // Listen window event
197
- window.addEventListener("message", (event) => {
198
- console.log("message event: ", event);
199
- });
200
-
201
- function toggleBooleanAttribute(name) {
202
- const value = map.getAttribute(name);
203
- map.setAttribute(name, value === "false" ? "true" : "false");
204
- const urlParams = new URLSearchParams(window.location.search);
205
- urlParams.set(name, map.getAttribute(name));
206
- window.history.replaceState(
207
- {},
208
- "",
209
- `${window.location.pathname}?${urlParams}`,
210
- );
211
- generateCodeText();
212
- }
213
66
  const attrs = [
214
- "apikey",
215
- "baselayer",
216
- "center",
217
- "geolocation",
218
- "mapsurl",
219
- "mots",
220
- "notification",
221
- "notificationat",
222
- "notificationurl",
223
- "notificationbeforelayerid",
67
+ // "apikey",
68
+ // "baselayer",
69
+ // "center",
70
+ // "geolocation",
71
+ // "mapsurl",
72
+ // "mots",
73
+ // "notification",
74
+ // "notificationat",
75
+ // "notificationurl",
76
+ // "notificationbeforelayerid",
224
77
  "realtime",
225
- "realtimeUrl",
78
+ // "realtimeUrl",
226
79
  "search",
227
- "tenant",
228
- "zoom",
229
- "permalink",
80
+ // "tenant",
81
+ // "zoom",
82
+ // "permalink",
230
83
  ];
231
84
 
232
- function generateCodeText() {
233
- const codeElt = document.querySelector("#code");
234
- let codeText = "";
235
- codeText = `&lt;script\n\ttype="module"\n\tsrc="https://www.unpkg.com/@geops/rvf-mobility-web-component"&gt;
236
- &lt;/script&gt;
237
- &lt;geops-mobility style="display:block;height:600px;width:100%;" `;
238
-
239
- attrs.forEach((key) => {
240
- if (key == "apikey") {
241
- // codeText += `\n\tapikey="YOUR_GEOPS_API_KEY"`;
242
- } else if (map.getAttribute(key) !== null) {
243
- codeText += `\n\t${[key, '"' + map.getAttribute(key) + '"'].join("=")}`;
244
- } else if (key == "center") {
245
- // codeText += `\n\tcenter="831634,5933959"`;
246
- } else if (key == "zoom") {
247
- // codeText += `\n\tzoom="13"`;
248
- } else if (key == "baselayer") {
249
- // codeText += `\n\tbaselayer="travic_v2"`;
250
- }
251
- });
252
-
253
- code.innerHTML = codeText + `&gt;\n&lt;/geops-mobility&gt;`;
254
- }
255
-
256
- // Initialize value of inputs fields
257
- function initInputs() {
258
- attrs.forEach((key) => {
259
- const input = document.querySelector(`input[name=${key}]`);
260
- if (input) {
261
- input.value = map.getAttribute(key) || "";
262
- }
263
- });
264
- const inputs = document.querySelectorAll("input");
265
- inputs.forEach((input) => {
266
- input.addEventListener("change", () => {
267
- generateCodeText();
268
- });
269
- });
270
- }
271
-
272
- initInputs();
273
- generateCodeText();
85
+ const booleanAttrs = [
86
+ "geolocation",
87
+ "notification",
88
+ "realtime",
89
+ "search",
90
+ "permalink",
91
+ ];
92
+
93
+ const events = [
94
+ "singleclick",
95
+ // "mwc:attribute",
96
+ ];
97
+
98
+ document.querySelector('#attributes').innerHTML = generateAttributesTable(wc, attrs, booleanAttrs);
99
+ document.querySelector('#events').innerHTML = generateEventsTable(wc, events);
100
+ document.querySelector('#code').innerHTML = generateCodeText(wc, attrs, pkgSrc);
101
+ wc.addEventListener('mwc:attribute', (event) => {
102
+ document.querySelector('#code').innerHTML = generateCodeText(wc, attrs, pkgSrc);
103
+ });
104
+ applyPermalinkParameters(wc);
274
105
  </script>
275
106
  </body>
276
107
  </html>