@blaze-cms/plugin-google-maps-fe 0.146.0-node18-core-styles-tooltips.45 → 0.146.0-node18-tooltips.38

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 (46) hide show
  1. package/CHANGELOG.md +21 -77
  2. package/lib-es/GoogleMaps/GoogleMaps.js +120 -0
  3. package/lib-es/GoogleMaps/GoogleMaps.js.map +1 -0
  4. package/lib-es/GoogleMaps/GoogleMapsFactory.js +41 -0
  5. package/lib-es/GoogleMaps/GoogleMapsFactory.js.map +1 -0
  6. package/lib-es/GoogleMaps/GoogleMapsHtml.js +16 -0
  7. package/lib-es/GoogleMaps/GoogleMapsHtml.js.map +1 -0
  8. package/lib-es/GoogleMaps/GoogleMapsRender.js +72 -0
  9. package/lib-es/GoogleMaps/GoogleMapsRender.js.map +1 -0
  10. package/lib-es/GoogleMaps/helpers/add-zoom-listener.js +9 -0
  11. package/lib-es/GoogleMaps/helpers/add-zoom-listener.js.map +1 -0
  12. package/lib-es/GoogleMaps/helpers/build-map-shapes.js +68 -0
  13. package/lib-es/GoogleMaps/helpers/build-map-shapes.js.map +1 -0
  14. package/lib-es/GoogleMaps/helpers/build-map-type-ids.js +9 -0
  15. package/lib-es/GoogleMaps/helpers/build-map-type-ids.js.map +1 -0
  16. package/lib-es/GoogleMaps/helpers/build-query.js +29 -0
  17. package/lib-es/GoogleMaps/helpers/build-query.js.map +1 -0
  18. package/lib-es/GoogleMaps/helpers/build-shapes-configs.js +124 -0
  19. package/lib-es/GoogleMaps/helpers/build-shapes-configs.js.map +1 -0
  20. package/lib-es/GoogleMaps/helpers/get-center-coordinates.js +29 -0
  21. package/lib-es/GoogleMaps/helpers/get-center-coordinates.js.map +1 -0
  22. package/lib-es/GoogleMaps/helpers/get-image-ids.js +13 -0
  23. package/lib-es/GoogleMaps/helpers/get-image-ids.js.map +1 -0
  24. package/lib-es/GoogleMaps/helpers/get-path.js +13 -0
  25. package/lib-es/GoogleMaps/helpers/get-path.js.map +1 -0
  26. package/lib-es/GoogleMaps/helpers/index.js +9 -0
  27. package/lib-es/GoogleMaps/helpers/index.js.map +1 -0
  28. package/lib-es/GoogleMaps/helpers/set-map-options.js +69 -0
  29. package/lib-es/GoogleMaps/helpers/set-map-options.js.map +1 -0
  30. package/lib-es/GoogleMaps/helpers/set-shapes.js +309 -0
  31. package/lib-es/GoogleMaps/helpers/set-shapes.js.map +1 -0
  32. package/lib-es/GoogleMaps/hooks/index.js +4 -0
  33. package/lib-es/GoogleMaps/hooks/index.js.map +1 -0
  34. package/lib-es/GoogleMaps/hooks/use-get-entity-schemas.js +20 -0
  35. package/lib-es/GoogleMaps/hooks/use-get-entity-schemas.js.map +1 -0
  36. package/lib-es/GoogleMaps/hooks/use-get-images.js +27 -0
  37. package/lib-es/GoogleMaps/hooks/use-get-images.js.map +1 -0
  38. package/lib-es/GoogleMaps/index.js +3 -0
  39. package/lib-es/GoogleMaps/index.js.map +1 -0
  40. package/lib-es/GoogleMaps/queries.js +47 -0
  41. package/lib-es/GoogleMaps/queries.js.map +1 -0
  42. package/lib-es/constants.js +90 -0
  43. package/lib-es/constants.js.map +1 -0
  44. package/lib-es/index.js +17 -0
  45. package/lib-es/index.js.map +1 -0
  46. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- # [0.146.0-node18-core-styles-tooltips.45](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.44...v0.146.0-node18-core-styles-tooltips.45) (2026-01-15)
6
+ # [0.146.0-node18-tooltips.38](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.37...v0.146.0-node18-tooltips.38) (2026-01-27)
7
7
 
8
8
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
9
9
 
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
11
11
 
12
12
 
13
13
 
14
- # [0.146.0-node18-core-styles-tooltips.44](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.43...v0.146.0-node18-core-styles-tooltips.44) (2026-01-02)
14
+ # [0.146.0-node18-tooltips.37](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.36...v0.146.0-node18-tooltips.37) (2026-01-08)
15
15
 
16
16
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
17
17
 
@@ -19,7 +19,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
19
19
 
20
20
 
21
21
 
22
- # [0.146.0-node18-core-styles-tooltips.43](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.42...v0.146.0-node18-core-styles-tooltips.43) (2025-12-17)
22
+ # [0.146.0-node18-tooltips.35](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.34...v0.146.0-node18-tooltips.35) (2025-12-17)
23
23
 
24
24
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
25
25
 
@@ -27,7 +27,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
27
27
 
28
28
 
29
29
 
30
- # [0.146.0-node18-core-styles-tooltips.42](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.41...v0.146.0-node18-core-styles-tooltips.42) (2025-12-17)
30
+ # [0.146.0-node18-tooltips.34](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.33...v0.146.0-node18-tooltips.34) (2025-12-17)
31
31
 
32
32
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
33
33
 
@@ -35,7 +35,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
35
35
 
36
36
 
37
37
 
38
- # [0.146.0-node18-core-styles-tooltips.41](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.40...v0.146.0-node18-core-styles-tooltips.41) (2025-12-15)
38
+ # [0.146.0-node18-tooltips.33](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.32...v0.146.0-node18-tooltips.33) (2025-12-15)
39
39
 
40
40
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
41
41
 
@@ -43,7 +43,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
43
43
 
44
44
 
45
45
 
46
- # [0.146.0-node18-core-styles-tooltips.38](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.37...v0.146.0-node18-core-styles-tooltips.38) (2025-12-04)
46
+ # [0.146.0-node18-tooltips.32](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.31...v0.146.0-node18-tooltips.32) (2025-12-15)
47
47
 
48
48
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
49
49
 
@@ -51,7 +51,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
51
51
 
52
52
 
53
53
 
54
- # [0.146.0-node18-core-styles-tooltips.34](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.33...v0.146.0-node18-core-styles-tooltips.34) (2025-11-27)
54
+ # [0.146.0-node18-tooltips.30](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.29...v0.146.0-node18-tooltips.30) (2025-11-17)
55
55
 
56
56
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
57
57
 
@@ -59,7 +59,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
59
59
 
60
60
 
61
61
 
62
- # [0.146.0-node18-core-styles-tooltips.32](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.31...v0.146.0-node18-core-styles-tooltips.32) (2025-11-26)
62
+ # [0.146.0-node18-tooltips.28](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.27...v0.146.0-node18-tooltips.28) (2025-11-10)
63
63
 
64
64
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
65
65
 
@@ -67,7 +67,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
67
67
 
68
68
 
69
69
 
70
- # [0.146.0-node18-core-styles-tooltips.31](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.30...v0.146.0-node18-core-styles-tooltips.31) (2025-11-26)
70
+ # [0.146.0-node18-tooltips.27](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.26...v0.146.0-node18-tooltips.27) (2025-11-06)
71
71
 
72
72
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
73
73
 
@@ -75,7 +75,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
75
75
 
76
76
 
77
77
 
78
- # [0.146.0-node18-core-styles-tooltips.30](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.29...v0.146.0-node18-core-styles-tooltips.30) (2025-11-25)
78
+ # [0.146.0-node18-tooltips.26](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.25...v0.146.0-node18-tooltips.26) (2025-10-29)
79
79
 
80
80
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
81
81
 
@@ -83,7 +83,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
83
83
 
84
84
 
85
85
 
86
- # [0.146.0-node18-core-styles-tooltips.29](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.28...v0.146.0-node18-core-styles-tooltips.29) (2025-11-17)
86
+ # [0.146.0-node18-tooltips.24](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.23...v0.146.0-node18-tooltips.24) (2025-10-27)
87
87
 
88
88
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
89
89
 
@@ -91,7 +91,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
91
91
 
92
92
 
93
93
 
94
- # [0.146.0-node18-core-styles-tooltips.27](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.26...v0.146.0-node18-core-styles-tooltips.27) (2025-11-13)
94
+ # [0.146.0-node18-tooltips.23](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.22...v0.146.0-node18-tooltips.23) (2025-10-20)
95
95
 
96
96
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
97
97
 
@@ -99,7 +99,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
99
99
 
100
100
 
101
101
 
102
- # [0.146.0-node18-core-styles-tooltips.26](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.25...v0.146.0-node18-core-styles-tooltips.26) (2025-11-12)
102
+ # [0.146.0-node18-tooltips.22](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.21...v0.146.0-node18-tooltips.22) (2025-10-17)
103
103
 
104
104
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
105
105
 
@@ -107,7 +107,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
107
107
 
108
108
 
109
109
 
110
- # [0.146.0-node18-core-styles-tooltips.25](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.24...v0.146.0-node18-core-styles-tooltips.25) (2025-11-07)
110
+ # [0.146.0-node18-tooltips.21](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.20...v0.146.0-node18-tooltips.21) (2025-10-14)
111
111
 
112
112
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
113
113
 
@@ -115,7 +115,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
115
115
 
116
116
 
117
117
 
118
- # [0.146.0-node18-core-styles-tooltips.24](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.23...v0.146.0-node18-core-styles-tooltips.24) (2025-11-03)
118
+ # [0.146.0-node18-tooltips.19](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.18...v0.146.0-node18-tooltips.19) (2025-10-10)
119
119
 
120
120
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
121
121
 
@@ -123,7 +123,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
123
123
 
124
124
 
125
125
 
126
- # [0.146.0-node18-core-styles-tooltips.23](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.22...v0.146.0-node18-core-styles-tooltips.23) (2025-10-27)
126
+ # [0.146.0-node18-tooltips.13](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.12...v0.146.0-node18-tooltips.13) (2025-10-02)
127
127
 
128
128
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
129
129
 
@@ -131,7 +131,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
131
131
 
132
132
 
133
133
 
134
- # [0.146.0-node18-core-styles-tooltips.22](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.21...v0.146.0-node18-core-styles-tooltips.22) (2025-10-20)
134
+ # [0.146.0-node18-tooltips.11](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.10...v0.146.0-node18-tooltips.11) (2025-10-01)
135
135
 
136
136
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
137
137
 
@@ -139,7 +139,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
139
139
 
140
140
 
141
141
 
142
- # [0.146.0-node18-core-styles-tooltips.20](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.19...v0.146.0-node18-core-styles-tooltips.20) (2025-10-03)
142
+ # [0.146.0-node18-tooltips.8](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.7...v0.146.0-node18-tooltips.8) (2025-09-24)
143
143
 
144
144
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
145
145
 
@@ -147,7 +147,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
147
147
 
148
148
 
149
149
 
150
- # [0.146.0-node18-core-styles-tooltips.19](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.18...v0.146.0-node18-core-styles-tooltips.19) (2025-10-01)
150
+ # [0.146.0-node18-tooltips.4](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.3...v0.146.0-node18-tooltips.4) (2025-09-22)
151
151
 
152
152
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
153
153
 
@@ -155,7 +155,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
155
155
 
156
156
 
157
157
 
158
- # [0.146.0-node18-core-styles-tooltips.18](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.17...v0.146.0-node18-core-styles-tooltips.18) (2025-09-29)
158
+ # [0.146.0-node18-tooltips.2](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-tooltips.1...v0.146.0-node18-tooltips.2) (2025-09-17)
159
159
 
160
160
  **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
161
161
 
@@ -163,63 +163,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
163
163
 
164
164
 
165
165
 
166
- # [0.146.0-node18-core-styles-tooltips.15](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.14...v0.146.0-node18-core-styles-tooltips.15) (2025-09-23)
167
-
168
- **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
169
-
170
-
171
-
172
-
173
-
174
- # [0.146.0-node18-core-styles-tooltips.13](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.12...v0.146.0-node18-core-styles-tooltips.13) (2025-09-15)
175
-
176
- **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
177
-
178
-
179
-
180
-
181
-
182
- # [0.146.0-node18-core-styles-tooltips.12](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.11...v0.146.0-node18-core-styles-tooltips.12) (2025-08-27)
183
-
184
- **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
185
-
186
-
187
-
188
-
189
-
190
- # [0.146.0-node18-core-styles-tooltips.11](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.10...v0.146.0-node18-core-styles-tooltips.11) (2025-08-27)
191
-
192
- **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
193
-
194
-
195
-
196
-
197
-
198
- # [0.146.0-node18-core-styles-tooltips.5](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.4...v0.146.0-node18-core-styles-tooltips.5) (2025-07-18)
199
-
200
- **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
201
-
202
-
203
-
204
-
205
-
206
- # [0.146.0-node18-core-styles-tooltips.4](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.3...v0.146.0-node18-core-styles-tooltips.4) (2025-07-10)
207
-
208
- **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
209
-
210
-
211
-
212
-
213
-
214
- # [0.146.0-node18-core-styles-tooltips.1](https://github.com/thebyte9/blaze/compare/v0.146.0-node18-core-styles-tooltips.0...v0.146.0-node18-core-styles-tooltips.1) (2025-06-20)
215
-
216
- **Note:** Version bump only for package @blaze-cms/plugin-google-maps-fe
217
-
218
-
219
-
220
-
221
-
222
- # [0.146.0-node18-core-styles-tooltips.0](https://github.com/thebyte9/blaze/compare/v0.145.0...v0.146.0-node18-core-styles-tooltips.0) (2025-06-18)
166
+ # [0.146.0-node18-tooltips.0](https://github.com/thebyte9/blaze/compare/v0.145.0...v0.146.0-node18-tooltips.0) (2025-09-09)
223
167
 
224
168
 
225
169
  ### Bug Fixes
@@ -0,0 +1,120 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ const _excluded = ["type", "name", "modifier", "elementTitle", "imageData", "onMount", "onMountProps", "parent", "mapShapes", "centerCoordinates"];
3
+ import React, { useEffect, useState } from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { useApolloClient } from '@apollo/client';
6
+ import { useRouter } from 'next/router';
7
+ import { withTitle } from '@blaze-cms/react-page-builder';
8
+ import { useInView } from '@blaze-react/utils/lib/customHooks';
9
+ import { functions, isEqual, omit } from 'lodash';
10
+ import { setMapOptions, addZoomListener } from './helpers';
11
+ import { GOOGLE_MAPS_SCRIPT, LOAD, SCRIPT, IN_VIEW_CONFIG } from '../constants';
12
+ import GoogleMapsHtml from './GoogleMapsHtml';
13
+ const shouldNotUpdate = (props, nextProps) => {
14
+ const [funcs, nextFuncs] = [functions(props), functions(nextProps)];
15
+ const noPropChange = isEqual(omit(props, funcs), omit(nextProps, nextFuncs));
16
+ const noFuncChange = funcs.length === nextFuncs.length && funcs.every(fn => props[fn].toString() === nextProps[fn].toString());
17
+ return noPropChange && noFuncChange;
18
+ };
19
+ const GoogleMaps = _ref => {
20
+ let {
21
+ type,
22
+ name,
23
+ modifier,
24
+ elementTitle,
25
+ imageData,
26
+ onMount,
27
+ onMountProps,
28
+ parent,
29
+ mapShapes,
30
+ centerCoordinates
31
+ } = _ref,
32
+ otherProps = _objectWithoutProperties(_ref, _excluded);
33
+ const router = useRouter();
34
+ const [isIntersecting, mapRef] = useInView(IN_VIEW_CONFIG);
35
+ const client = useApolloClient();
36
+ const [map, setMap] = useState();
37
+ useEffect(() => {
38
+ const options = setMapOptions(otherProps);
39
+ const onLoad = () => {
40
+ const initialMap = new window.google.maps.Map(mapRef.current, options);
41
+ if (centerCoordinates.length === 1) {
42
+ const [{
43
+ latitude: lat,
44
+ longitude: lng
45
+ }] = centerCoordinates;
46
+ initialMap.setCenter({
47
+ lat,
48
+ lng
49
+ });
50
+ } else {
51
+ const bounds = new window.google.maps.LatLngBounds();
52
+ centerCoordinates.forEach(({
53
+ latitude,
54
+ longitude
55
+ }) => {
56
+ bounds.extend(new window.google.maps.LatLng(latitude, longitude));
57
+ });
58
+ initialMap.fitBounds(bounds);
59
+ }
60
+ setMap(initialMap);
61
+ };
62
+ if (!window.google) {
63
+ const script = document.createElement(SCRIPT);
64
+ script.src = `${GOOGLE_MAPS_SCRIPT}${process.env.GOOGLE_MAPS_API_KEY}`;
65
+ document.head.append(script);
66
+ script.addEventListener(LOAD, onLoad);
67
+ return () => script.removeEventListener(LOAD, onLoad);
68
+ }
69
+ onLoad();
70
+ if (map) {
71
+ map.setOptions(options);
72
+ const {
73
+ enableGeolocation
74
+ } = otherProps;
75
+ const shouldActivateGeolocation = enableGeolocation && navigator.geolocation;
76
+ if (shouldActivateGeolocation) {
77
+ navigator.geolocation.getCurrentPosition(position => {
78
+ const center = {
79
+ lat: position.coords.latitude,
80
+ lng: position.coords.longitude
81
+ };
82
+ map.setCenter(center);
83
+ }, () => {});
84
+ }
85
+ }
86
+ return () => {};
87
+ // eslint-disable-next-line react-hooks/exhaustive-deps
88
+ }, []);
89
+ if (map && typeof onMount === `function`) onMount(map, onMountProps);
90
+ if (isIntersecting) addZoomListener(map, router, mapShapes, imageData, client);
91
+ return /*#__PURE__*/React.createElement(GoogleMapsHtml, {
92
+ mapRef: mapRef
93
+ });
94
+ };
95
+ GoogleMaps.propTypes = {
96
+ mapShapes: PropTypes.array,
97
+ imageData: PropTypes.array,
98
+ type: PropTypes.string,
99
+ name: PropTypes.string,
100
+ modifier: PropTypes.string,
101
+ elementTitle: PropTypes.string,
102
+ onMount: PropTypes.func,
103
+ onMountProps: PropTypes.object,
104
+ parent: PropTypes.object,
105
+ centerCoordinates: PropTypes.array
106
+ };
107
+ GoogleMaps.defaultProps = {
108
+ mapShapes: [],
109
+ imageData: [],
110
+ centerCoordinates: [],
111
+ type: '',
112
+ name: '',
113
+ modifier: '',
114
+ elementTitle: '',
115
+ onMount: null,
116
+ onMountProps: null,
117
+ parent: {}
118
+ };
119
+ export default React.memo(withTitle(GoogleMaps), shouldNotUpdate);
120
+ //# sourceMappingURL=GoogleMaps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleMaps.js","names":["React","useEffect","useState","PropTypes","useApolloClient","useRouter","withTitle","useInView","functions","isEqual","omit","setMapOptions","addZoomListener","GOOGLE_MAPS_SCRIPT","LOAD","SCRIPT","IN_VIEW_CONFIG","GoogleMapsHtml","shouldNotUpdate","props","nextProps","funcs","nextFuncs","noPropChange","noFuncChange","length","every","fn","toString","GoogleMaps","_ref","type","name","modifier","elementTitle","imageData","onMount","onMountProps","parent","mapShapes","centerCoordinates","otherProps","_objectWithoutProperties","_excluded","router","isIntersecting","mapRef","client","map","setMap","options","onLoad","initialMap","window","google","maps","Map","current","latitude","lat","longitude","lng","setCenter","bounds","LatLngBounds","forEach","extend","LatLng","fitBounds","script","document","createElement","src","process","env","GOOGLE_MAPS_API_KEY","head","append","addEventListener","removeEventListener","setOptions","enableGeolocation","shouldActivateGeolocation","navigator","geolocation","getCurrentPosition","position","center","coords","propTypes","array","string","func","object","defaultProps","memo"],"sources":["../../src/GoogleMaps/GoogleMaps.js"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { useApolloClient } from '@apollo/client';\nimport { useRouter } from 'next/router';\nimport { withTitle } from '@blaze-cms/react-page-builder';\nimport { useInView } from '@blaze-react/utils/lib/customHooks';\nimport { functions, isEqual, omit } from 'lodash';\nimport { setMapOptions, addZoomListener } from './helpers';\nimport { GOOGLE_MAPS_SCRIPT, LOAD, SCRIPT, IN_VIEW_CONFIG } from '../constants';\nimport GoogleMapsHtml from './GoogleMapsHtml';\n\nconst shouldNotUpdate = (props, nextProps) => {\n const [funcs, nextFuncs] = [functions(props), functions(nextProps)];\n const noPropChange = isEqual(omit(props, funcs), omit(nextProps, nextFuncs));\n const noFuncChange =\n funcs.length === nextFuncs.length &&\n funcs.every(fn => props[fn].toString() === nextProps[fn].toString());\n return noPropChange && noFuncChange;\n};\n\nconst GoogleMaps = ({\n type,\n name,\n modifier,\n elementTitle,\n imageData,\n onMount,\n onMountProps,\n parent,\n mapShapes,\n centerCoordinates,\n ...otherProps\n}) => {\n const router = useRouter();\n const [isIntersecting, mapRef] = useInView(IN_VIEW_CONFIG);\n const client = useApolloClient();\n const [map, setMap] = useState();\n\n useEffect(() => {\n const options = setMapOptions(otherProps);\n const onLoad = () => {\n const initialMap = new window.google.maps.Map(mapRef.current, options);\n if (centerCoordinates.length === 1) {\n const [{ latitude: lat, longitude: lng }] = centerCoordinates;\n initialMap.setCenter({ lat, lng });\n } else {\n const bounds = new window.google.maps.LatLngBounds();\n centerCoordinates.forEach(({ latitude, longitude }) => {\n bounds.extend(new window.google.maps.LatLng(latitude, longitude));\n });\n initialMap.fitBounds(bounds);\n }\n setMap(initialMap);\n };\n\n if (!window.google) {\n const script = document.createElement(SCRIPT);\n script.src = `${GOOGLE_MAPS_SCRIPT}${process.env.GOOGLE_MAPS_API_KEY}`;\n document.head.append(script);\n script.addEventListener(LOAD, onLoad);\n return () => script.removeEventListener(LOAD, onLoad);\n }\n\n onLoad();\n\n if (map) {\n map.setOptions(options);\n const { enableGeolocation } = otherProps;\n const shouldActivateGeolocation = enableGeolocation && navigator.geolocation;\n if (shouldActivateGeolocation) {\n navigator.geolocation.getCurrentPosition(\n position => {\n const center = {\n lat: position.coords.latitude,\n lng: position.coords.longitude\n };\n\n map.setCenter(center);\n },\n () => {}\n );\n }\n }\n\n return () => {};\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n if (map && typeof onMount === `function`) onMount(map, onMountProps);\n if (isIntersecting) addZoomListener(map, router, mapShapes, imageData, client);\n\n return <GoogleMapsHtml mapRef={mapRef} />;\n};\n\nGoogleMaps.propTypes = {\n mapShapes: PropTypes.array,\n imageData: PropTypes.array,\n type: PropTypes.string,\n name: PropTypes.string,\n modifier: PropTypes.string,\n elementTitle: PropTypes.string,\n onMount: PropTypes.func,\n onMountProps: PropTypes.object,\n parent: PropTypes.object,\n centerCoordinates: PropTypes.array\n};\n\nGoogleMaps.defaultProps = {\n mapShapes: [],\n imageData: [],\n centerCoordinates: [],\n type: '',\n name: '',\n modifier: '',\n elementTitle: '',\n onMount: null,\n onMountProps: null,\n parent: {}\n};\n\nexport default React.memo(withTitle(GoogleMaps), shouldNotUpdate);\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ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C,SAAS,CAACuF,KAAK;EAC1BvD,SAAS,EAAEhC,SAAS,CAACuF,KAAK;EAC1B3D,IAAI,EAAE5B,SAAS,CAACwF,MAAM;EACtB3D,IAAI,EAAE7B,SAAS,CAACwF,MAAM;EACtB1D,QAAQ,EAAE9B,SAAS,CAACwF,MAAM;EAC1BzD,YAAY,EAAE/B,SAAS,CAACwF,MAAM;EAC9BvD,OAAO,EAAEjC,SAAS,CAACyF,IAAI;EACvBvD,YAAY,EAAElC,SAAS,CAAC0F,MAAM;EAC9BvD,MAAM,EAAEnC,SAAS,CAAC0F,MAAM;EACxBrD,iBAAiB,EAAErC,SAAS,CAACuF;AAC/B,CAAC;AAED7D,UAAU,CAACiE,YAAY,GAAG;EACxBvD,SAAS,EAAE,EAAE;EACbJ,SAAS,EAAE,EAAE;EACbK,iBAAiB,EAAE,EAAE;EACrBT,IAAI,EAAE,EAAE;EACRC,IAAI,EAAE,EAAE;EACRC,QAAQ,EAAE,EAAE;EACZC,YAAY,EAAE,EAAE;EAChBE,OAAO,EAAE,IAAI;EACbC,YAAY,EAAE,IAAI;EAClBC,MAAM,EAAE,CAAC;AACX,CAAC;AAED,eAAetC,KAAK,CAAC+F,IAAI,CAACzF,SAAS,CAACuB,UAAU,CAAC,EAAEX,eAAe,CAAC","ignoreList":[]}
@@ -0,0 +1,41 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ const _excluded = ["entityGroups", "parent"];
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { useGetEntitySchemasAsObj } from '@blaze-cms/react-page-builder';
7
+ import { buildShapesConfig } from './helpers';
8
+ import GoogleMapsRender from './GoogleMapsRender';
9
+ import GoogleMapsHtml from './GoogleMapsHtml';
10
+ const GoogleMapsFactory = _ref => {
11
+ let {
12
+ entityGroups,
13
+ parent
14
+ } = _ref,
15
+ otherProps = _objectWithoutProperties(_ref, _excluded);
16
+ const {
17
+ data,
18
+ loading,
19
+ error
20
+ } = useGetEntitySchemasAsObj(entityGroups.map(({
21
+ entity
22
+ }) => entity));
23
+ if (loading) return /*#__PURE__*/React.createElement(GoogleMapsHtml, null);
24
+ if (error) return error.message;
25
+ const shapeConfigs = buildShapesConfig(data, entityGroups, parent);
26
+ return /*#__PURE__*/React.createElement(GoogleMapsRender, _extends({
27
+ shapeConfigs: shapeConfigs,
28
+ entityGroups: entityGroups,
29
+ parent: parent
30
+ }, otherProps));
31
+ };
32
+ GoogleMapsFactory.propTypes = {
33
+ parent: PropTypes.object,
34
+ entityGroups: PropTypes.array
35
+ };
36
+ GoogleMapsFactory.defaultProps = {
37
+ parent: {},
38
+ entityGroups: []
39
+ };
40
+ export default GoogleMapsFactory;
41
+ //# sourceMappingURL=GoogleMapsFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleMapsFactory.js","names":["React","PropTypes","useGetEntitySchemasAsObj","buildShapesConfig","GoogleMapsRender","GoogleMapsHtml","GoogleMapsFactory","_ref","entityGroups","parent","otherProps","_objectWithoutProperties","_excluded","data","loading","error","map","entity","createElement","message","shapeConfigs","_extends","propTypes","object","array","defaultProps"],"sources":["../../src/GoogleMaps/GoogleMapsFactory.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { useGetEntitySchemasAsObj } from '@blaze-cms/react-page-builder';\nimport { buildShapesConfig } from './helpers';\nimport GoogleMapsRender from './GoogleMapsRender';\nimport GoogleMapsHtml from './GoogleMapsHtml';\n\nconst GoogleMapsFactory = ({ entityGroups, parent, ...otherProps }) => {\n const { data, loading, error } = useGetEntitySchemasAsObj(\n entityGroups.map(({ entity }) => entity)\n );\n\n if (loading) return <GoogleMapsHtml />;\n if (error) return error.message;\n\n const shapeConfigs = buildShapesConfig(data, entityGroups, parent);\n\n return (\n <GoogleMapsRender\n shapeConfigs={shapeConfigs}\n entityGroups={entityGroups}\n parent={parent}\n {...otherProps}\n />\n );\n};\n\nGoogleMapsFactory.propTypes = {\n parent: PropTypes.object,\n entityGroups: PropTypes.array\n};\n\nGoogleMapsFactory.defaultProps = {\n parent: {},\n entityGroups: []\n};\n\nexport default GoogleMapsFactory;\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,wBAAwB,QAAQ,+BAA+B;AACxE,SAASC,iBAAiB,QAAQ,WAAW;AAC7C,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,cAAc,MAAM,kBAAkB;AAE7C,MAAMC,iBAAiB,GAAGC,IAAA,IAA6C;EAAA,IAA5C;MAAEC,YAAY;MAAEC;IAAsB,CAAC,GAAAF,IAAA;IAAZG,UAAU,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EAC9D,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGb,wBAAwB,CACvDM,YAAY,CAACQ,GAAG,CAAC,CAAC;IAAEC;EAAO,CAAC,KAAKA,MAAM,CACzC,CAAC;EAED,IAAIH,OAAO,EAAE,oBAAOd,KAAA,CAAAkB,aAAA,CAACb,cAAc,MAAE,CAAC;EACtC,IAAIU,KAAK,EAAE,OAAOA,KAAK,CAACI,OAAO;EAE/B,MAAMC,YAAY,GAAGjB,iBAAiB,CAACU,IAAI,EAAEL,YAAY,EAAEC,MAAM,CAAC;EAElE,oBACET,KAAA,CAAAkB,aAAA,CAACd,gBAAgB,EAAAiB,QAAA;IACfD,YAAY,EAAEA,YAAa;IAC3BZ,YAAY,EAAEA,YAAa;IAC3BC,MAAM,EAAEA;EAAO,GACXC,UAAU,CACf,CAAC;AAEN,CAAC;AAEDJ,iBAAiB,CAACgB,SAAS,GAAG;EAC5Bb,MAAM,EAAER,SAAS,CAACsB,MAAM;EACxBf,YAAY,EAAEP,SAAS,CAACuB;AAC1B,CAAC;AAEDlB,iBAAiB,CAACmB,YAAY,GAAG;EAC/BhB,MAAM,EAAE,CAAC,CAAC;EACVD,YAAY,EAAE;AAChB,CAAC;AAED,eAAeF,iBAAiB","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ const GoogleMapsFactory = ({
4
+ mapRef
5
+ }) => /*#__PURE__*/React.createElement("div", {
6
+ className: `google-maps ${!mapRef ? 'loading' : ''}`,
7
+ ref: mapRef
8
+ });
9
+ GoogleMapsFactory.propTypes = {
10
+ mapRef: PropTypes.object
11
+ };
12
+ GoogleMapsFactory.defaultProps = {
13
+ mapRef: null
14
+ };
15
+ export default GoogleMapsFactory;
16
+ //# sourceMappingURL=GoogleMapsHtml.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleMapsHtml.js","names":["React","PropTypes","GoogleMapsFactory","mapRef","createElement","className","ref","propTypes","object","defaultProps"],"sources":["../../src/GoogleMaps/GoogleMapsHtml.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst GoogleMapsFactory = ({ mapRef }) => (\n <div className={`google-maps ${!mapRef ? 'loading' : ''}`} ref={mapRef} />\n);\n\nGoogleMapsFactory.propTypes = {\n mapRef: PropTypes.object\n};\n\nGoogleMapsFactory.defaultProps = {\n mapRef: null\n};\n\nexport default GoogleMapsFactory;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAElC,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC;AAAO,CAAC,kBACnCH,KAAA,CAAAI,aAAA;EAAKC,SAAS,EAAE,eAAe,CAACF,MAAM,GAAG,SAAS,GAAG,EAAE,EAAG;EAACG,GAAG,EAAEH;AAAO,CAAE,CAC1E;AAEDD,iBAAiB,CAACK,SAAS,GAAG;EAC5BJ,MAAM,EAAEF,SAAS,CAACO;AACpB,CAAC;AAEDN,iBAAiB,CAACO,YAAY,GAAG;EAC/BN,MAAM,EAAE;AACV,CAAC;AAED,eAAeD,iBAAiB","ignoreList":[]}
@@ -0,0 +1,72 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ const _excluded = ["shapeConfigs", "entityGroups", "id"];
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import isNumber from 'lodash.isnumber';
7
+ import { useQuery } from '@apollo/client';
8
+ import { getAction } from '@blaze-cms/react-page-builder';
9
+ import { useGetImages } from './hooks';
10
+ import { buildQuery, getImageIds, getCenterCoordinates, buildMapShapes } from './helpers';
11
+ import GoogleMaps from './GoogleMaps';
12
+ import GoogleMapsHtml from './GoogleMapsHtml';
13
+ const defaultQuery = getAction('getPublishedPages', 'id');
14
+ const GoogleMapsRender = _ref => {
15
+ let {
16
+ shapeConfigs,
17
+ entityGroups,
18
+ id
19
+ } = _ref,
20
+ otherProps = _objectWithoutProperties(_ref, _excluded);
21
+ const {
22
+ defaultZoom
23
+ } = otherProps;
24
+ const {
25
+ query
26
+ } = buildQuery(shapeConfigs);
27
+ const {
28
+ data,
29
+ loading,
30
+ error
31
+ } = useQuery(query || defaultQuery, {
32
+ skip: !query
33
+ });
34
+ const mapShapes = buildMapShapes(shapeConfigs, data);
35
+ const imageIds = getImageIds(mapShapes);
36
+ const {
37
+ data: {
38
+ getFiles: imageData
39
+ } = {},
40
+ loading: imagesLoading,
41
+ error: imagesError
42
+ } = useGetImages(imageIds);
43
+ if (loading || imagesLoading) return /*#__PURE__*/React.createElement(GoogleMapsHtml, null);
44
+ if (error || imagesError) return null;
45
+ const centerCoordinates = getCenterCoordinates(mapShapes, otherProps);
46
+ const shouldDisplayMap = isNumber(defaultZoom) && !!centerCoordinates.length;
47
+ if (!shouldDisplayMap) return null;
48
+ return /*#__PURE__*/React.createElement(GoogleMaps, _extends({
49
+ key: otherProps.slug,
50
+ centerCoordinates: centerCoordinates,
51
+ mapShapes: mapShapes,
52
+ imageData: imageData
53
+ }, otherProps));
54
+ };
55
+ GoogleMapsRender.propTypes = {
56
+ entityGroups: PropTypes.array,
57
+ id: PropTypes.string,
58
+ shapeConfigs: PropTypes.array,
59
+ centerLatitude: PropTypes.number,
60
+ centerLongitude: PropTypes.number,
61
+ defaultZoom: PropTypes.number
62
+ };
63
+ GoogleMapsRender.defaultProps = {
64
+ entityGroups: [],
65
+ shapeConfigs: [],
66
+ id: '',
67
+ centerLatitude: null,
68
+ centerLongitude: null,
69
+ defaultZoom: null
70
+ };
71
+ export default GoogleMapsRender;
72
+ //# sourceMappingURL=GoogleMapsRender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleMapsRender.js","names":["React","PropTypes","isNumber","useQuery","getAction","useGetImages","buildQuery","getImageIds","getCenterCoordinates","buildMapShapes","GoogleMaps","GoogleMapsHtml","defaultQuery","GoogleMapsRender","_ref","shapeConfigs","entityGroups","id","otherProps","_objectWithoutProperties","_excluded","defaultZoom","query","data","loading","error","skip","mapShapes","imageIds","getFiles","imageData","imagesLoading","imagesError","createElement","centerCoordinates","shouldDisplayMap","length","_extends","key","slug","propTypes","array","string","centerLatitude","number","centerLongitude","defaultProps"],"sources":["../../src/GoogleMaps/GoogleMapsRender.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isNumber from 'lodash.isnumber';\nimport { useQuery } from '@apollo/client';\nimport { getAction } from '@blaze-cms/react-page-builder';\nimport { useGetImages } from './hooks';\nimport { buildQuery, getImageIds, getCenterCoordinates, buildMapShapes } from './helpers';\nimport GoogleMaps from './GoogleMaps';\nimport GoogleMapsHtml from './GoogleMapsHtml';\n\nconst defaultQuery = getAction('getPublishedPages', 'id');\n\nconst GoogleMapsRender = ({ shapeConfigs, entityGroups, id, ...otherProps }) => {\n const { defaultZoom } = otherProps;\n const { query } = buildQuery(shapeConfigs);\n const { data, loading, error } = useQuery(query || defaultQuery, {\n skip: !query\n });\n\n const mapShapes = buildMapShapes(shapeConfigs, data);\n const imageIds = getImageIds(mapShapes);\n const {\n data: { getFiles: imageData } = {},\n loading: imagesLoading,\n error: imagesError\n } = useGetImages(imageIds);\n if (loading || imagesLoading) return <GoogleMapsHtml />;\n if (error || imagesError) return null;\n\n const centerCoordinates = getCenterCoordinates(mapShapes, otherProps);\n const shouldDisplayMap = isNumber(defaultZoom) && !!centerCoordinates.length;\n\n if (!shouldDisplayMap) return null;\n\n return (\n <GoogleMaps\n key={otherProps.slug}\n centerCoordinates={centerCoordinates}\n mapShapes={mapShapes}\n imageData={imageData}\n {...otherProps}\n />\n );\n};\n\nGoogleMapsRender.propTypes = {\n entityGroups: PropTypes.array,\n id: PropTypes.string,\n shapeConfigs: PropTypes.array,\n centerLatitude: PropTypes.number,\n centerLongitude: PropTypes.number,\n defaultZoom: PropTypes.number\n};\n\nGoogleMapsRender.defaultProps = {\n entityGroups: [],\n shapeConfigs: [],\n id: '',\n centerLatitude: null,\n centerLongitude: null,\n defaultZoom: null\n};\n\nexport default GoogleMapsRender;\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,QAAQ,MAAM,iBAAiB;AACtC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,+BAA+B;AACzD,SAASC,YAAY,QAAQ,SAAS;AACtC,SAASC,UAAU,EAAEC,WAAW,EAAEC,oBAAoB,EAAEC,cAAc,QAAQ,WAAW;AACzF,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,cAAc,MAAM,kBAAkB;AAE7C,MAAMC,YAAY,GAAGR,SAAS,CAAC,mBAAmB,EAAE,IAAI,CAAC;AAEzD,MAAMS,gBAAgB,GAAGC,IAAA,IAAuD;EAAA,IAAtD;MAAEC,YAAY;MAAEC,YAAY;MAAEC;IAAkB,CAAC,GAAAH,IAAA;IAAZI,UAAU,GAAAC,wBAAA,CAAAL,IAAA,EAAAM,SAAA;EACvE,MAAM;IAAEC;EAAY,CAAC,GAAGH,UAAU;EAClC,MAAM;IAAEI;EAAM,CAAC,GAAGhB,UA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AE1C,SAAS,CAAC2C,MAAM;EAChCC,eAAe,EAAE5C,SAAS,CAAC2C,MAAM;EACjCvB,WAAW,EAAEpB,SAAS,CAAC2C;AACzB,CAAC;AAED/B,gBAAgB,CAACiC,YAAY,GAAG;EAC9B9B,YAAY,EAAE,EAAE;EAChBD,YAAY,EAAE,EAAE;EAChBE,EAAE,EAAE,EAAE;EACN0B,cAAc,EAAE,IAAI;EACpBE,eAAe,EAAE,IAAI;EACrBxB,WAAW,EAAE;AACf,CAAC;AAED,eAAeR,gBAAgB","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import { ZOOM_CHANGED } from '../../constants';
2
+ import setShapes from './set-shapes';
3
+ const addZoomListener = (map, router, shapes, imageData, client) => {
4
+ if (!map) return;
5
+ setShapes(map, router, shapes, imageData);
6
+ map.addListener(ZOOM_CHANGED, () => setShapes(map, router, shapes, imageData, client));
7
+ };
8
+ export default addZoomListener;
9
+ //# sourceMappingURL=add-zoom-listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-zoom-listener.js","names":["ZOOM_CHANGED","setShapes","addZoomListener","map","router","shapes","imageData","client","addListener"],"sources":["../../../src/GoogleMaps/helpers/add-zoom-listener.js"],"sourcesContent":["import { ZOOM_CHANGED } from '../../constants';\nimport setShapes from './set-shapes';\n\nconst addZoomListener = (map, router, shapes, imageData, client) => {\n if (!map) return;\n setShapes(map, router, shapes, imageData);\n map.addListener(ZOOM_CHANGED, () => setShapes(map, router, shapes, imageData, client));\n};\n\nexport default addZoomListener;\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,iBAAiB;AAC9C,OAAOC,SAAS,MAAM,cAAc;AAEpC,MAAMC,eAAe,GAAGA,CAACC,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,MAAM,KAAK;EAClE,IAAI,CAACJ,GAAG,EAAE;EACVF,SAAS,CAACE,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,SAAS,CAAC;EACzCH,GAAG,CAACK,WAAW,CAACR,YAAY,EAAE,MAAMC,SAAS,CAACE,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,SAAS,EAAEC,MAAM,CAAC,CAAC;AACxF,CAAC;AAED,eAAeL,eAAe","ignoreList":[]}
@@ -0,0 +1,68 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ const getLatLonValues = (keys, data) => {
5
+ if (keys.length === 1) return data[keys];
6
+ const key = keys.shift();
7
+ return getLatLonValues(keys, data[key]);
8
+ };
9
+ const getLatLong = (latProp, lonProp, shape, data) => {
10
+ const {
11
+ latitude,
12
+ longitude
13
+ } = shape;
14
+ if (!latProp || !lonProp) return {
15
+ latitude,
16
+ longitude
17
+ };
18
+ const latKeys = latProp.split('.');
19
+ const lonKeys = lonProp.split('.');
20
+ const lat = getLatLonValues(latKeys, data);
21
+ const lon = getLatLonValues(lonKeys, data);
22
+ return {
23
+ latitude: lat,
24
+ longitude: lon
25
+ };
26
+ };
27
+ const buildMapShapes = (shapesOptions, shapesData) => {
28
+ if (!shapesData) return [];
29
+ const mapShapes = [];
30
+ shapesOptions.forEach(shape => {
31
+ const {
32
+ shapeKey,
33
+ entityOptions,
34
+ shapeOptions
35
+ } = shape;
36
+ const {
37
+ dataSummaries,
38
+ enableInfoPane
39
+ } = entityOptions;
40
+ const shapeData = Array.isArray(shapesData[shapeKey]) ? shapesData[shapeKey] : shapesData[shapeKey].results;
41
+ if (!shapeData) return;
42
+ const {
43
+ latProp,
44
+ lonProp
45
+ } = entityOptions;
46
+ shapeData.forEach(data => {
47
+ const {
48
+ url
49
+ } = data;
50
+ const {
51
+ latitude,
52
+ longitude
53
+ } = getLatLong(latProp, lonProp, shapeOptions, data);
54
+ const formatedShape = _objectSpread(_objectSpread({}, shapeOptions), {}, {
55
+ latitude,
56
+ longitude,
57
+ dataSummaries,
58
+ enableInfoPane,
59
+ url,
60
+ shapeData: data
61
+ });
62
+ mapShapes.push(formatedShape);
63
+ });
64
+ });
65
+ return mapShapes;
66
+ };
67
+ export default buildMapShapes;
68
+ //# sourceMappingURL=build-map-shapes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-map-shapes.js","names":["getLatLonValues","keys","data","length","key","shift","getLatLong","latProp","lonProp","shape","latitude","longitude","latKeys","split","lonKeys","lat","lon","buildMapShapes","shapesOptions","shapesData","mapShapes","forEach","shapeKey","entityOptions","shapeOptions","dataSummaries","enableInfoPane","shapeData","Array","isArray","results","url","formatedShape","_objectSpread","push"],"sources":["../../../src/GoogleMaps/helpers/build-map-shapes.js"],"sourcesContent":["const getLatLonValues = (keys, data) => {\n if (keys.length === 1) return data[keys];\n const key = keys.shift();\n return getLatLonValues(keys, data[key]);\n};\n\nconst getLatLong = (latProp, lonProp, shape, data) => {\n const { latitude, longitude } = shape;\n\n if (!latProp || !lonProp) return { latitude, longitude };\n const latKeys = latProp.split('.');\n const lonKeys = lonProp.split('.');\n const lat = getLatLonValues(latKeys, data);\n const lon = getLatLonValues(lonKeys, data);\n\n return { latitude: lat, longitude: lon };\n};\n\nconst buildMapShapes = (shapesOptions, shapesData) => {\n if (!shapesData) return [];\n const mapShapes = [];\n shapesOptions.forEach(shape => {\n const { shapeKey, entityOptions, shapeOptions } = shape;\n const { dataSummaries, enableInfoPane } = entityOptions;\n\n const shapeData = Array.isArray(shapesData[shapeKey])\n ? shapesData[shapeKey]\n : shapesData[shapeKey].results;\n if (!shapeData) return;\n const { latProp, lonProp } = entityOptions;\n\n shapeData.forEach(data => {\n const { url } = data;\n const { latitude, longitude } = getLatLong(latProp, lonProp, shapeOptions, data);\n\n const formatedShape = {\n ...shapeOptions,\n latitude,\n longitude,\n dataSummaries,\n enableInfoPane,\n url,\n shapeData: data\n };\n\n mapShapes.push(formatedShape);\n });\n });\n\n return mapShapes;\n};\n\nexport default buildMapShapes;\n"],"mappings":";;;AAAA,MAAMA,eAAe,GAAGA,CAACC,IAAI,EAAEC,IAAI,KAAK;EACtC,IAAID,IAAI,CAACE,MAAM,KAAK,CAAC,EAAE,OAAOD,IAAI,CAACD,IAAI,CAAC;EACxC,MAAMG,GAAG,GAAGH,IAAI,CAACI,KAAK,CAAC,CAAC;EACxB,OAAOL,eAAe,CAACC,IAAI,EAAEC,IAAI,CAACE,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,MAAME,UAAU,GAAGA,CAACC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAEP,IAAI,KAAK;EACpD,MAAM;IAAEQ,QAAQ;IAAEC;EAAU,CAAC,GAAGF,KAAK;EAErC,IAAI,CAACF,OAAO,IAAI,CAACC,OAAO,EAAE,OAAO;IAAEE,QAAQ;IAAEC;EAAU,CAAC;EACxD,MAAMC,OAAO,GAAGL,OAAO,CAACM,KAAK,CAAC,GAAG,CAAC;EAClC,MAAMC,OAAO,GAAGN,OAAO,CAACK,KAAK,CAAC,GAAG,CAAC;EAClC,MAAME,GAAG,GAAGf,eAAe,CAACY,OAAO,EAAEV,IAAI,CAAC;EAC1C,MAAMc,GAAG,GAAGhB,eAAe,CAACc,OAAO,EAAEZ,IAAI,CAAC;EAE1C,OAAO;IAAEQ,QAAQ,EAAEK,GAAG;IAAEJ,SAAS,EAAEK;EAAI,CAAC;AAC1C,CAAC;AAED,MAAMC,cAAc,GAAGA,CAACC,aAAa,EAAEC,UAAU,KAAK;EACpD,IAAI,CAACA,UAAU,EAAE,OAAO,EAAE;EAC1B,MAAMC,SAAS,GAAG,EAAE;EACpBF,aAAa,CAACG,OAAO,CAACZ,KAAK,IAAI;IAC7B,MAAM;MAAEa,QAAQ;MAAEC,aAAa;MAAEC;IAAa,CAAC,GAAGf,KAAK;IACvD,MAAM;MAAEgB,aAAa;MAAEC;IAAe,CAAC,GAAGH,aAAa;IAEvD,MAAMI,SAAS,GAAGC,KAAK,CAACC,OAAO,CAACV,UAAU,CAACG,QAAQ,CAAC,CAAC,GACjDH,UAAU,CAACG,QAAQ,CAAC,GACpBH,UAAU,CAACG,QAAQ,CAAC,CAACQ,OAAO;IAChC,IAAI,CAACH,SAAS,EAAE;IAChB,MAAM;MAAEpB,OAAO;MAAEC;IAAQ,CAAC,GAAGe,aAAa;IAE1CI,SAAS,CAACN,OAAO,CAACnB,IAAI,IAAI;MACxB,MAAM;QAAE6B;MAAI,CAAC,GAAG7B,IAAI;MACpB,MAAM;QAAEQ,QAAQ;QAAEC;MAAU,CAAC,GAAGL,UAAU,CAACC,OAAO,EAAEC,OAAO,EAAEgB,YAAY,EAAEtB,IAAI,CAAC;MAEhF,MAAM8B,aAAa,GAAAC,aAAA,CAAAA,aAAA,KACdT,YAAY;QACfd,QAAQ;QACRC,SAAS;QACTc,aAAa;QACbC,cAAc;QACdK,GAAG;QACHJ,SAAS,EAAEzB;MAAI,EAChB;MAEDkB,SAAS,CAACc,IAAI,CAACF,aAAa,CAAC;IAC/B,CAAC,CAAC;EACJ,CAAC,CAAC;EAEF,OAAOZ,SAAS;AAClB,CAAC;AAED,eAAeH,cAAc","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import { ROADMAP, SATELLITE, TERRAIN } from '../../constants';
2
+ const buildMapTypeIds = (enableSatelliteView, enableTerrainScreen) => {
3
+ const mapTypeIds = [ROADMAP];
4
+ if (enableSatelliteView) mapTypeIds.push(SATELLITE);
5
+ if (enableTerrainScreen) mapTypeIds.push(TERRAIN);
6
+ return mapTypeIds;
7
+ };
8
+ export default buildMapTypeIds;
9
+ //# sourceMappingURL=build-map-type-ids.js.map