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,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M17.9999 14.0001C17.4091 14.004 16.8265 14.1388 16.2939 14.3947C15.7614 14.6506 15.2921 15.0213 14.9199 15.4801L9.81991 13.1301C10.0597 12.3959 10.0597 11.6044 9.81991 10.8701L14.9199 8.52011C15.5215 9.24608 16.3602 9.73619 17.2881 9.90395C18.2159 10.0717 19.1731 9.90634 19.9909 9.43702C20.8086 8.96769 21.4343 8.22459 21.7575 7.33886C22.0806 6.45312 22.0805 5.4817 21.7572 4.59602C21.4339 3.71035 20.8081 2.96736 19.9902 2.49818C19.1724 2.02901 18.2151 1.86381 17.2873 2.03174C16.3596 2.19967 15.5209 2.68993 14.9194 3.41601C14.318 4.14208 13.9923 5.05729 13.9999 6.00011C14.0029 6.23835 14.0263 6.47588 14.0699 6.71011L8.78991 9.14011C8.22699 8.58969 7.51415 8.21763 6.74071 8.07054C5.96727 7.92345 5.16762 8.00788 4.44196 8.31325C3.71629 8.61861 3.09687 9.13133 2.66131 9.78718C2.22574 10.443 1.99341 11.2128 1.99341 12.0001C1.99341 12.7874 2.22574 13.5572 2.66131 14.2131C3.09687 14.8689 3.71629 15.3816 4.44196 15.687C5.16762 15.9923 5.96727 16.0768 6.74071 15.9297C7.51415 15.7826 8.22699 15.4105 8.78991 14.8601L14.0699 17.2901C14.0263 17.5243 14.0029 17.7619 13.9999 18.0001C13.9999 18.7912 14.2345 19.5646 14.674 20.2224C15.1136 20.8802 15.7383 21.3929 16.4692 21.6956C17.2001 21.9984 18.0043 22.0776 18.7803 21.9233C19.5562 21.7689 20.2689 21.388 20.8283 20.8285C21.3877 20.2691 21.7687 19.5564 21.923 18.7805C22.0774 18.0046 21.9982 17.2003 21.6954 16.4694C21.3927 15.7385 20.88 15.1138 20.2222 14.6742C19.5644 14.2347 18.791 14.0001 17.9999 14.0001ZM17.9999 4.00011C18.3955 4.00011 18.7822 4.11741 19.111 4.33718C19.4399 4.55694 19.6963 4.8693 19.8477 5.23475C19.999 5.6002 20.0386 6.00233 19.9615 6.3903C19.8843 6.77826 19.6938 7.13462 19.4141 7.41433C19.1344 7.69403 18.778 7.88451 18.3901 7.96169C18.0021 8.03886 17.6 7.99925 17.2345 7.84787C16.8691 7.6965 16.5567 7.44015 16.337 7.11125C16.1172 6.78236 15.9999 6.39568 15.9999 6.00011C15.9999 5.46968 16.2106 4.96097 16.5857 4.5859C16.9608 4.21083 17.4695 4.00011 17.9999 4.00011ZM5.99991 14.0001C5.60434 14.0001 5.21766 13.8828 4.88877 13.6631C4.55987 13.4433 4.30352 13.1309 4.15215 12.7655C4.00077 12.4 3.96116 11.9979 4.03834 11.6099C4.11551 11.222 4.30599 10.8656 4.58569 10.5859C4.8654 10.3062 5.22176 10.1157 5.60973 10.0385C5.99769 9.96137 6.39982 10.001 6.76527 10.1524C7.13073 10.3037 7.44308 10.5601 7.66285 10.889C7.88261 11.2179 7.99991 11.6046 7.99991 12.0001C7.99991 12.5305 7.78919 13.0393 7.41412 13.4143C7.03905 13.7894 6.53034 14.0001 5.99991 14.0001ZM17.9999 20.0001C17.6043 20.0001 17.2177 19.8828 16.8888 19.6631C16.5599 19.4433 16.3035 19.1309 16.1521 18.7655C16.0008 18.4 15.9612 17.9979 16.0383 17.6099C16.1155 17.222 16.306 16.8656 16.5857 16.5859C16.8654 16.3062 17.2218 16.1157 17.6097 16.0385C17.9977 15.9614 18.3998 16.001 18.7653 16.1524C19.1307 16.3037 19.4431 16.5601 19.6628 16.889C19.8826 17.2179 19.9999 17.6046 19.9999 18.0001C19.9999 18.5305 19.7892 19.0393 19.4141 19.4143C19.039 19.7894 18.5303 20.0001 17.9999 20.0001Z" fill="#171717"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M17.9999 4.4804C16.4086 2.8891 14.2504 1.99512 11.9999 1.99512C9.74949 1.99512 7.59123 2.8891 5.99993 4.4804C4.40863 6.0717 3.51465 8.22996 3.51465 10.4804C3.51465 12.7308 4.40863 14.8891 5.99993 16.4804L11.2699 21.7604C11.3629 21.8541 11.4735 21.9285 11.5954 21.9793C11.7172 22.0301 11.8479 22.0562 11.9799 22.0562C12.1119 22.0562 12.2426 22.0301 12.3645 21.9793C12.4864 21.9285 12.597 21.8541 12.6899 21.7604L17.9999 16.4304C19.5846 14.8457 20.4748 12.6965 20.4748 10.4554C20.4748 8.21434 19.5846 6.06508 17.9999 4.4804ZM16.5699 15.0004L11.9999 19.5904L7.42993 15.0004C6.52707 14.0967 5.91241 12.9456 5.66362 11.6927C5.41484 10.4397 5.54312 9.14115 6.03223 7.96108C6.52135 6.78101 7.34935 5.77245 8.41156 5.06288C9.47377 4.3533 10.7225 3.97458 11.9999 3.97458C13.2773 3.97458 14.5261 4.3533 15.5883 5.06288C16.6505 5.77245 17.4785 6.78101 17.9676 7.96108C18.4567 9.14115 18.585 10.4397 18.3362 11.6927C18.0875 12.9456 17.4728 14.0967 16.5699 15.0004ZM8.99993 7.4104C8.19264 8.22017 7.73932 9.31697 7.73932 10.4604C7.73932 11.6038 8.19264 12.7006 8.99993 13.5104C9.59969 14.1112 10.3635 14.5215 11.1956 14.6898C12.0276 14.8581 12.8909 14.777 13.677 14.4566C14.4631 14.1361 15.1371 13.5907 15.6144 12.8886C16.0917 12.1866 16.3511 11.3593 16.3599 10.5104C16.3644 9.9436 16.2553 9.38166 16.0388 8.85779C15.8224 8.33392 15.5032 7.85875 15.0999 7.4604C14.7036 7.05498 14.231 6.73194 13.7094 6.50986C13.1877 6.28779 12.6273 6.17107 12.0603 6.16643C11.4934 6.16178 10.9311 6.2693 10.4059 6.48279C9.88067 6.69628 9.40285 7.01153 8.99993 7.4104ZM13.6899 12.0904C13.311 12.4751 12.8101 12.7163 12.2731 12.7727C11.736 12.829 11.196 12.697 10.7454 12.3993C10.2949 12.1016 9.96173 11.6566 9.80294 11.1405C9.64415 10.6243 9.66958 10.069 9.87489 9.56955C10.0802 9.07007 10.4526 8.65741 10.9285 8.40213C11.4044 8.14686 11.9542 8.06481 12.4839 8.17002C13.0135 8.27522 13.4902 8.56116 13.8324 8.97893C14.1746 9.3967 14.3611 9.92037 14.3599 10.4604C14.3454 11.0777 14.0864 11.6639 13.6399 12.0904H13.6899Z" fill="#818181"/>
3
+ </svg>
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <circle cx="11" cy="11" r="7" stroke="#171717" stroke-width="2"/>
3
+ <path d="M20 20L17 17" stroke="#171717" stroke-width="2" stroke-linecap="round"/>
4
+ </svg>
package/index.html ADDED
@@ -0,0 +1,137 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>waygomaps Test</title>
8
+ <link rel="stylesheet" href="src/styles.css">
9
+ <style>
10
+ body {
11
+ margin: 0;
12
+ padding: 0;
13
+ }
14
+
15
+ /* #map { position: absolute; z-index: 0; } */
16
+ #map {
17
+ position: absolute;
18
+ top: 0;
19
+ bottom: 0;
20
+ width: 100%;
21
+ z-index: 0;
22
+ }
23
+ </style>
24
+ <script src="dist/bundle.js"></script>
25
+ </head>
26
+
27
+ <body>
28
+ <div id="map"></div>
29
+ <script>
30
+
31
+ // waygomaps.setApiKey("USER'S-API-KEY");
32
+ // const map = new waygomaps.MapView({
33
+ // container: 'map',
34
+ // sourceId: 'e9df990cbd084934973a87fc2f3b0e74.move-america-2024.FTdsy9btTs6qumoZ6E8Z2Q',
35
+ // });
36
+
37
+ // // const searchBox = new waygomaps.SearchBox();
38
+ // // document.body.appendChild(searchBox.getElement());
39
+
40
+ // map.on('load', () => {
41
+ // const searchBoxControl = new waygomaps.SearchBoxControl();
42
+ // map.addControl(searchBoxControl);
43
+
44
+ // const categoryBarControl = new waygomaps.CategoryBarControl();
45
+ // map.addControl(categoryBarControl);
46
+
47
+ // const searchResultsControl = new waygomaps.SearchResultsControl();
48
+ // map.addControl(searchResultsControl);
49
+
50
+ // const contentPlacementControl = new waygomaps.ContentPlacementControl();
51
+ // map.addControl(contentPlacementControl);
52
+
53
+ // const directionsControl = new waygomaps.DirectionsControl();
54
+ // map.addControl(directionsControl);
55
+
56
+ // const interactionControl = new waygomaps.InteractionControl();
57
+ // map.addControl(interactionControl);
58
+ // })
59
+
60
+ // map.on('mousedown', (e) => {
61
+ // console.log('Mouse down on map:', e);
62
+ // });
63
+
64
+ // map.on('click', (e) => {
65
+ // console.log('Click on map:', e);
66
+ // const {lng, lat} = map.getCenter();
67
+ // console.log(lng, lat);
68
+ // });
69
+
70
+ // map.on('mouseover', (e) => {
71
+ // console.log('Mouseover map:', e);
72
+ // });
73
+
74
+ // // map.on('mousemove', (e) => {
75
+ // // console.log('mousemove map:', e);
76
+ // // });
77
+
78
+ // map.on('dblclick', (e) => {
79
+ // console.log('dblclick map:', e);
80
+ // });
81
+
82
+ // map.on('mouseout', (e) => {
83
+ // console.log('mouseout map:', e);
84
+ // });
85
+
86
+ // map.on('contextmenu', (e) => {
87
+ // console.log('contextmenu map:', e);
88
+ // });
89
+
90
+ // map.on('wheel', (e) => {
91
+ // console.log('wheel map:', e);
92
+ // });
93
+
94
+ // map.on('touchstart', (e) => {
95
+ // console.log('touchstart map:', e);
96
+ // });
97
+
98
+ // map.on('touchstend', (e) => {
99
+ // console.log('touchend map:', e);
100
+ // });
101
+
102
+ // map.on('touchmove', (e) => {
103
+ // console.log('touchmove map:', e);
104
+ // });
105
+
106
+ // map.on('touchcancel', (e) => {
107
+ // console.log('touchcancel map:', e);
108
+ // });
109
+
110
+ // map.on('move', () => {
111
+ // console.log('The map is moving.');
112
+ // });
113
+
114
+ // map.on('zoom', () => {
115
+ // console.log('The map is zooming.');
116
+ // });
117
+
118
+ map.on('zoomend', () => {
119
+ console.log(map.map.getZoom());
120
+ });
121
+
122
+ map.on('pitchend', () => {
123
+ console.log(map.map.getPitch());
124
+ });
125
+
126
+ map.on('rotateend', () => {
127
+ console.log(map.map.getBearing());
128
+ });
129
+
130
+ map.on('moveend', () => {
131
+ console.log(map.map.getCenter());
132
+ });
133
+
134
+ </script>
135
+ </body>
136
+
137
+ </html>
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "waygo-maps",
3
+ "version": "1.0.0",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1",
7
+ "build": "webpack"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "description": "",
13
+ "dependencies": {
14
+ "axios": "^1.7.2",
15
+ "css-loader": "^7.1.2",
16
+ "style-loader": "^4.0.0"
17
+ },
18
+ "devDependencies": {
19
+ "@babel/core": "^7.24.9",
20
+ "@babel/preset-env": "^7.25.0",
21
+ "babel-loader": "^9.1.3",
22
+ "file-loader": "^6.2.0",
23
+ "webpack": "^5.93.0",
24
+ "webpack-cli": "^5.1.4",
25
+ "webpack-dev-server": "^5.1.0"
26
+ }
27
+ }
@@ -0,0 +1,94 @@
1
+ import SliderBar from "../components/SliderBar";
2
+ import Control from "../core/Control";
3
+
4
+ class CategoryBarControl extends Control {
5
+ constructor(options = {}) {
6
+ super(options);
7
+ const categories = [
8
+ { title: 'Energy & charging' },
9
+ { title: 'Mobility' },
10
+ { title: 'Automotive' },
11
+ { title: 'Indoor mapping' },
12
+ { title: 'Supply chain' },
13
+ { title: 'Tech data' },
14
+ { title: 'Insurance' },
15
+ { title: 'Rideshare' },
16
+ { title: 'Manufacturing' },
17
+ { title: 'Autonomous vehicles' },
18
+ { title: 'Human resources' },
19
+ { title: 'Battery tech' },
20
+ { title: 'Renewable energy' }
21
+ ];
22
+ this.categoryBar = new SliderBar(categories, {
23
+ container: 'category-bar'
24
+ });
25
+ this.map = null;
26
+ }
27
+
28
+ onAdd(map) {
29
+ this.map = map;
30
+
31
+ this.container = document.createElement('div');
32
+ this.container.className = 'category-bar-control-container';
33
+
34
+ const element = this.categoryBar.getElement();
35
+ this.container.appendChild(element);
36
+
37
+ this.initializeEventListeners();
38
+ this.show();
39
+ return this.container;
40
+ }
41
+
42
+ onRemove() {
43
+ super.onRemove();
44
+ }
45
+
46
+ initializeEventListeners() {
47
+ this.categoryBar.on('selectNew', this._handleNewCategoryButtonSelect.bind(this));
48
+ this.categoryBar.on('deselect', this._handleCategoryButtonDeselect.bind(this));
49
+ this.map.on('state:default', this._handleDefaultState.bind(this));
50
+ this.map.on('state:search', this._handleSearchState.bind(this));
51
+ this.map.on('state:selectedContent', this._handleSelectedContentState.bind(this));
52
+ this.map.on('state:directions', this._handleDirectionsState.bind(this));
53
+ }
54
+
55
+ _handleDefaultState() {
56
+ this.show();
57
+ this.categoryBar.deselectAll();
58
+ }
59
+
60
+ _handleSelectedContentState(_) {
61
+ this.hide()
62
+ }
63
+
64
+ _handleDirectionsState(_) {
65
+ // console.log("handling directions state in category bar control");
66
+ this.hide();
67
+ }
68
+
69
+
70
+ _handleNewCategoryButtonSelect(data) {
71
+ const { query } = data;
72
+ this.map.setToSearchState(query);
73
+ }
74
+
75
+ _handleCategoryButtonDeselect() {
76
+ this.map.setToDefaultState();
77
+ }
78
+
79
+ _handleSearchState(data) {
80
+ const { query, results } = data;
81
+ this.show();
82
+ this.categoryBar.deselectAllNotMatchingQuery(query);
83
+ }
84
+
85
+ show() {
86
+ this.container.classList.add('visible');
87
+ }
88
+
89
+ hide() {
90
+ this.container.classList.remove('visible');
91
+ }
92
+ }
93
+
94
+ export default CategoryBarControl;
@@ -0,0 +1,326 @@
1
+ import ContentDetails from "../components/ContentPlacementView/ContentDetails";
2
+ import Control from "../core/Control";
3
+
4
+ class ContentPlacementControl extends Control {
5
+ constructor(options = {}) {
6
+ super(options);
7
+ this.map = null;
8
+ this.contentPlacementIds = [];
9
+ this.currentContentPlacement = null;
10
+ }
11
+
12
+ onAdd(map) {
13
+ this.map = map;
14
+
15
+ this.container = document.createElement('div');
16
+ this.container.className = 'content-details-control-container';
17
+
18
+ this.initializeEventListeners();
19
+ this.hide();
20
+ return this.container;
21
+ }
22
+
23
+ onRemove() {
24
+ super.onRemove();
25
+ }
26
+
27
+ initializeEventListeners() {
28
+ this.map.on('state:default', this._handleDefaultState.bind(this));
29
+ this.map.on('state:search', this._handleSearchState.bind(this));
30
+ this.map.on('state:selectedContent', this._handleSelectedContentState.bind(this));
31
+ this.map.on('state:directions', this._handleDirectionsState.bind(this));
32
+ this.map.on('initiate:back', this._handleMapInitiateBack.bind(this));
33
+ }
34
+
35
+ _handleMapInitiateBack() {
36
+ const currentState = this.map._stateCoordinator.state;
37
+
38
+ if (currentState === 'selectedContent') {
39
+ if (this.contentPlacementIds.length === 0) return;
40
+ else if (this.contentPlacementIds.length === 1) {
41
+ const stateHistory = this.map._stateCoordinator.stateHistory;
42
+ const previousMapState = stateHistory[stateHistory.length - 2];
43
+ stateHistory.pop();
44
+ stateHistory.pop();
45
+ if (previousMapState === 'search') {
46
+ this.map.initiateSetToSearchState();
47
+ } else {
48
+ this.map.setToDefaultState();
49
+ }
50
+ } else {
51
+ this.contentPlacementIds.pop();
52
+ this.map.setToSelectedContentState(this.contentPlacementIds);
53
+ }
54
+ } else if (currentState === 'directions') {
55
+ console.log("THIS IS BACK IN DIRECTIONS STATE:", this.contentPlacementIds.length);
56
+ this.map.setToSelectedContentState(this.contentPlacementIds);
57
+ }
58
+ }
59
+
60
+ _handleSelectChildContentPlacement(data) {
61
+ const { placementId } = data;
62
+ this.contentPlacementIds.push(placementId);
63
+ this.map.setToSelectedContentState(this.contentPlacementIds);
64
+ }
65
+
66
+ _handleDefaultState() {
67
+ this.hide();
68
+ this.contentPlacementIds = [];
69
+ this.currentContentPlacement = null;
70
+ this._clearViews();
71
+ }
72
+
73
+ _handleSearchState(_) {
74
+ // const { query, results } = data;
75
+ this.hide();
76
+ this.contentPlacementIds = [];
77
+ this.currentContentPlacement = null;
78
+ this._clearViews();
79
+ }
80
+
81
+ _handleSelectedContentState(data) {
82
+ const { contentPlacementIds, selectedContentPlacement } = data;
83
+
84
+ this.contentPlacementIds = contentPlacementIds;
85
+ this.currentContentPlacement = selectedContentPlacement;
86
+
87
+ console.log("SELECTED", selectedContentPlacement);
88
+
89
+ this._updateContentViews();
90
+ this.show();
91
+ }
92
+
93
+ _handleDirectionsState(_) {
94
+ // console.log("handling directions state in content placement control");
95
+ this.hide();
96
+ // this.contentPlacementIds = [];
97
+ // this.currentContentPlacement = null;
98
+ // this._clearViews();
99
+ }
100
+
101
+ async _handleSelectDirectionsButton(data) {
102
+ const { placementId } = data;
103
+ await this.map.setToDirectionsState(null, placementId);
104
+ }
105
+
106
+ _updateContentViews() {
107
+ this._clearViews();
108
+ this._render();
109
+ }
110
+
111
+ _render() {
112
+ if (this.contentPlacementIds.length === 0 || this.currentContentPlacement === null) return;
113
+
114
+ const contentPlacementView = new ContentDetails();
115
+ contentPlacementView.updateView(this.currentContentPlacement);
116
+ contentPlacementView.on('selectChildContentPlacement', this._handleSelectChildContentPlacement.bind(this));
117
+ contentPlacementView.on('selectDirectionsButton', this._handleSelectDirectionsButton.bind(this));
118
+
119
+ this.container.appendChild(contentPlacementView.getElement());
120
+ }
121
+
122
+ _clearViews() {
123
+ while (this.container.firstChild) {
124
+ this.container.removeChild(this.container.firstChild);
125
+ }
126
+ }
127
+
128
+ show() {
129
+ this.container.classList.add('visible');
130
+ }
131
+
132
+ hide() {
133
+ this.container.classList.remove('visible');
134
+ }
135
+ }
136
+
137
+ export default ContentPlacementControl;
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+ // class ContentPlacementControl extends Control {
168
+ // constructor(options = {}) {
169
+ // super(options);
170
+ // this.map = null;
171
+ // this.contentPlacementStack = [];
172
+ // this.searchApi = waygoMaps.getSearchApi();
173
+
174
+ // this.currentView = null;
175
+ // }
176
+
177
+ // onAdd(map) {
178
+ // this.map = map;
179
+
180
+ // this.container = document.createElement('div');
181
+ // this.container.className = 'content-details-control-container';
182
+
183
+ // this.initializeEventListeners();
184
+ // this._attachResizeListener();
185
+ // this.hide();
186
+ // this._initialize();
187
+ // return this.container;
188
+ // }
189
+
190
+ // onRemove() {
191
+ // super.onRemove();
192
+ // }
193
+
194
+ // _initialize() {
195
+ // const containerWidth = this.map.mapContainer.offsetWidth;
196
+ // this._configureView(containerWidth);
197
+ // }
198
+
199
+ // _configureView(width) {
200
+ // if (width > 767) {
201
+ // this._setViewForDesktop();
202
+ // } else {
203
+ // this._setViewForMobile();
204
+ // }
205
+ // }
206
+
207
+ // _setViewForDesktop() {
208
+ // console.log("SET VIEW FOR DESKTOP");
209
+ // this.currentView = 'desktop';
210
+ // this._updateContentViews();
211
+ // }
212
+
213
+ // _setViewForMobile() {
214
+ // console.log("SET VIEW FOR MOBILE");
215
+ // this.currentView = 'mobile';
216
+ // this._updateContentViews();
217
+ // }
218
+
219
+ // _attachResizeListener() {
220
+ // window.addEventListener('resize', () => {
221
+ // const newWidth = this.map.mapContainer.offsetWidth;
222
+ // // console.log("WIDTH", newWidth);
223
+ // this._configureView(newWidth); // Reconfigure based on new width
224
+ // });
225
+ // }
226
+
227
+ // initializeEventListeners() {
228
+ // this.map.on('setToSearchState', this._handleSearchState.bind(this));
229
+ // this.map.on('setToDefaultState', this._handleDefaultState.bind(this));
230
+ // this.map.on('setToSelectedContentState', this._handleSelectedContentState.bind(this));
231
+ // }
232
+
233
+ // async _handleSelectChildContentPlacement(data) {
234
+ // const { placementId } = data;
235
+ // const contentPlacement = await this.map.getContentPlacementDetails(placementId);
236
+ // this.contentPlacementStack.push(contentPlacement);
237
+ // console.log(this.contentPlacementStack);
238
+ // this._updateContentViews();
239
+ // }
240
+
241
+ // // STATE METHODS
242
+ // _handleDefaultState() {
243
+ // this.hide();
244
+ // // Should clear them too!
245
+ // }
246
+
247
+ // _handleSearchState(data) {
248
+ // const { query, results } = data;
249
+ // this.hide();
250
+ // }
251
+
252
+ // _handleSelectedContentState(data) {
253
+ // const { contentPlacement } = data;
254
+ // this.contentPlacementStack = [contentPlacement];
255
+ // this._updateContentViews();
256
+ // this.show();
257
+
258
+ // // if (this.contentPlacementView && this.container.lastChild) {
259
+ // // this.container.removeChild(this.container.lastChild);
260
+ // // }
261
+
262
+ // // this.contentPlacementView = new ContentDetails();
263
+ // // this.contentPlacementView.updateView(contentPlacement);
264
+ // // this.contentPlacementView.on('selectChildContentPlacement', this._handleSelectChildContentPlacement.bind(this));
265
+ // // this.container.appendChild(this.contentPlacementView.getElement());
266
+
267
+ // // NEED TO USE this.contentPlacementStack and CURRENT WIDTH TO APPRORIATELY SET VIEWS
268
+ // }
269
+
270
+ // _updateContentViews() {
271
+ // this._clearViews();
272
+
273
+ // if (this.currentView === 'desktop') {
274
+ // this._renderDesktopView();
275
+ // } else {
276
+ // this._renderMobileView();
277
+ // }
278
+ // }
279
+
280
+ // _renderDesktopView() {
281
+ // if (this.contentPlacementStack.length === 0) return;
282
+
283
+ // const firstPlacement = this.contentPlacementStack[0];
284
+ // const lastPlacement = this.contentPlacementStack[this.contentPlacementStack.length - 1];
285
+
286
+ // const leftContentPlacementView = new ContentDetails();
287
+ // leftContentPlacementView.on('selectChildContentPlacement', this._handleSelectChildContentPlacement.bind(this));
288
+ // leftContentPlacementView.updateView(firstPlacement);
289
+ // this.container.appendChild(leftContentPlacementView.getElement());
290
+
291
+ // if (this.contentPlacementStack.length > 1) {
292
+ // const rightContentPlacementView = new ContentDetails();
293
+ // rightContentPlacementView.on('selectChildContentPlacement', this._handleSelectChildContentPlacement.bind(this));
294
+ // rightContentPlacementView.updateView(lastPlacement);
295
+ // this.container.appendChild(rightContentPlacementView.getElement());
296
+ // }
297
+ // }
298
+
299
+ // _renderMobileView() {
300
+ // if (this.contentPlacementStack.length === 0) return;
301
+
302
+ // const lastPlacement = this.contentPlacementStack[this.contentPlacementStack.length - 1];
303
+
304
+ // const mobileContentPlacementView = new ContentDetails();
305
+ // mobileContentPlacementView.on('selectChildContentPlacement', this._handleSelectChildContentPlacement.bind(this));
306
+ // mobileContentPlacementView.updateView(lastPlacement);
307
+ // this.container.appendChild(mobileContentPlacementView.getElement());
308
+ // }
309
+
310
+ // _clearViews() {
311
+ // while (this.container.firstChild) {
312
+ // this.container.removeChild(this.container.firstChild);
313
+ // }
314
+ // }
315
+
316
+ // // HIDE/SHOW METHODS
317
+ // show() {
318
+ // this.container.classList.add('visible');
319
+ // }
320
+
321
+ // hide() {
322
+ // this.container.classList.remove('visible');
323
+ // }
324
+ // }
325
+
326
+ // export default ContentPlacementControl;