waygo-maps 1.0.0

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 (98) hide show
  1. package/.babelrc +4 -0
  2. package/dist/014017f831c78bc6fd64841d8678a8d1.svg +1 -0
  3. package/dist/0680802a9353dabec5dd7049f4cd6263.svg +3 -0
  4. package/dist/0d1982dbcd8e3e8fcfbede8c102ab2f6.svg +3 -0
  5. package/dist/1b7f16a1f8c7a51acb29667188b93cd4.svg +3 -0
  6. package/dist/216edfa842a5ed98698739b69479f38c.svg +3 -0
  7. package/dist/392dbb2b5523bec74bc9a88df3f43dcf.svg +3 -0
  8. package/dist/49f8ed3d44d3320ea78c5da3231d00ca.svg +3 -0
  9. package/dist/4afa21a73de906916b62dd0baefae8fa.svg +3 -0
  10. package/dist/4b9ae054d996b09c84d311ff59d62135.svg +3 -0
  11. package/dist/4fc911a49bb7b090cdeeaed8fec429d3.svg +1 -0
  12. package/dist/507fada530642f8f1084a961a554e5a5.svg +3 -0
  13. package/dist/5dddcb86c4e0b23bd0209f44fd342d98.svg +3 -0
  14. package/dist/5e7fb034cbde37bc0e6ea8d3e6e4d954.svg +3 -0
  15. package/dist/63aa91aee195b612708db336ad5020db.svg +3 -0
  16. package/dist/709b5ad35fbbdaa1c4b5222a276444fa.svg +3 -0
  17. package/dist/73b73ceab46aea8192b55d504089b7b7.svg +3 -0
  18. package/dist/7cf71b89208aed47ca8d698707c7c1a1.svg +3 -0
  19. package/dist/7d2fb7c25b2d12614aeb1b025a51b86f.svg +4 -0
  20. package/dist/95d40a1236e53e308fb691adb40560da.svg +3 -0
  21. package/dist/bf15a356e49a659ec20974a7168c76ec.svg +12 -0
  22. package/dist/bundle.js +2 -0
  23. package/dist/bundle.js.LICENSE.txt +1 -0
  24. package/dist/d39d475496b3b4ce383f53bbf356f4f2.svg +2 -0
  25. package/dist/d8e06ee8b585e38158e77073a35d3cc1.svg +3 -0
  26. package/dist/da4aa51dbf8250628e654d4e01d44c06.svg +3 -0
  27. package/dist/e88ae66eec18595e40fc4b4bc894e4f6.svg +3 -0
  28. package/dist/f106fedfc261aa203f641adaf87ec68f.svg +3 -0
  29. package/dist/f8965838ad87362f7fd1507af2a45dfa.svg +4 -0
  30. package/index.html +137 -0
  31. package/package.json +27 -0
  32. package/src/Controls/CategoryBarControl.js +94 -0
  33. package/src/Controls/ContentPlacementControl.js +326 -0
  34. package/src/Controls/DirectionsControl.js +198 -0
  35. package/src/Controls/InteractionControl.js +521 -0
  36. package/src/Controls/SearchBoxControl.js +123 -0
  37. package/src/Controls/SearchResultsControl.js +86 -0
  38. package/src/WaygoMaps.js +29 -0
  39. package/src/api/ApiManager.js +55 -0
  40. package/src/api/MapApi.js +15 -0
  41. package/src/api/MapViewApi.js +20 -0
  42. package/src/api/SearchApi.js +38 -0
  43. package/src/assets/WaygoIcon.svg +3 -0
  44. package/src/assets/WaygoIconWhite.svg +3 -0
  45. package/src/assets/actionButtonIcons/missingIncorrect.svg +3 -0
  46. package/src/assets/actionButtonIcons/share.svg +3 -0
  47. package/src/assets/actionButtonIcons/signboard.svg +3 -0
  48. package/src/assets/actionButtonIcons/website.svg +3 -0
  49. package/src/assets/arrows/backArrow.svg +3 -0
  50. package/src/assets/arrows/leftArrow.svg +3 -0
  51. package/src/assets/arrows/leftBackArrow.svg +3 -0
  52. package/src/assets/arrows/rightArrow.svg +3 -0
  53. package/src/assets/cancel.svg +4 -0
  54. package/src/assets/directions.svg +3 -0
  55. package/src/assets/fonts/CircularXX-Book.woff2 +0 -0
  56. package/src/assets/fonts/CircularXX-Medium.woff2 +0 -0
  57. package/src/assets/fonts/CircularXX-Regular.woff2 +0 -0
  58. package/src/assets/location.svg +3 -0
  59. package/src/assets/locationPin.svg +3 -0
  60. package/src/assets/magnify.svg +4 -0
  61. package/src/assets/magnify_glass.svg +1 -0
  62. package/src/assets/missing.svg +3 -0
  63. package/src/assets/pin.svg +3 -0
  64. package/src/assets/pinOutlineIcon.svg +3 -0
  65. package/src/assets/search.svg +3 -0
  66. package/src/assets/volks.svg +1 -0
  67. package/src/assets/website.svg +3 -0
  68. package/src/components/ContentPlacementView/ContentChildButton.js +37 -0
  69. package/src/components/ContentPlacementView/ContentChildrenView.js +55 -0
  70. package/src/components/ContentPlacementView/ContentDetails.js +159 -0
  71. package/src/components/ContentPlacementView/ContentPlacementHeader.js +44 -0
  72. package/src/components/ContentPlacementView/ContentPlacementView.js +84 -0
  73. package/src/components/ContentPlacementView/ContextualLocationView.js +33 -0
  74. package/src/components/ContentPlacementView/DetailsView.js +53 -0
  75. package/src/components/DirectionsView/ContentStartEndCells.js +48 -0
  76. package/src/components/DirectionsView/DirectionsView.js +322 -0
  77. package/src/components/DirectionsView/StepsView.js +43 -0
  78. package/src/components/MapView/MapView.js +403 -0
  79. package/src/components/MapView/StateCoordinator.js +23 -0
  80. package/src/components/SearchBox/SearchBar.js +173 -0
  81. package/src/components/SearchBox/SearchBarSuggestionsView.js +49 -0
  82. package/src/components/SearchBox/SearchBarSuggestionsViewCell.js +34 -0
  83. package/src/components/SearchBox/SearchBox.js +110 -0
  84. package/src/components/SearchResultsView/SearchResultsView.js +71 -0
  85. package/src/components/SearchResultsView/SearchResultsViewCell.js +34 -0
  86. package/src/components/SliderBar.js +161 -0
  87. package/src/core/Component.js +72 -0
  88. package/src/core/Control.js +31 -0
  89. package/src/core/EventBus.js +38 -0
  90. package/src/core/Events.js +38 -0
  91. package/src/core/StateStore.js +34 -0
  92. package/src/index.js +23 -0
  93. package/src/styles.css +1499 -0
  94. package/src/utils/coordinateSystems.js +48 -0
  95. package/src/utils/debounce.js +8 -0
  96. package/src/utils/resourceLoader.js +41 -0
  97. package/test.json +58 -0
  98. package/webpack.config.js +47 -0
@@ -0,0 +1,198 @@
1
+ import Control from "../core/Control";
2
+ import DirectionsView from "../components/DirectionsView/DirectionsView";
3
+ import mapboxgl from 'mapbox-gl';
4
+
5
+ class DirectionsControl extends Control {
6
+ constructor(options = {}) {
7
+ super(options);
8
+ this.directionsView = null;
9
+ this.map = null;
10
+ }
11
+
12
+ onAdd(map) {
13
+ this.map = map;
14
+
15
+ this.container = document.createElement('div');
16
+ this.container.className = 'directions-control-container';
17
+
18
+ this.directionsView = new DirectionsView();
19
+ this.container.appendChild(this.directionsView.getElement());
20
+
21
+ this.initializeEventListeners();
22
+ this.createDirectionsLineLayer();
23
+ this.hide();
24
+ return this.container;
25
+ }
26
+
27
+ onRemove() {
28
+ super.onRemove();
29
+ }
30
+
31
+ initializeEventListeners() {
32
+ this.map.on('state:default', this._handleDefaultState.bind(this));
33
+ this.map.on('state:search', this._handleSearchState.bind(this));
34
+ this.map.on('state:selectedContent', this._handleSelectedContentState.bind(this));
35
+ this.map.on('state:directions', this._handleDirectionsState.bind(this));
36
+ // this.map.on('initiate:back', this._handleMapInitiateBack.bind(this));
37
+
38
+ this.directionsView.on('initiate:findPath', this._handleIntiateFindPath.bind(this));
39
+ }
40
+
41
+ createDirectionsLineLayer() {
42
+ // Check if the source already exists to avoid adding it multiple times
43
+ if (!this.map.map.getSource('directionsLineSource')) {
44
+ this.map.map.addSource('directionsLineSource', {
45
+ 'type': 'geojson',
46
+ 'data': {
47
+ 'type': 'Feature',
48
+ 'properties': {},
49
+ 'geometry': {
50
+ 'type': 'LineString',
51
+ 'coordinates': []
52
+ }
53
+ }
54
+ });
55
+ }
56
+
57
+ // Check if the layer already exists to avoid adding it multiple times
58
+ if (!this.map.map.getLayer('directionsLineLayer')) {
59
+ this.map.map.addLayer({
60
+ 'id': 'directionsLineLayer',
61
+ 'type': 'line',
62
+ 'source': 'directionsLineSource',
63
+ 'layout': {
64
+ 'line-join': 'round',
65
+ 'line-cap': 'round'
66
+ },
67
+ 'paint': {
68
+ 'line-color': '#1e1e1e',
69
+ 'line-width': 8,
70
+ // 'line-blur': 0.9
71
+ }
72
+ });
73
+
74
+ this.map.map.moveLayer('directionsLineLayer', 'special-areas');
75
+ }
76
+ }
77
+
78
+
79
+ updateLineData(newCoordinates) {
80
+ this.map.map.getSource('directionsLineSource').setData({
81
+ 'type': 'Feature',
82
+ 'properties': {},
83
+ 'geometry': {
84
+ 'type': 'LineString',
85
+ 'coordinates': newCoordinates
86
+ }
87
+ });
88
+
89
+ const bounds = new mapboxgl.LngLatBounds();
90
+ newCoordinates.forEach(function (coordinate) {
91
+ bounds.extend(coordinate);
92
+ });
93
+
94
+ this.map.map.fitBounds(bounds, {
95
+ padding: 200, // Add padding around the edges of the map
96
+ padding: {
97
+ top: 200,
98
+ bottom: 200,
99
+ left: 500,
100
+ right: 150
101
+ },
102
+ maxZoom: 15, // Optional: Limit the maximum zoom level
103
+ duration: 1000 // Optional: Animation duration in milliseconds
104
+ });
105
+ }
106
+
107
+ clearLineData() {
108
+ this.map.map.getSource('directionsLineSource').setData({
109
+ 'type': 'Feature',
110
+ 'properties': {},
111
+ 'geometry': {
112
+ 'type': 'LineString',
113
+ 'coordinates': []
114
+ }
115
+ });
116
+ }
117
+
118
+ // _handleMapInitiateBack() {
119
+
120
+ // }
121
+
122
+ _handleDefaultState() {
123
+ this.hide();
124
+ // this._clearViews();
125
+ }
126
+
127
+ _handleSearchState(data) {
128
+ const { query, results } = data;
129
+ this.hide();
130
+ // this._clearViews();
131
+ }
132
+
133
+ _handleSelectedContentState(data) {
134
+ const { contentPlacementIds, selectedContentPlacement } = data;
135
+ // this._updateContentViews();
136
+ this.hide();
137
+ this.directionsView.updateView(null, null);
138
+ this.clearLineData();
139
+ }
140
+
141
+ _handleDirectionsState(data) {
142
+ const { startContentPlacement, endContentPlacement } = data;
143
+ console.log("handling directions state in directions control", data);
144
+ this.show();
145
+ this.clearLineData();
146
+ this.directionsView.updateView(startContentPlacement, endContentPlacement);
147
+ }
148
+
149
+ _handleIntiateFindPath(data) {
150
+ const { startContentPlacementId, endContentPlacementId } = data;
151
+ this.clearLineData();
152
+ const pathResponse = this.map.findPath(startContentPlacementId, endContentPlacementId);
153
+
154
+ console.log("HERE IS PATH RESPONSEEE", pathResponse);
155
+ const { coordinates, steps } = pathResponse;
156
+
157
+ this.updateLineData(coordinates);
158
+ this.directionsView.setSteps(steps);
159
+ }
160
+
161
+ _handleSelectDirectionsButton(data) {
162
+ const { placementId } = data;
163
+ // this.map.setToDirectionsState(null, placementId);
164
+ }
165
+
166
+ // _updateContentViews() {
167
+ // this._clearViews();
168
+ // this._render();
169
+ // }
170
+
171
+ _render() {
172
+ console.log('render');
173
+ // if (this.contentPlacementIds.length === 0 || this.currentContentPlacement === null) return;
174
+
175
+ // const contentPlacementView = new ContentDetails();
176
+ // contentPlacementView.updateView(this.currentContentPlacement);
177
+ // contentPlacementView.on('selectChildContentPlacement', this._handleSelectChildContentPlacement.bind(this));
178
+ // contentPlacementView.on('selectDirectionsButton', this._handleSelectDirectionsButton.bind(this));
179
+
180
+ // this.container.appendChild(contentPlacementView.getElement());
181
+ }
182
+
183
+ // _clearViews() {
184
+ // while (this.container.firstChild) {
185
+ // this.container.removeChild(this.container.firstChild);
186
+ // }
187
+ // }
188
+
189
+ show() {
190
+ this.container.classList.add('visible');
191
+ }
192
+
193
+ hide() {
194
+ this.container.classList.remove('visible');
195
+ }
196
+ }
197
+
198
+ export default DirectionsControl;