@appbaseio/reactivesearch-vue 1.29.0 → 2.0.0-alpha

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 (89) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +11162 -762
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +21 -5
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/{Button-e0b7c1f6.js → Button-446f819e.js} +1 -1
  6. package/dist/cjs/{CancelSvg-4aa35935.js → CancelSvg-9f258f4f.js} +1 -1
  7. package/dist/cjs/{Card-fd94ef07.js → Card-642547a8.js} +2 -2
  8. package/dist/cjs/{ComponentWrapper-10bad289.js → ComponentWrapper-ad3dad02.js} +2 -2
  9. package/dist/cjs/{Container-526efa6a.js → Container-daf30918.js} +1 -1
  10. package/dist/cjs/{DataSearch-eec21890.js → DataSearch-6cf29cf0.js} +236 -84
  11. package/dist/cjs/DataSearch.js +10 -10
  12. package/dist/cjs/{DropDown-e4381fcc.js → DropDown-c479bbb0.js} +5 -5
  13. package/dist/cjs/DynamicRangeSlider.js +8 -7
  14. package/dist/cjs/{Flex-f146cdad.js → Flex-aa517a13.js} +1 -1
  15. package/dist/cjs/{FormControlList-808dbcef.js → FormControlList-c195a592.js} +1 -1
  16. package/dist/cjs/{Input-0d7b25ad.js → Input-e6603a7e.js} +1 -1
  17. package/dist/cjs/{ListItem-b40adb04.js → ListItem-8c9e0d68.js} +2 -2
  18. package/dist/cjs/MultiDropdownList.js +13 -12
  19. package/dist/cjs/MultiList.js +11 -10
  20. package/dist/cjs/MultiRange.js +9 -8
  21. package/dist/cjs/Pagination-71e85fa9.js +182 -0
  22. package/dist/cjs/RangeInput.js +11 -10
  23. package/dist/cjs/RangeSlider.js +9 -8
  24. package/dist/cjs/ReactiveBase.js +69 -35
  25. package/dist/cjs/ReactiveComponent.js +6 -5
  26. package/dist/cjs/ReactiveGoogleMap.js +2336 -0
  27. package/dist/cjs/ReactiveList.js +22 -185
  28. package/dist/cjs/ResultCard.js +4 -4
  29. package/dist/cjs/ResultList.js +4 -4
  30. package/dist/cjs/SelectedFilters.js +45 -28
  31. package/dist/cjs/SingleDropdownList.js +13 -12
  32. package/dist/cjs/SingleList.js +11 -10
  33. package/dist/cjs/SingleRange.js +10 -9
  34. package/dist/cjs/StateProvider.js +30 -5
  35. package/dist/cjs/{Title-584a8cc8.js → Title-1de7d0f4.js} +1 -1
  36. package/dist/cjs/ToggleButton.js +10 -8
  37. package/dist/cjs/{_rollupPluginBabelHelpers-f127c8b7.js → _rollupPluginBabelHelpers-c705cbe6.js} +17 -2
  38. package/dist/cjs/{index-4509aa45.js → index-6a167fe0.js} +13 -1
  39. package/dist/cjs/index.js +24 -18
  40. package/dist/cjs/initReactivesearch.js +40 -8
  41. package/dist/cjs/{install-4886582d.js → install-99716d95.js} +252 -87
  42. package/dist/cjs/install.js +20 -18
  43. package/dist/cjs/{ssr-0ee35a09.js → ssr-3027b848.js} +1 -1
  44. package/dist/cjs/{utils-1219e1fe.js → utils-d6a52588.js} +1 -1
  45. package/dist/cjs/version.js +1 -1
  46. package/dist/cjs/{vueTypes-57d01f18.js → vueTypes-727b7c63.js} +30 -13
  47. package/dist/es/{Button-33de88e6.js → Button-d8bc15ea.js} +1 -1
  48. package/dist/es/{CancelSvg-c2c03a35.js → CancelSvg-4cfae5fd.js} +1 -1
  49. package/dist/es/{Card-6446f1b7.js → Card-450683f1.js} +2 -2
  50. package/dist/es/{ComponentWrapper-0f3431d1.js → ComponentWrapper-424e86fd.js} +2 -2
  51. package/dist/es/{Container-18b03fde.js → Container-ba826e96.js} +1 -1
  52. package/dist/es/{DataSearch-42f547cd.js → DataSearch-4888aa43.js} +236 -86
  53. package/dist/es/DataSearch.js +10 -10
  54. package/dist/es/{DropDown-ff6ad982.js → DropDown-05a644a5.js} +5 -5
  55. package/dist/es/DynamicRangeSlider.js +8 -7
  56. package/dist/es/{Flex-8770345d.js → Flex-1f0795c3.js} +1 -1
  57. package/dist/es/{FormControlList-704f8dee.js → FormControlList-c22d64f6.js} +1 -1
  58. package/dist/es/{Input-e339e63a.js → Input-7a2a9fac.js} +1 -1
  59. package/dist/es/{ListItem-8e8fb535.js → ListItem-cad14c5e.js} +2 -2
  60. package/dist/es/MultiDropdownList.js +13 -12
  61. package/dist/es/MultiList.js +11 -10
  62. package/dist/es/MultiRange.js +9 -8
  63. package/dist/es/Pagination-784bf143.js +177 -0
  64. package/dist/es/RangeInput.js +11 -10
  65. package/dist/es/RangeSlider.js +9 -8
  66. package/dist/es/ReactiveBase.js +70 -36
  67. package/dist/es/ReactiveComponent.js +6 -5
  68. package/dist/es/ReactiveGoogleMap.js +2327 -0
  69. package/dist/es/ReactiveList.js +21 -184
  70. package/dist/es/ResultCard.js +4 -4
  71. package/dist/es/ResultList.js +4 -4
  72. package/dist/es/SelectedFilters.js +45 -28
  73. package/dist/es/SingleDropdownList.js +13 -12
  74. package/dist/es/SingleList.js +11 -10
  75. package/dist/es/SingleRange.js +10 -9
  76. package/dist/es/StateProvider.js +30 -5
  77. package/dist/es/{Title-3522ff56.js → Title-3342664a.js} +1 -1
  78. package/dist/es/ToggleButton.js +10 -8
  79. package/dist/es/{_rollupPluginBabelHelpers-0f24d612.js → _rollupPluginBabelHelpers-76660dab.js} +17 -3
  80. package/dist/es/{index-78920565.js → index-7788a843.js} +13 -2
  81. package/dist/es/index.js +24 -19
  82. package/dist/es/initReactivesearch.js +41 -9
  83. package/dist/es/{install-54ebd72e.js → install-87984085.js} +252 -87
  84. package/dist/es/install.js +20 -18
  85. package/dist/es/{ssr-a41dfea9.js → ssr-b2c0b401.js} +1 -1
  86. package/dist/es/{utils-64a2e5f0.js → utils-9e68acee.js} +1 -1
  87. package/dist/es/version.js +1 -1
  88. package/dist/es/{vueTypes-687b2304.js → vueTypes-b8146772.js} +30 -13
  89. package/package.json +11 -5
@@ -0,0 +1,2327 @@
1
+ import { Actions, helper } from '@appbaseio/reactivecore';
2
+ import { a as _extends, b as _objectWithoutPropertiesLoose, c as _toPropertyKey, d as _inheritsLoose, _ as _taggedTemplateLiteralLoose } from './_rollupPluginBabelHelpers-76660dab.js';
3
+ import VueTypes from 'vue-types';
4
+ import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
5
+ import 'emotion';
6
+ import styled, { css } from '@appbaseio/vue-emotion';
7
+ import 'polished';
8
+ import './Button-d8bc15ea.js';
9
+ import { t as types } from './vueTypes-b8146772.js';
10
+ import { P as Pagination } from './Pagination-784bf143.js';
11
+ import '@appbaseio/reactivecore/lib/utils/transform';
12
+ import 'redux';
13
+ import { h as hasCustomRenderer, i as isQueryIdentical, g as getComponent, a as isFunction, c as connect } from './index-7788a843.js';
14
+ import { C as ComponentWrapper } from './ComponentWrapper-424e86fd.js';
15
+ import _mergeJSXProps from '@vue/babel-helper-vue-jsx-merge-props';
16
+ import { C as Checkbox } from './FormControlList-c22d64f6.js';
17
+ import GmapVue, { components } from 'gmap-vue';
18
+ import geohash from 'ngeohash';
19
+
20
+ var setStreaming = Actions.setStreaming,
21
+ setQueryOptions = Actions.setQueryOptions,
22
+ updateQuery = Actions.updateQuery,
23
+ loadMore = Actions.loadMore,
24
+ setValue = Actions.setValue,
25
+ updateComponentProps = Actions.updateComponentProps,
26
+ setDefaultQuery = Actions.setDefaultQuery,
27
+ recordResultClick = Actions.recordResultClick,
28
+ setMapData = Actions.setMapData;
29
+ var isEqual = helper.isEqual,
30
+ getQueryOptions = helper.getQueryOptions,
31
+ getClassName = helper.getClassName,
32
+ parseHits = helper.parseHits,
33
+ getOptionsFromQuery = helper.getOptionsFromQuery,
34
+ getResultStats = helper.getResultStats; // default map center
35
+
36
+ var MAP_CENTER = {
37
+ lat: 37.7749,
38
+ lng: 122.4194
39
+ };
40
+ var style = {
41
+ width: '100%',
42
+ height: '100vh',
43
+ position: 'relative'
44
+ };
45
+
46
+ function getPrecision(a) {
47
+ if (isNaN(a)) return 0; // eslint-disable-line
48
+
49
+ var e = 1;
50
+ var p = 0;
51
+
52
+ while (Math.round(a * e) / e !== a) {
53
+ e *= 10;
54
+ p += 1;
55
+ }
56
+
57
+ return p;
58
+ }
59
+
60
+ function withDistinctLat(loc, count) {
61
+ var length = getPrecision(loc.lat);
62
+ var noiseFactor = length >= 6 ? 4 : length - 2; // eslint-disable-next-line
63
+
64
+ var suffix = 1 / Math.pow(10, noiseFactor) * count;
65
+
66
+ var location = _extends({}, loc, {
67
+ lat: parseFloat((loc.lat + suffix).toFixed(length))
68
+ });
69
+
70
+ return location;
71
+ }
72
+
73
+ function getLocationObject(location) {
74
+ var resultType = Array.isArray(location) ? 'array' : typeof location;
75
+
76
+ switch (resultType) {
77
+ case 'string':
78
+ {
79
+ if (location.indexOf(',') > -1) {
80
+ var locationSplit = location.split(',');
81
+ return {
82
+ lat: parseFloat(locationSplit[0]),
83
+ lng: parseFloat(locationSplit[1])
84
+ };
85
+ }
86
+
87
+ var locationDecode = geohash.decode(location);
88
+ return {
89
+ lat: locationDecode.latitude,
90
+ lng: locationDecode.longitude
91
+ };
92
+ }
93
+
94
+ case 'array':
95
+ {
96
+ return {
97
+ lat: location[1],
98
+ lng: location[0]
99
+ };
100
+ }
101
+
102
+ default:
103
+ {
104
+ return location;
105
+ }
106
+ }
107
+ }
108
+
109
+ var ReactiveMap = {
110
+ name: 'ReactiveMap',
111
+ props: {
112
+ className: types.string,
113
+ componentId: types.stringRequired,
114
+ dataField: types.stringRequired,
115
+ react: types.react,
116
+ size: types.number,
117
+ sortBy: types.sortBy,
118
+ URLParams: VueTypes.bool,
119
+ autoCenter: VueTypes.bool,
120
+ getMapRef: VueTypes.func.isRequired,
121
+ center: types.location,
122
+ defaultCenter: types.location,
123
+ defaultPin: types.string,
124
+ defaultZoom: VueTypes.number.def(13),
125
+ defaultQuery: types.func,
126
+ innerClass: types.style,
127
+ loader: types.title,
128
+ render: types.func,
129
+ renderItem: types.func,
130
+ renderError: types.title,
131
+ pages: VueTypes.number.def(5),
132
+ currentPage: VueTypes.number.def(0),
133
+ pagination: VueTypes.bool,
134
+ showMarkers: VueTypes.bool,
135
+ defaultSearchAsMove: VueTypes.bool,
136
+ showSearchAsMove: VueTypes.bool,
137
+ defaultRadius: types.number,
138
+ unit: types.string,
139
+ autoClosePopover: VueTypes.bool,
140
+ renderMap: VueTypes.func.isRequired,
141
+ renderPopover: VueTypes.func,
142
+ calculateMarkers: VueTypes.func,
143
+ searchAsMoveLabel: VueTypes.string.def('Search as I move the map')
144
+ },
145
+ preserveCenter: false,
146
+ data: function data() {
147
+ var props = this.$props;
148
+ var currentPageState = 0;
149
+
150
+ if (props.currentPage) {
151
+ currentPageState = Math.max(props.currentPage - 1, 0);
152
+ }
153
+
154
+ this.__state = {
155
+ from: currentPageState * props.size,
156
+ zoom: props.defaultZoom,
157
+ searchAsMove: props.defaultSearchAsMove,
158
+ currentPageState: currentPageState,
159
+ mapBoxBounds: null,
160
+ markersData: null
161
+ };
162
+ return this.__state;
163
+ },
164
+ computed: {
165
+ totalPages: function totalPages() {
166
+ return Math.ceil(this.total / this.$props.size) || 0;
167
+ },
168
+ stats: function stats() {
169
+ var _this$getAllData = this.getAllData(),
170
+ resultsToRender = _this$getAllData.resultsToRender;
171
+
172
+ return _extends({}, getResultStats(this), {
173
+ currentPage: this.currentPageState,
174
+ displayedResults: resultsToRender.length
175
+ });
176
+ },
177
+ hasCustomRender: function hasCustomRender() {
178
+ return hasCustomRenderer(this);
179
+ }
180
+ },
181
+ watch: {
182
+ defaultZoom: function defaultZoom(newVal) {
183
+ this.zoom = newVal;
184
+ },
185
+ currentPage: function currentPage(newVal, oldVal) {
186
+ if (oldVal !== newVal && newVal > 0 && newVal <= this.totalPages) {
187
+ this.setPage(newVal - 1);
188
+ }
189
+ },
190
+ defaultQuery: function defaultQuery(newVal, oldVal) {
191
+ if (!isQueryIdentical(newVal, oldVal, null, this.$props)) {
192
+ var options = getQueryOptions(this.$props);
193
+ options.from = 0;
194
+ this.$defaultQuery = newVal(null, this.$props);
195
+
196
+ var _ref = this.$defaultQuery || {},
197
+ sort = _ref.sort,
198
+ query = _ref.query;
199
+
200
+ if (sort) {
201
+ options.sort = this.$defaultQuery.sort;
202
+ }
203
+
204
+ var queryOptions = getOptionsFromQuery(this.$defaultQuery);
205
+
206
+ if (queryOptions) {
207
+ options = _extends({}, options, getOptionsFromQuery(this.$defaultQuery));
208
+ } // Update calculated default query in store
209
+
210
+
211
+ this.setQueryOptions(this.$props.componentId, options, false);
212
+ var persistMapQuery = true;
213
+ var forceExecute = true; // Update default query to include the geo bounding box query
214
+
215
+ this.setDefaultQueryForRSAPI();
216
+ var meta = {
217
+ mapBoxBounds: this.mapBoxBounds
218
+ };
219
+ this.setMapData(this.componentId, query, persistMapQuery, forceExecute, meta);
220
+ this.currentPageState = 0;
221
+ this.from = 0;
222
+ }
223
+ },
224
+ promotedResults: function promotedResults(newVal, oldVal) {
225
+ if (!isEqual(newVal, oldVal)) {
226
+ this.$emit('data', this.getData());
227
+ }
228
+ },
229
+ hidden: function hidden(newVal, oldVal) {
230
+ if (!isEqual(newVal, oldVal)) {
231
+ this.$emit('data', this.getData());
232
+ }
233
+ },
234
+ time: function time(newVal, oldVal) {
235
+ if (!isEqual(newVal, oldVal)) {
236
+ this.$emit('data', this.getData());
237
+ }
238
+ },
239
+ hits: function hits(newVal, oldVal) {
240
+ this.$emit('data', this.getData());
241
+
242
+ if (this.pagination) {
243
+ // called when page is changed
244
+ if (this.isLoading && (oldVal || newVal)) {
245
+ this.$emit('page-change', this.currentPageState + 1, this.totalPages);
246
+ }
247
+ }
248
+ },
249
+ rawData: function rawData(newVal, oldVal) {
250
+ var _this = this;
251
+
252
+ if (!isEqual(newVal, oldVal)) {
253
+ var promotedResults = this.promotedResults,
254
+ hits = this.hits;
255
+ var results = parseHits(hits) || [];
256
+ var parsedPromotedResults = parseHits(promotedResults) || [];
257
+ var filteredResults = results;
258
+
259
+ if (parsedPromotedResults.length) {
260
+ var ids = parsedPromotedResults.map(function (item) {
261
+ return item._id;
262
+ }).filter(Boolean);
263
+
264
+ if (ids) {
265
+ filteredResults = filteredResults.filter(function (item) {
266
+ return !ids.includes(item._id);
267
+ });
268
+ }
269
+
270
+ filteredResults = [].concat(parsedPromotedResults, filteredResults);
271
+ }
272
+
273
+ filteredResults = filteredResults.filter(function (item) {
274
+ return !!item[_this.dataField];
275
+ }).map(function (item) {
276
+ var _extends2;
277
+
278
+ return _extends({}, item, (_extends2 = {}, _extends2[_this.dataField] = getLocationObject(item[_this.dataField]), _extends2));
279
+ });
280
+ this.filteredResults = this.addNoise(filteredResults);
281
+
282
+ if (this.calculateMarkers) {
283
+ this.markersData = this.calculateMarkers({
284
+ data: this.filteredResults,
285
+ rawData: this.rawData
286
+ }) || [];
287
+ }
288
+
289
+ this.$emit('data', this.getData());
290
+ }
291
+ },
292
+ center: function center(newVal, oldVal) {
293
+ if (!isEqual(newVal, oldVal)) {
294
+ var persistMapQuery = !!this.center; // we need to forceExecute the query because the center has changed
295
+
296
+ var forceExecute = true;
297
+ var geoQuery = this.getGeoQuery(this.$props); // Update default query for RS API
298
+
299
+ this.setDefaultQueryForRSAPI();
300
+ var meta = {
301
+ mapBoxBounds: this.mapBoxBounds
302
+ };
303
+ this.setMapData(this.componentId, geoQuery, persistMapQuery, forceExecute, meta);
304
+ }
305
+ }
306
+ },
307
+ methods: {
308
+ parseLocation: function parseLocation(location) {
309
+ if (Array.isArray(location)) {
310
+ return {
311
+ lat: Number(location[0]),
312
+ lng: Number(location[1])
313
+ };
314
+ }
315
+
316
+ return {
317
+ lat: location ? Number(location.lat) : this.defaultCenter.lat,
318
+ lng: location ? Number(location.lon === undefined ? location.lng : location.lon) : this.defaultCenter.lng
319
+ };
320
+ },
321
+ getDefaultCenter: function getDefaultCenter() {
322
+ if (this.defaultCenter) return this.parseLocation(this.defaultCenter);
323
+ return this.parseLocation(MAP_CENTER);
324
+ },
325
+ addNoise: function addNoise(hits) {
326
+ var _this2 = this;
327
+
328
+ var hitMap = {};
329
+ var updatedHits = [];
330
+ hits.forEach(function (item) {
331
+ var updatedItem = _extends({}, item);
332
+
333
+ var location = _this2.parseLocation(item[_this2.dataField]);
334
+
335
+ var key = JSON.stringify(location);
336
+ var count = hitMap[key] || 0;
337
+ updatedItem[_this2.dataField] = count ? withDistinctLat(location, count) : location;
338
+ updatedHits = [].concat(updatedHits, [updatedItem]);
339
+ hitMap[key] = count + 1;
340
+ });
341
+ return updatedHits;
342
+ },
343
+ getPosition: function getPosition(result) {
344
+ if (result) {
345
+ return this.parseLocation(result[this.dataField]);
346
+ }
347
+
348
+ return null;
349
+ },
350
+ getHitsCenter: function getHitsCenter(hits) {
351
+ var _this3 = this;
352
+
353
+ var data = hits.map(function (hit) {
354
+ return hit[_this3.dataField];
355
+ });
356
+
357
+ if (data.length) {
358
+ var numCoords = data.length;
359
+ var X = 0.0;
360
+ var Y = 0.0;
361
+ var Z = 0.0;
362
+ data.forEach(function (location) {
363
+ if (location) {
364
+ var _lat = 0.0;
365
+ var _lng = 0.0;
366
+ var locationObj = getLocationObject(location);
367
+ _lat = locationObj.lat * Math.PI / 180;
368
+ _lng = (locationObj.lng !== undefined ? locationObj.lng : locationObj.lon) * Math.PI / 180;
369
+ var a = Math.cos(_lat) * Math.cos(_lng);
370
+ var b = Math.cos(_lat) * Math.sin(_lng);
371
+ var c = Math.sin(_lat);
372
+ X += a;
373
+ Y += b;
374
+ Z += c;
375
+ }
376
+ });
377
+ X /= numCoords;
378
+ Y /= numCoords;
379
+ Z /= numCoords;
380
+ var lng = Math.atan2(Y, X); // eslint-disable-next-line
381
+
382
+ var hyp = Math.sqrt(X * X + Y * Y);
383
+ var lat = Math.atan2(Z, hyp);
384
+ var newX = lat * 180 / Math.PI;
385
+ var newY = lng * 180 / Math.PI;
386
+ return {
387
+ lat: newX,
388
+ lng: newY
389
+ };
390
+ }
391
+
392
+ return false;
393
+ },
394
+ getCenter: function getCenter(hits) {
395
+ var _this4 = this;
396
+
397
+ if (this.center) {
398
+ return this.parseLocation(this.center);
399
+ }
400
+
401
+ var mapRef = this.getMapRef();
402
+
403
+ if (mapRef && typeof mapRef.getCenter === 'function' && this.$options.preserveCenter) {
404
+ var currentCenter = mapRef.getCenter();
405
+ setTimeout(function () {
406
+ _this4.$options.preserveCenter = false;
407
+ }, 100);
408
+ return this.parseLocation({
409
+ lat: currentCenter.lat(),
410
+ lng: currentCenter.lng()
411
+ });
412
+ }
413
+
414
+ if (hits && hits.length) {
415
+ if (this.autoCenter) {
416
+ return this.getHitsCenter(hits) || this.getDefaultCenter();
417
+ }
418
+
419
+ return hits[0] && hits[0][this.dataField] ? this.getPosition(hits[0]) : this.getDefaultCenter();
420
+ }
421
+
422
+ return this.getDefaultCenter();
423
+ },
424
+ handleZoomChange: function handleZoomChange(zoom) {
425
+ if (zoom) {
426
+ var prevZoom = this.zoom;
427
+
428
+ if (this.searchAsMove) {
429
+ this.zoom = zoom;
430
+ this.$options.preserveCenter = true;
431
+ this.setGeoQuery(true);
432
+ } else {
433
+ this.zoom = zoom;
434
+ }
435
+
436
+ if (prevZoom !== zoom) {
437
+ this.$emit('zoom-changed', zoom);
438
+ }
439
+ }
440
+ },
441
+ handleOnDragEnd: function handleOnDragEnd() {
442
+ if (this.searchAsMove) {
443
+ this.$options.preserveCenter = true;
444
+ this.setGeoQuery(true);
445
+ }
446
+
447
+ this.$emit('drag-end');
448
+ },
449
+ handlePreserveCenter: function handlePreserveCenter(preserveCenter) {
450
+ this.$options.preserveCenter = preserveCenter;
451
+ },
452
+ handleOnIdle: function handleOnIdle() {
453
+ // only make the geo_bounding query if we have hits data
454
+ if (this.hits && this.hits.length && this.searchAsMove) {
455
+ // always execute geo-bounds query when center is set
456
+ // to improve the specificity of search results
457
+ var executeUpdate = !!this.center;
458
+ this.setGeoQuery(executeUpdate);
459
+ }
460
+
461
+ this.$emit('idle');
462
+ },
463
+ setGeoQuery: function setGeoQuery(executeUpdate) {
464
+ if (executeUpdate === void 0) {
465
+ executeUpdate = false;
466
+ }
467
+
468
+ // execute a new query on the initial mount
469
+ // or whenever searchAsMove is true and the map is dragged
470
+ if (executeUpdate || !this.skipBoundingBox && !this.mapBoxBounds) {
471
+ this.$defaultQuery = this.getGeoQuery();
472
+ var persistMapQuery = !!this.center;
473
+ var forceExecute = this.searchAsMove;
474
+ var meta = {
475
+ mapBoxBounds: this.mapBoxBounds
476
+ };
477
+ this.setMapData(this.componentId, this.$defaultQuery, persistMapQuery, forceExecute, meta);
478
+ }
479
+
480
+ this.skipBoundingBox = false;
481
+ },
482
+ getMapParams: function getMapParams() {
483
+ var _this$getData = this.getData(),
484
+ data = _this$getData.data;
485
+
486
+ var showMarkers = this.showMarkers,
487
+ defaultPin = this.defaultPin,
488
+ renderPopover = this.renderPopover,
489
+ autoClosePopover = this.autoClosePopover,
490
+ renderItem = this.renderItem;
491
+ return {
492
+ resultsToRender: data,
493
+ center: this.getCenter(data),
494
+ getPosition: this.getPosition,
495
+ zoom: this.zoom,
496
+ renderItem: renderItem,
497
+ showMarkers: showMarkers,
498
+ defaultPin: defaultPin,
499
+ renderPopover: renderPopover,
500
+ autoClosePopover: autoClosePopover,
501
+ renderSearchAsMove: this.renderSearchAsMove,
502
+ handlePreserveCenter: this.handlePreserveCenter,
503
+ preserveCenter: this.$options.preserveCenter,
504
+ handleOnDragEnd: this.handleOnDragEnd,
505
+ handleOnIdle: this.handleOnIdle,
506
+ handleZoomChange: this.handleZoomChange
507
+ };
508
+ },
509
+ getAllData: function getAllData() {
510
+ var size = this.size,
511
+ promotedResults = this.promotedResults,
512
+ customData = this.customData,
513
+ currentPage = this.currentPage,
514
+ hits = this.hits;
515
+ var results = parseHits(hits) || [];
516
+ var parsedPromotedResults = parseHits(promotedResults) || [];
517
+ var base = currentPage * size;
518
+ var resultsToRender = this.filteredResults || [];
519
+
520
+ if (this.markersData) {
521
+ resultsToRender = this.markersData;
522
+ }
523
+
524
+ return {
525
+ results: results,
526
+ resultsToRender: resultsToRender,
527
+ customData: customData || {},
528
+ promotedResults: parsedPromotedResults,
529
+ loadMore: this.loadMore,
530
+ base: base,
531
+ triggerClickAnalytics: this.triggerClickAnalytics
532
+ };
533
+ },
534
+ getData: function getData() {
535
+ var _this$getAllData2 = this.getAllData(),
536
+ promotedResults = _this$getAllData2.promotedResults,
537
+ aggregationData = _this$getAllData2.aggregationData,
538
+ customData = _this$getAllData2.customData,
539
+ resultsToRender = _this$getAllData2.resultsToRender;
540
+
541
+ return {
542
+ data: this.withClickIds(resultsToRender),
543
+ aggregationData: this.withClickIds(aggregationData || []),
544
+ promotedData: this.withClickIds(promotedResults),
545
+ rawData: this.rawData,
546
+ resultStats: this.stats,
547
+ customData: customData
548
+ };
549
+ },
550
+ getComponent: function getComponent$1() {
551
+ var error = this.error,
552
+ isLoading = this.isLoading;
553
+
554
+ var data = _extends({
555
+ error: error,
556
+ loading: isLoading,
557
+ loadMore: this.loadMore,
558
+ triggerClickAnalytics: this.triggerClickAnalytics,
559
+ setPage: this.setPage
560
+ }, this.getData());
561
+
562
+ return getComponent(data, this);
563
+ },
564
+ setPage: function setPage(page) {
565
+ // pageClick will be called every time a pagination button is clicked
566
+ if (page !== this.currentPageState) {
567
+ this.$emit('pageClick', page + 1);
568
+ this.$emit('page-click', page + 1);
569
+ var value = this.size * page;
570
+ var options = getQueryOptions(this.$props);
571
+ options.from = this.$data.from;
572
+ this.from = value;
573
+ this.currentPageState = page;
574
+ this.loadMoreAction(this.componentId, _extends({}, options, {
575
+ from: value
576
+ }), false);
577
+
578
+ if (this.URLParams) {
579
+ this.setPageURL(this.componentId, page + 1, this.componentId, false, true);
580
+ }
581
+ }
582
+ },
583
+ setDefaultQueryForRSAPI: function setDefaultQueryForRSAPI() {
584
+ if (this.defaultQuery && typeof this.defaultQuery === 'function') {
585
+ var defaultQuery = this.defaultQuery();
586
+ this.setDefaultQuery(this.componentId, defaultQuery);
587
+ }
588
+ },
589
+ getArrPosition: function getArrPosition(location) {
590
+ return {
591
+ lat: location.lat,
592
+ lon: location.lon || location.lng
593
+ };
594
+ },
595
+ getGeoQuery: function getGeoQuery(props) {
596
+ if (props === void 0) {
597
+ props = this.$props;
598
+ }
599
+
600
+ this.$defaultQuery = props.defaultQuery ? props.defaultQuery() : null;
601
+ var mapRef = this.getMapRef();
602
+ var mapBounds = mapRef && typeof mapRef.getBounds === 'function' ? mapRef.getBounds() : false;
603
+ var north;
604
+ var south;
605
+ var east;
606
+ var west;
607
+
608
+ if (mapBounds) {
609
+ var _geo_bounding_box;
610
+
611
+ north = mapBounds.getNorthEast().lat();
612
+ south = mapBounds.getSouthWest().lat();
613
+ east = mapBounds.getNorthEast().lng();
614
+ west = mapBounds.getSouthWest().lng();
615
+ var boundingBoxCoordinates = {
616
+ top_left: [west, north],
617
+ bottom_right: [east, south]
618
+ };
619
+ this.mapBoxBounds = boundingBoxCoordinates;
620
+ var geoQuery = {
621
+ geo_bounding_box: (_geo_bounding_box = {}, _geo_bounding_box[this.dataField] = boundingBoxCoordinates, _geo_bounding_box)
622
+ };
623
+
624
+ if (this.$defaultQuery) {
625
+ var query = this.$defaultQuery.query;
626
+
627
+ if (query) {
628
+ // adds defaultQuery's query to geo-query
629
+ // to generate a map query
630
+ return {
631
+ must: [geoQuery, query]
632
+ };
633
+ }
634
+ }
635
+
636
+ return geoQuery;
637
+ } // return the defaultQuery (if set) or null when map query not available
638
+
639
+
640
+ return this.$defaultQuery ? this.$defaultQuery.query : null;
641
+ },
642
+ getGeoDistanceQuery: function getGeoDistanceQuery() {
643
+ var center = this.center || this.defaultCenter;
644
+
645
+ if (center && this.defaultRadius) {
646
+ var _geo_distance;
647
+
648
+ // skips geo bounding box query on initial load
649
+ this.skipBoundingBox = true;
650
+ return {
651
+ geo_distance: (_geo_distance = {
652
+ distance: "" + this.defaultRadius + this.unit
653
+ }, _geo_distance[this.dataField] = this.getArrPosition(center), _geo_distance)
654
+ };
655
+ }
656
+
657
+ return null;
658
+ },
659
+ loadMore: function loadMore() {
660
+ if (this.hits && !this.pagination && this.total !== this.hits.length) {
661
+ var value = this.from + this.size;
662
+ var options = getQueryOptions(this.$props);
663
+ this.from = value;
664
+ this.loadMoreAction(this.componentId, _extends({}, options, {
665
+ from: value
666
+ }), true);
667
+ }
668
+ },
669
+ triggerClickAnalytics: function triggerClickAnalytics(searchPosition, documentId) {
670
+ var docId = documentId;
671
+
672
+ if (!docId) {
673
+ var _this$getData2 = this.getData(),
674
+ data = _this$getData2.data;
675
+
676
+ var hitData = data.find(function (hit) {
677
+ return hit._click_id === searchPosition;
678
+ });
679
+
680
+ if (hitData && hitData._id) {
681
+ docId = hitData._id;
682
+ }
683
+ }
684
+
685
+ this.recordResultClick(searchPosition, docId);
686
+ },
687
+ withClickIds: function withClickIds(results) {
688
+ var _this$getAllData3 = this.getAllData(),
689
+ base = _this$getAllData3.base;
690
+
691
+ return results.map(function (result, index) {
692
+ return _extends({}, result, {
693
+ _click_id: base + index
694
+ });
695
+ });
696
+ },
697
+ toggleSearchAsMove: function toggleSearchAsMove() {
698
+ this.searchAsMove = !this.searchAsMove;
699
+ this.$emit('search-as-move', this.searchAsMove);
700
+ },
701
+ renderErrorComponent: function renderErrorComponent() {
702
+ var renderError = this.$scopedSlots.renderError || this.$props.renderError;
703
+
704
+ if (renderError && this.error && !this.isLoading) {
705
+ return isFunction(renderError) ? renderError(this.error) : renderError;
706
+ }
707
+
708
+ return null;
709
+ },
710
+ renderSearchAsMove: function renderSearchAsMove() {
711
+ var h = this.$createElement;
712
+
713
+ if (this.showSearchAsMove) {
714
+ return h("div", {
715
+ "style": {
716
+ position: 'absolute',
717
+ bottom: '30px',
718
+ left: '10px',
719
+ width: '240px',
720
+ backgroundColor: '#fff',
721
+ padding: '8px 10px',
722
+ boxShadow: 'rgba(0,0,0,0.3) 0px 1px 4px -1px',
723
+ borderRadius: 2,
724
+ zIndex: 10000
725
+ },
726
+ "attrs": {
727
+ "className": getClassName(this.innerClass, 'checkboxContainer') || null
728
+ }
729
+ }, [h(Checkbox, {
730
+ "attrs": {
731
+ "type": "checkbox",
732
+ "id": this.$props.componentId + "-searchasmove",
733
+ "checked": this.searchAsMove,
734
+ "show": true
735
+ },
736
+ "class": getClassName(this.$props.innerClass, 'checkbox'),
737
+ "on": {
738
+ "click": this.toggleSearchAsMove
739
+ }
740
+ }), h("label", {
741
+ "attrs": {
742
+ "className": getClassName(this.innerClass, 'label') || null,
743
+ "for": this.$props.componentId + "-searchasmove"
744
+ }
745
+ }, [this.searchAsMoveLabel])]);
746
+ }
747
+
748
+ return null;
749
+ },
750
+ renderPagination: function renderPagination() {
751
+ var h = this.$createElement;
752
+ return h(Pagination, {
753
+ "attrs": {
754
+ "pages": this.pages,
755
+ "totalPages": this.totalPages,
756
+ "currentPage": this.currentPageState,
757
+ "setPage": this.setPage,
758
+ "innerClass": this.innerClass
759
+ }
760
+ });
761
+ }
762
+ },
763
+ created: function created() {
764
+ if (this.defaultPage >= 0) {
765
+ this.currentPageState = this.defaultPage;
766
+ this.from = this.currentPageState * this.$props.size;
767
+ }
768
+
769
+ this.internalComponent = this.$props.componentId + "__internal";
770
+ this.updateComponentProps(this.componentId, {
771
+ from: this.from
772
+ }, componentTypes.reactiveMap);
773
+ this.updateComponentProps(this.internalComponent, {
774
+ from: this.from
775
+ }, componentTypes.reactiveMap);
776
+ },
777
+ mounted: function mounted() {
778
+ if (this.defaultPage < 0 && this.currentPage > 0) {
779
+ if (this.$props.URLParams) {
780
+ this.setPageURL(this.$props.componentId, this.currentPage, this.$props.componentId, false, true);
781
+ }
782
+ }
783
+
784
+ var options = getQueryOptions(this.$props);
785
+ options.from = this.$data.from;
786
+
787
+ if (this.$props.sortBy) {
788
+ var _ref2;
789
+
790
+ options.sort = [(_ref2 = {}, _ref2[this.$props.dataField] = {
791
+ order: this.$props.sortBy
792
+ }, _ref2)];
793
+ }
794
+
795
+ this.$defaultQuery = null;
796
+
797
+ if (this.$props.defaultQuery) {
798
+ this.$defaultQuery = this.$props.defaultQuery();
799
+ options = _extends({}, options, getOptionsFromQuery(this.$defaultQuery)); // Override sort query with defaultQuery's sort if defined
800
+
801
+ if (this.$defaultQuery.sort) {
802
+ options.sort = this.$defaultQuery.sort;
803
+ } // since we want defaultQuery to be executed anytime
804
+ // map component's query is being executed
805
+
806
+
807
+ var persistMapQuery = true; // no need to forceExecute because setReact() will capture the main query
808
+ // and execute the defaultQuery along with it
809
+
810
+ var forceExecute = false; // Update default query for RS API
811
+
812
+ this.setDefaultQueryForRSAPI();
813
+ var meta = {
814
+ mapBoxBounds: this.mapBoxBounds
815
+ };
816
+ this.setMapData(this.componentId, this.$defaultQuery.query, persistMapQuery, forceExecute, meta);
817
+ } else {
818
+ // only apply geo-distance when defaultQuery prop is not set
819
+ var query = this.getGeoDistanceQuery();
820
+
821
+ if (query) {
822
+ // - only persist the map query if center prop is set
823
+ // - ideally, persist the map query if you want to keep executing it
824
+ // whenever there is a change (due to subscription) in the component query
825
+ var _persistMapQuery = !!this.center; // - forceExecute will make sure that the component query + Map query gets executed
826
+ // irrespective of the changes in the component query
827
+ // - forceExecute will only come into play when searchAsMove is true
828
+ // - kindly note that forceExecute may result in one additional network request
829
+ // since it bypasses the gatekeeping
830
+
831
+
832
+ var _forceExecute = this.searchAsMove; // Set meta for `distance` and `coordinates` in selected value
833
+
834
+ var center = this.center || this.defaultCenter;
835
+ var coordinatesObject = this.getArrPosition(center);
836
+ var _meta = {
837
+ distance: this.defaultRadius,
838
+ coordinates: coordinatesObject.lat + ", " + coordinatesObject.lon
839
+ };
840
+ this.setMapData(this.componentId, query, _persistMapQuery, _forceExecute, _meta);
841
+ }
842
+ }
843
+
844
+ this.setQueryOptions(this.componentId, options, !(this.$defaultQuery && this.$defaultQuery.query));
845
+ },
846
+ render: function render() {
847
+ var h = arguments[0];
848
+ var loader = this.$scopedSlots.loader || this.$props.loader;
849
+ return h("div", {
850
+ "style": _extends({}, style, this.$props.style),
851
+ "class": this.$props.className
852
+ }, [this.renderErrorComponent(), this.isLoading && loader, this.hasCustomRender ? this.getComponent() : null, this.renderMap(this.getMapParams()), this.pagination ? this.renderPagination() : null]);
853
+ }
854
+ };
855
+
856
+ var mapStateToProps = function mapStateToProps(state, props) {
857
+ return {
858
+ defaultPage: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value - 1 || -1,
859
+ error: state.error[props.componentId],
860
+ isLoading: state.isLoading[props.componentId],
861
+ hits: state.hits[props.componentId] && state.hits[props.componentId].hits,
862
+ promotedResults: state.promotedResults[props.componentId],
863
+ customData: state.customData[props.componentId],
864
+ total: state.hits[props.componentId] && state.hits[props.componentId].total,
865
+ time: state.hits[props.componentId] && state.hits[props.componentId].time,
866
+ rawData: state.rawData[props.componentId],
867
+ hidden: state.hits[props.componentId] && state.hits[props.componentId].hidden
868
+ };
869
+ };
870
+
871
+ var mapDispatchToProps = {
872
+ loadMoreAction: loadMore,
873
+ setPageURL: setValue,
874
+ setQueryOptions: setQueryOptions,
875
+ setStreaming: setStreaming,
876
+ updateQuery: updateQuery,
877
+ updateComponentProps: updateComponentProps,
878
+ setDefaultQuery: setDefaultQuery,
879
+ recordResultClick: recordResultClick,
880
+ setMapData: setMapData
881
+ };
882
+ var RMConnected = ComponentWrapper(connect(mapStateToProps, mapDispatchToProps)(ReactiveMap), {
883
+ componentType: componentTypes.reactiveMap,
884
+ internalComponent: true
885
+ });
886
+
887
+ ReactiveMap.install = function (Vue) {
888
+ Vue.component(ReactiveMap.name, RMConnected);
889
+ }; // Add componentType for SSR
890
+
891
+
892
+ ReactiveMap.componentType = componentTypes.reactiveMap;
893
+
894
+ var infoWindowMappedProps = {
895
+ content: {
896
+ type: Object,
897
+ twoWay: true
898
+ },
899
+ options: {
900
+ type: Object,
901
+ required: false,
902
+ "default": function _default() {
903
+ return {};
904
+ }
905
+ },
906
+ position: {
907
+ type: Object,
908
+ twoWay: true
909
+ },
910
+ zIndex: {
911
+ type: Number,
912
+ twoWay: true
913
+ }
914
+ };
915
+ /**
916
+ * This function helps you to bind events from Google Maps API to Vue events
917
+ *
918
+ * @param {Object} vueInst the Vue instance
919
+ * @param {Object} googleMapsInst the Google Maps instance
920
+ * @param {string[]} events an array of string with all events that you want to bind
921
+ * @returns {void}
922
+ */
923
+
924
+ function bindEvents(vueInst, googleMapsInst, events) {
925
+ events.forEach(function (eventName) {
926
+ if (vueInst.$gmapOptions.autoBindAllEvents || vueInst.$listeners[eventName]) {
927
+ googleMapsInst.addListener(eventName, function (ev) {
928
+ vueInst.$emit(eventName, ev);
929
+ });
930
+ }
931
+ });
932
+ }
933
+ /**
934
+ * Function that helps you to capitalize the first letter on a word
935
+ *
936
+ * @param {string} text the text that you want to capitalize
937
+ * @returns {string}
938
+ */
939
+
940
+ function capitalizeFirstLetter(text) {
941
+ return text.charAt(0).toUpperCase() + text.slice(1);
942
+ }
943
+ /**
944
+ * Function that helps you to get all non nullable props from a component
945
+ *
946
+ * @param {Object} vueInst the Vue component instance
947
+ * @param {Object} props the props object
948
+ * @returns {Object}
949
+ */
950
+
951
+ function getPropsValues(vueInst, props) {
952
+ return Object.keys(props).reduce(function (acc, prop) {
953
+ if (vueInst[prop] !== undefined) {
954
+ acc[prop] = vueInst[prop];
955
+ }
956
+
957
+ return acc;
958
+ }, {});
959
+ }
960
+ /**
961
+ * Watch the individual properties of a PoD object, instead of the object
962
+ * per se. This is different from a deep watch where both the reference
963
+ * and the individual values are watched.
964
+ *
965
+ * In effect, it throttles the multiple $watch to execute at most once per tick.
966
+ *
967
+ * @param {Object} vueInst the component instance
968
+ * @param {string[]} propertiesToTrack string array with all properties that you want to track
969
+ * @param {Function} handler function to be fired when the prop change
970
+ * @param {boolean} immediate=false
971
+ * @returns {void}
972
+ */
973
+
974
+ function watchPrimitiveProperties(vueInst, propertiesToTrack, handler, immediate) {
975
+ if (immediate === void 0) {
976
+ immediate = false;
977
+ }
978
+
979
+ var isHandled = false;
980
+ /**
981
+ * Function in charge to execute the handler function if it was not fired
982
+ *
983
+ * @returns void
984
+ */
985
+
986
+ function requestHandle() {
987
+ if (!isHandled) {
988
+ isHandled = true;
989
+ vueInst.$nextTick(function () {
990
+ isHandled = false;
991
+ handler();
992
+ });
993
+ }
994
+ }
995
+
996
+ propertiesToTrack.forEach(function (prop) {
997
+ vueInst.$watch(prop, requestHandle, {
998
+ immediate: immediate
999
+ });
1000
+ });
1001
+ }
1002
+ /**
1003
+ * Binds the properties defined in props to the google maps instance.
1004
+ * If the prop is an Object type, and we wish to track the properties
1005
+ * of the object (e.g. the lat and lng of a LatLng), then we do a deep
1006
+ * watch. For deep watch, we also prevent the _changed event from being
1007
+ * emitted if the data source was external.
1008
+ *
1009
+ * @param {Object} vueInst the component instance
1010
+ * @param {Object} googleMapsInst the Google Maps instance
1011
+ * @param {Object} props object with the component props tha should be synched with the Google Maps instances props
1012
+ * @returns {void}
1013
+ */
1014
+
1015
+ function bindProps(vueInst, googleMapsInst, props) {
1016
+ Object.keys(props).forEach(function (attribute) {
1017
+ var _props$attribute = props[attribute],
1018
+ twoWay = _props$attribute.twoWay,
1019
+ type = _props$attribute.type,
1020
+ trackProperties = _props$attribute.trackProperties,
1021
+ noBind = _props$attribute.noBind;
1022
+
1023
+ if (!noBind) {
1024
+ var setMethodName = "set" + capitalizeFirstLetter(attribute);
1025
+ var getMethodName = "get" + capitalizeFirstLetter(attribute);
1026
+ var eventName = attribute.toLowerCase() + "_changed";
1027
+ var initialValue = vueInst[attribute];
1028
+
1029
+ if (typeof googleMapsInst[setMethodName] === 'undefined') {
1030
+ throw new Error( // TODO: Analyze all disabled rules in the file
1031
+ // eslint-disable-next-line no-underscore-dangle -- old code should be analyzed
1032
+ setMethodName + " is not a method of (the Maps object corresponding to) " + vueInst.$options._componentTag);
1033
+ } // We need to avoid an endless
1034
+ // propChanged -> event emitted -> propChanged -> event emitted loop
1035
+ // although this may really be the user's responsibility
1036
+
1037
+
1038
+ if (type !== Object || !trackProperties) {
1039
+ // Track the object deeply
1040
+ vueInst.$watch(attribute, function () {
1041
+ var attributeValue = vueInst[attribute];
1042
+ googleMapsInst[setMethodName](attributeValue);
1043
+ }, {
1044
+ immediate: typeof initialValue !== 'undefined',
1045
+ deep: type === Object
1046
+ });
1047
+ } else {
1048
+ watchPrimitiveProperties(vueInst, trackProperties.map(function (prop) {
1049
+ return attribute + "." + prop;
1050
+ }), function () {
1051
+ googleMapsInst[setMethodName](vueInst[attribute]);
1052
+ }, vueInst[attribute] !== undefined);
1053
+ }
1054
+
1055
+ if (twoWay && (vueInst.$gmapOptions.autoBindAllEvents || vueInst.$listeners[eventName])) {
1056
+ googleMapsInst.addListener(eventName, function () {
1057
+ vueInst.$emit(eventName, googleMapsInst[getMethodName]());
1058
+ });
1059
+ }
1060
+ }
1061
+ });
1062
+ }
1063
+
1064
+ var _excluded = ["options", "position"];
1065
+ var InfoWindowClusterManager = {
1066
+ name: 'InfoWindowClusterManager',
1067
+ inject: {
1068
+ $markerPromise: {
1069
+ "default": null
1070
+ },
1071
+ $mapPromise: {}
1072
+ },
1073
+ provide: function provide() {
1074
+ var _this = this;
1075
+
1076
+ var events = ['domready', 'closeclick', 'content_changed']; // Infowindow needs this to be immediately available
1077
+
1078
+ var promise = this.$mapPromise.then(function (map) {
1079
+ _this.$map = map; // Initialize the maps with the given options
1080
+
1081
+ var initialOptions = _extends({}, _this.options, {
1082
+ map: map
1083
+ }, getPropsValues(_this, infoWindowMappedProps));
1084
+
1085
+ var extraOptions = initialOptions.options,
1086
+ position = initialOptions.position,
1087
+ finalOptions = _objectWithoutPropertiesLoose(initialOptions, _excluded);
1088
+
1089
+ finalOptions.content = _this.$refs.flyaway;
1090
+
1091
+ if (_this.$markerPromise) {
1092
+ _this.$markerPromise.then(function (markerObject) {
1093
+ _this.$markerObject = markerObject; // eslint-disable-next-line
1094
+
1095
+ _this.$infoWindowObject = new google.maps.InfoWindow(finalOptions);
1096
+ bindProps(_this, _this.$infoWindowObject, infoWindowMappedProps);
1097
+ bindEvents(_this, _this.$infoWindowObject, events); // TODO: This function names should be analyzed
1098
+
1099
+ /* eslint-disable no-underscore-dangle -- old style */
1100
+
1101
+ _this._openInfoWindow();
1102
+
1103
+ _this.$watch('opened', function () {
1104
+ _this._openInfoWindow();
1105
+ });
1106
+ /* eslint-enable no-underscore-dangle */
1107
+
1108
+
1109
+ return _this.$infoWindowObject;
1110
+ });
1111
+ }
1112
+ })["catch"](function (error) {
1113
+ throw error;
1114
+ }); // TODO: analyze the efects of only returns the instance and remove completely the promise
1115
+
1116
+ this.$infoWindowPromise = promise;
1117
+ return {
1118
+ $infoWindowPromise: promise
1119
+ };
1120
+ },
1121
+ props: {
1122
+ /**
1123
+ * NOTE: This prop overrides the content of the default slot, use only one of them, not both at the same time
1124
+ * Content to display in the InfoWindow. This can be an HTML element, a plain-text string, or a string containing HTML. The InfoWindow will be sized according to the content. To set an explicit size for the content, set content to be a HTML element with that size.
1125
+ * @value undefined
1126
+ * @see [InfoWindow content](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.content)
1127
+ */
1128
+ content: {
1129
+ type: [String, Object],
1130
+ "default": undefined
1131
+ },
1132
+
1133
+ /**
1134
+ * Determines if the info-window is open or not
1135
+ */
1136
+ opened: {
1137
+ type: Boolean,
1138
+ "default": true
1139
+ },
1140
+
1141
+ /**
1142
+ * Contains the LatLng at which this info window is anchored.
1143
+ * Note: An InfoWindow may be attached either to a Marker object
1144
+ * (in which case its position is based on the marker's location)
1145
+ * or on the map itself at a specified LatLng.
1146
+ *
1147
+ * The LatLng at which to display this InfoWindow. If the InfoWindow is opened with an anchor, the anchor's position will be used instead.
1148
+ * @value undefined
1149
+ * @type LatLng|LatLngLiteral
1150
+ * @see [InfoWindow position](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.position)
1151
+ */
1152
+ position: {
1153
+ type: Object,
1154
+ "default": undefined
1155
+ },
1156
+
1157
+ /**
1158
+ * All InfoWindows are displayed on the map in order of their zIndex, with higher values displaying in front of InfoWindows with lower values. By default, InfoWindows are displayed according to their latitude, with InfoWindows of lower latitudes appearing in front of InfoWindows at higher latitudes. InfoWindows are always displayed in front of markers.
1159
+ * @value 0
1160
+ * @see [InfoWindow position](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindowOptions.zIndex)
1161
+ */
1162
+ zIndex: {
1163
+ type: Number,
1164
+ "default": 0
1165
+ },
1166
+
1167
+ /**
1168
+ * Extra options that you want to pass to the component
1169
+ */
1170
+ options: {
1171
+ type: Object,
1172
+ required: false,
1173
+ "default": undefined
1174
+ }
1175
+ },
1176
+ mounted: function mounted() {
1177
+ var el = this.$refs.flyaway;
1178
+ el.parentNode.removeChild(el);
1179
+ },
1180
+ destroyed: function destroyed() {
1181
+ // Note: not all Google Maps components support maps
1182
+ if (this.$infoWindowObject && this.$infoWindowObject.setMap) {
1183
+ this.$infoWindowObject.setMap(null);
1184
+ }
1185
+ },
1186
+ methods: {
1187
+ // TODO: we need to analyze the following method name
1188
+ // eslint-disable-next-line no-underscore-dangle -- old code
1189
+ _openInfoWindow: function _openInfoWindow() {
1190
+ if (this.opened) {
1191
+ if (this.$markerObject !== null) {
1192
+ this.$infoWindowObject.open(this.$map, this.$markerObject);
1193
+ } else {
1194
+ this.$infoWindowObject.open(this.$map);
1195
+ }
1196
+ } else {
1197
+ this.$infoWindowObject.close();
1198
+ }
1199
+ }
1200
+ },
1201
+ render: function render() {
1202
+ var h = arguments[0];
1203
+ return h("div", [h("div", {
1204
+ "ref": "flyaway"
1205
+ }, [this.$scopedSlots["default"]()])]);
1206
+ }
1207
+ };
1208
+
1209
+ var InfoWindowWrapper = {
1210
+ name: 'InfoWindowWrapperClusterManager',
1211
+ props: {
1212
+ id: VueTypes.string,
1213
+ renderPopover: VueTypes.func,
1214
+ infoWindowProps: VueTypes.object,
1215
+ events: VueTypes.object,
1216
+ marker: VueTypes.Object
1217
+ },
1218
+ data: function data() {
1219
+ return {
1220
+ infoWindowRef: null
1221
+ };
1222
+ },
1223
+ provide: function provide() {
1224
+ return {
1225
+ $markerPromise: Promise.resolve(this.marker)
1226
+ };
1227
+ },
1228
+ mounted: function mounted() {
1229
+ this.infoWindowRef = this.$refs[this.id + "-Info-Window"];
1230
+ },
1231
+ methods: {
1232
+ handleClose: function handleClose() {
1233
+ this.infoWindowRef.$infoWindowObject.close();
1234
+ }
1235
+ },
1236
+ render: function render() {
1237
+ var h = arguments[0];
1238
+ var renderPopover = this.renderPopover,
1239
+ events = this.events;
1240
+ return h(InfoWindowClusterManager, {
1241
+ "ref": this.id + "-Info-Window",
1242
+ "props": _extends({}, this.infoWindowProps),
1243
+ "on": _extends({}, events)
1244
+ }, [h("div", [renderPopover(this.handleClose)])]);
1245
+ }
1246
+ };
1247
+
1248
+ var _excluded$1 = ["options"];
1249
+ var isEqual$1 = helper.isEqual;
1250
+ var recordResultClick$1 = Actions.recordResultClick;
1251
+ var ClusterMarkers = {
1252
+ name: 'ClusterMarkers',
1253
+ props: {
1254
+ markers: VueTypes.array,
1255
+ getPosition: VueTypes.func,
1256
+ defaultPin: VueTypes.string,
1257
+ renderItem: VueTypes.func,
1258
+ markerProps: VueTypes.object,
1259
+ handlePreserveCenter: VueTypes.func.isRequired,
1260
+ autoClosePopover: VueTypes.bool,
1261
+ renderPopover: VueTypes.func,
1262
+ highlightMarkerOnHover: VueTypes.bool
1263
+ },
1264
+ inject: {
1265
+ $clusterPromise: {
1266
+ "default": null
1267
+ },
1268
+ $mapPromise: {}
1269
+ },
1270
+ data: function data() {
1271
+ return {
1272
+ openMarkers: {}
1273
+ };
1274
+ },
1275
+ mounted: function mounted() {
1276
+ this.buildMarkers(this.markers);
1277
+ },
1278
+ destroy: function destroy() {
1279
+ // Remove active markers
1280
+ this.buildMarkers([]);
1281
+ },
1282
+ watch: {
1283
+ markers: function markers(newVal, oldVal) {
1284
+ if (!isEqual$1(oldVal, newVal)) {
1285
+ this.buildMarkers(newVal);
1286
+ }
1287
+ }
1288
+ },
1289
+ methods: {
1290
+ triggerAnalytics: function triggerAnalytics(clickPosition, markerId) {
1291
+ this.recordResultClick(clickPosition, markerId);
1292
+ },
1293
+ setOpenMarkers: function setOpenMarkers(openMarkers) {
1294
+ this.openMarkers = openMarkers;
1295
+ },
1296
+ closeMarker: function closeMarker(marker) {
1297
+ var _this$$props = this.$props,
1298
+ autoClosePopover = _this$$props.autoClosePopover,
1299
+ handlePreserveCenter = _this$$props.handlePreserveCenter;
1300
+ var id = marker.metaData && marker.metaData._id;
1301
+
1302
+ var _this$openMarkers = this.openMarkers,
1303
+ del = _this$openMarkers[id],
1304
+ activeMarkers = _objectWithoutPropertiesLoose(_this$openMarkers, [id].map(_toPropertyKey));
1305
+
1306
+ var newOpenMarkers = autoClosePopover ? {} : activeMarkers;
1307
+ this.setOpenMarkers(newOpenMarkers);
1308
+ handlePreserveCenter(true);
1309
+ this.$emit('close-marker-popover', marker);
1310
+ },
1311
+ openMarker: function openMarker(marker, index) {
1312
+ var _ref, _extends2;
1313
+
1314
+ var autoClosePopover = this.autoClosePopover,
1315
+ handlePreserveCenter = this.handlePreserveCenter;
1316
+ var id = marker.metaData && marker.metaData._id;
1317
+ var newOpenMarkers = autoClosePopover ? (_ref = {}, _ref[id] = marker, _ref) : _extends({}, this.openMarkers, (_extends2 = {}, _extends2[id] = marker, _extends2));
1318
+ this.setOpenMarkers(newOpenMarkers);
1319
+ handlePreserveCenter(true);
1320
+ this.triggerAnalytics(id, index);
1321
+ this.$emit('open-marker-popover', marker.metaData);
1322
+ },
1323
+ buildMarkers: function buildMarkers(markersToRender) {
1324
+ var _this = this;
1325
+
1326
+ this.$mapPromise.then(function (map) {
1327
+ if (_this.$clusterPromise) {
1328
+ _this.$clusterPromise.then(function (clusterObject) {
1329
+ // Detect changed markers
1330
+ var markersToAdd = [];
1331
+ var markersToRemove = []; // A map of marker id to active status, `true` means marker is active
1332
+ // `false` means marker is stale and should be removed
1333
+
1334
+ var oldMarkersIdMap = {};
1335
+ (_this.$markers || []).forEach(function (marker) {
1336
+ if (marker.metaData && marker.metaData._id) {
1337
+ // mark all old markers as stale
1338
+ oldMarkersIdMap[marker.metaData._id] = false;
1339
+ }
1340
+ }); // build map markers
1341
+
1342
+ markersToRender.forEach(function (marker, index) {
1343
+ // Avoid if a marker is already rendered
1344
+ if (marker._id && oldMarkersIdMap[marker._id] !== undefined) {
1345
+ // Set old marker as active
1346
+ oldMarkersIdMap[marker._id] = true;
1347
+ } else {
1348
+ // Initialize the maps with the given options
1349
+ var initialOptions = _extends({}, _this.markerProps, {
1350
+ metaData: marker,
1351
+ map: map,
1352
+ position: _this.getPosition(marker)
1353
+ });
1354
+
1355
+ if (_this.renderItem) {
1356
+ var data = _this.renderItem(marker);
1357
+
1358
+ if ('label' in data) {
1359
+ initialOptions.label = data.label;
1360
+ }
1361
+
1362
+ if ('icon' in data) {
1363
+ initialOptions.icon = data.icon;
1364
+ }
1365
+ } else if (_this.defaultPin) {
1366
+ initialOptions.icon = {
1367
+ url: _this.defaultPin
1368
+ };
1369
+ }
1370
+
1371
+ var extraOptions = initialOptions.options,
1372
+ finalOptions = _objectWithoutPropertiesLoose(initialOptions, _excluded$1);
1373
+
1374
+ if (_this.$clusterPromise) {
1375
+ finalOptions.map = null;
1376
+ } // eslint-disable-next-line
1377
+
1378
+
1379
+ var markerObject = new google.maps.Marker(finalOptions);
1380
+ markerObject.addListener('click', function () {
1381
+ _this.openMarker(markerObject, index);
1382
+ });
1383
+ markersToAdd.push(markerObject);
1384
+ }
1385
+ }); // Current active markers
1386
+
1387
+ var currentMarkers = [];
1388
+ markersToAdd.forEach(function (marker) {
1389
+ currentMarkers.push(marker);
1390
+ });
1391
+ (_this.$markers || []).forEach(function (marker) {
1392
+ if (marker.metaData && marker.metaData._id) {
1393
+ // if maker is not active then add to remove list
1394
+ if (!oldMarkersIdMap[marker.metaData._id]) {
1395
+ markersToRemove.push(marker);
1396
+ } else {
1397
+ currentMarkers.push(marker);
1398
+ }
1399
+ }
1400
+ }); // Remove old markers
1401
+
1402
+ clusterObject.removeMarkers(markersToRemove); // Add inital markers at once
1403
+
1404
+ clusterObject.addMarkers(markersToAdd);
1405
+ _this.$clusterObject = clusterObject;
1406
+ _this.$map = map;
1407
+ _this.$markers = currentMarkers;
1408
+ });
1409
+ }
1410
+ })["catch"](function (error) {
1411
+ throw error;
1412
+ });
1413
+ }
1414
+ },
1415
+ render: function render() {
1416
+ var _this2 = this;
1417
+
1418
+ var h = arguments[0];
1419
+
1420
+ if (!this.renderPopover) {
1421
+ return null;
1422
+ }
1423
+
1424
+ return h("div", [Object.keys(this.openMarkers).map(function (markerId) {
1425
+ var marker = _this2.openMarkers[markerId];
1426
+ var item = marker.metaData;
1427
+ return h(InfoWindowWrapper, {
1428
+ "key": markerId + "-InfoWindow",
1429
+ "attrs": {
1430
+ "id": markerId,
1431
+ "renderPopover": function renderPopover(_handleClose) {
1432
+ return _this2.renderPopover({
1433
+ item: item,
1434
+ handleClose: function handleClose() {
1435
+ _handleClose();
1436
+
1437
+ _this2.closeMarker(item);
1438
+ }
1439
+ });
1440
+ },
1441
+ "marker": marker,
1442
+ "infoWindowProps": {
1443
+ zIndex: 500
1444
+ },
1445
+ "events": {
1446
+ closeclick: function closeclick() {
1447
+ return _this2.closeMarker(marker);
1448
+ }
1449
+ }
1450
+ }
1451
+ });
1452
+ })]);
1453
+ }
1454
+ };
1455
+ var mapDispatchToProps$1 = {
1456
+ recordResultClick: recordResultClick$1
1457
+ };
1458
+ var ClusterManager = connect(function () {
1459
+ return null;
1460
+ }, mapDispatchToProps$1)(ClusterMarkers);
1461
+
1462
+ var InfoWindow = components.InfoWindow;
1463
+ var InfoWindowWrapper$1 = {
1464
+ name: 'InfoWindowWrapper',
1465
+ props: {
1466
+ id: VueTypes.string,
1467
+ renderPopover: VueTypes.func,
1468
+ infoWindowProps: VueTypes.object,
1469
+ events: VueTypes.object
1470
+ },
1471
+ data: function data() {
1472
+ return {
1473
+ infoWindowRef: null
1474
+ };
1475
+ },
1476
+ mounted: function mounted() {
1477
+ this.infoWindowRef = this.$refs[this.id + "-Info-Window"];
1478
+ },
1479
+ methods: {
1480
+ handleClose: function handleClose() {
1481
+ this.infoWindowRef.$infoWindowObject.close();
1482
+ }
1483
+ },
1484
+ render: function render() {
1485
+ var h = arguments[0];
1486
+ var renderPopover = this.renderPopover,
1487
+ events = this.events;
1488
+ return h(InfoWindow, {
1489
+ "ref": this.id + "-Info-Window",
1490
+ "props": _extends({}, this.infoWindowProps),
1491
+ "on": _extends({}, events)
1492
+ }, [h("div", [renderPopover(this.handleClose)])]);
1493
+ }
1494
+ };
1495
+
1496
+ var MapElementMixin = components.MapElementMixin; // Note: This file has been taken from https://github.com/eregnier/vue2-gmap-custom-marker/blob/master/gmap-custom-marker.vue
1497
+
1498
+ var MarkerWithLabel = {
1499
+ name: 'MarkerWithLabel',
1500
+ props: {
1501
+ metaData: {
1502
+ type: Object,
1503
+ "default": undefined
1504
+ },
1505
+ marker: {
1506
+ type: Object,
1507
+ "default": undefined
1508
+ },
1509
+ offsetX: {
1510
+ type: Number,
1511
+ "default": 0
1512
+ },
1513
+ offsetY: {
1514
+ type: Number,
1515
+ "default": 0
1516
+ },
1517
+ alignment: {
1518
+ type: String,
1519
+ "default": 'top'
1520
+ },
1521
+ zIndex: {
1522
+ type: Number,
1523
+ "default": 50
1524
+ },
1525
+ cssPosition: {
1526
+ type: Boolean,
1527
+ "default": false
1528
+ },
1529
+ renderMarker: VueTypes.func.isRequired,
1530
+ handleMouseOver: VueTypes.func,
1531
+ handleFocus: VueTypes.func,
1532
+ handleMouseOut: VueTypes.func,
1533
+ handleBlur: VueTypes.func,
1534
+ handleClick: VueTypes.func
1535
+ },
1536
+ data: function data() {
1537
+ return {
1538
+ opacity: 0.01
1539
+ };
1540
+ },
1541
+ mixins: [MapElementMixin],
1542
+ inject: {
1543
+ $clusterPromise: {
1544
+ "default": null
1545
+ }
1546
+ },
1547
+ computed: {
1548
+ lat: function lat() {
1549
+ return parseFloat(Number.isNaN(this.marker.lat) ? this.marker.latitude : this.marker.lat);
1550
+ },
1551
+ lng: function lng() {
1552
+ return parseFloat(Number.isNaN(this.marker.lng) ? this.marker.longitude : this.marker.lng);
1553
+ },
1554
+ latLng: function latLng() {
1555
+ if (this.marker instanceof window.google.maps.LatLng) {
1556
+ return this.marker;
1557
+ }
1558
+
1559
+ return new window.google.maps.LatLng(this.lat, this.lng);
1560
+ }
1561
+ },
1562
+ watch: {
1563
+ marker: function marker() {
1564
+ var _this = this;
1565
+
1566
+ this.$mapPromise.then(function () {
1567
+ return _this.$overlay.setPosition();
1568
+ });
1569
+ },
1570
+ zIndex: function zIndex() {
1571
+ if (this.$overlay) {
1572
+ this.$overlay.repaint();
1573
+ }
1574
+ }
1575
+ },
1576
+ beforeCreate: function beforeCreate(options) {
1577
+ if (this.$clusterPromise) {
1578
+ // eslint-disable-next-line
1579
+ options.map = null;
1580
+ }
1581
+
1582
+ return this.$clusterPromise;
1583
+ },
1584
+ destroyed: function destroyed() {
1585
+ if (this.$clusterObject) {
1586
+ this.$clusterObject.removeMarker(this.$overlay, true);
1587
+ } else if (this.$overlay) {
1588
+ this.$overlay.setMap(null);
1589
+ this.$overlay = undefined;
1590
+ }
1591
+ },
1592
+ provide: function provide() {
1593
+ var _this2 = this;
1594
+
1595
+ var self = this;
1596
+ return this.$mapPromise.then(function (map) {
1597
+ var Overlay = /*#__PURE__*/function (_window$google$maps$O) {
1598
+ _inheritsLoose(Overlay, _window$google$maps$O);
1599
+
1600
+ function Overlay(map2) {
1601
+ var _this3;
1602
+
1603
+ _this3 = _window$google$maps$O.call(this) || this;
1604
+ _this3.metaData = self.metaData;
1605
+
1606
+ _this3.setMap(map2);
1607
+
1608
+ _this3.draw = function () {
1609
+ return _this3.repaint();
1610
+ };
1611
+
1612
+ _this3.setPosition = function () {
1613
+ return _this3.repaint();
1614
+ };
1615
+
1616
+ _this3.getVisible = function () {
1617
+ return true;
1618
+ };
1619
+
1620
+ return _this3;
1621
+ }
1622
+
1623
+ var _proto = Overlay.prototype;
1624
+
1625
+ _proto.repaint = function repaint() {
1626
+ var div = self.$el;
1627
+ var projection = this.getProjection();
1628
+
1629
+ if (projection && div) {
1630
+ var posPixel = projection.fromLatLngToDivPixel(self.latLng);
1631
+ var x;
1632
+ var y;
1633
+
1634
+ switch (self.alignment) {
1635
+ case 'top':
1636
+ x = posPixel.x - div.offsetWidth / 2;
1637
+ y = posPixel.y - div.offsetHeight;
1638
+ break;
1639
+
1640
+ case 'bottom':
1641
+ x = posPixel.x - div.offsetWidth / 2;
1642
+ y = posPixel.y;
1643
+ break;
1644
+
1645
+ case 'left':
1646
+ x = posPixel.x - div.offsetWidth;
1647
+ y = posPixel.y - div.offsetHeight / 2;
1648
+ break;
1649
+
1650
+ case 'right':
1651
+ x = posPixel.x;
1652
+ y = posPixel.y - div.offsetHeight / 2;
1653
+ break;
1654
+
1655
+ case 'center':
1656
+ x = posPixel.x - div.offsetWidth / 2;
1657
+ y = posPixel.y - div.offsetHeight / 2;
1658
+ break;
1659
+
1660
+ case 'topleft':
1661
+ case 'lefttop':
1662
+ x = posPixel.x - div.offsetWidth;
1663
+ y = posPixel.y - div.offsetHeight;
1664
+ break;
1665
+
1666
+ case 'topright':
1667
+ case 'righttop':
1668
+ x = posPixel.x;
1669
+ y = posPixel.y - div.offsetHeight;
1670
+ break;
1671
+
1672
+ case 'bottomleft':
1673
+ case 'leftop':
1674
+ x = posPixel.x - div.offsetWidth;
1675
+ y = posPixel.y;
1676
+ break;
1677
+
1678
+ case 'bottomright':
1679
+ case 'rightbottom':
1680
+ x = posPixel.x;
1681
+ y = posPixel.y;
1682
+ break;
1683
+
1684
+ default:
1685
+ throw new Error('Invalid alignment type of custom marker!');
1686
+ }
1687
+
1688
+ if (self.cssPosition) {
1689
+ div.style.transform = "translate(" + (x + self.offsetX) + "px, " + (y + self.offsetY) + "px)";
1690
+ } else {
1691
+ div.style.left = x + self.offsetX + "px";
1692
+ div.style.top = y + self.offsetY + "px";
1693
+ }
1694
+
1695
+ div.style['z-index'] = self.zIndex;
1696
+ }
1697
+ };
1698
+
1699
+ _proto.onAdd = function onAdd() {
1700
+ if (this.$clusterObject) {
1701
+ this.$clusterObject.removeMarker(this.$overlay, true);
1702
+ } else if (this.$overlay) {
1703
+ this.$overlay.setMap(null);
1704
+ this.$overlay = undefined;
1705
+ }
1706
+
1707
+ var div = self.$el;
1708
+ var panes = this.getPanes();
1709
+ div.style.position = 'absolute';
1710
+ div.style.display = 'inline-block';
1711
+ div.style.zIndex = self.zIndex;
1712
+ panes.overlayLayer.appendChild(div);
1713
+ panes.overlayMouseTarget.appendChild(div);
1714
+
1715
+ this.getDraggable = function () {
1716
+ return false;
1717
+ };
1718
+
1719
+ this.getPosition = function () {
1720
+ return new window.google.maps.LatLng(self.lat, self.lng);
1721
+ };
1722
+
1723
+ self.afterCreate(this);
1724
+ } // eslint-disable-next-line
1725
+ ;
1726
+
1727
+ _proto.onRemove = function onRemove() {
1728
+ if (self.$el) {
1729
+ var ua = window.navigator.userAgent;
1730
+ var msie = ua.indexOf('MSIE '); // eslint-disable-next-line
1731
+
1732
+ if (msie > 0 || !!ua.match(/Trident.*rv\:11\./)) {
1733
+ self.$el.parentNode.removeChild(self.$el);
1734
+ } else {
1735
+ self.$el.remove();
1736
+ }
1737
+ }
1738
+ };
1739
+
1740
+ return Overlay;
1741
+ }(window.google.maps.OverlayView);
1742
+
1743
+ _this2.$overlay = new Overlay(map);
1744
+ setTimeout(function () {
1745
+ if (_this2.$overlay) {
1746
+ _this2.$overlay.repaint();
1747
+
1748
+ _this2.opacity = 1;
1749
+ }
1750
+ }, 100);
1751
+ });
1752
+ },
1753
+ methods: {
1754
+ afterCreate: function afterCreate(inst) {
1755
+ var _this4 = this;
1756
+
1757
+ if (this.$clusterPromise && !this.isMarkerAdded) {
1758
+ this.$clusterPromise.then(function (co) {
1759
+ co.addMarker(inst);
1760
+ _this4.$clusterObject = co;
1761
+ _this4.isMarkerAdded = true;
1762
+ });
1763
+ }
1764
+ }
1765
+ },
1766
+ render: function render() {
1767
+ var h = arguments[0];
1768
+ return h("div", {
1769
+ "style": {
1770
+ opacity: this.opacity
1771
+ },
1772
+ "on": {
1773
+ "mouseover": this.handleMouseOver,
1774
+ "mouseout": this.handleMouseOut,
1775
+ "click": this.handleClick
1776
+ }
1777
+ }, [this.renderMarker()]);
1778
+ }
1779
+ };
1780
+
1781
+ var _templateObject, _templateObject2, _templateObject3;
1782
+ var MapPin = styled('div')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n\theight: 24px;\n\twidth: auto;\n\tbackground-color: #fff;\n\tborder-radius: 2px;\n\tcolor: #222;\n\tbox-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.15);\n\tpadding: 3px 6px;\n\tfont-size: 15px;\n"])));
1783
+ var MapPinArrow = styled('div')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n\tborder-color: rgba(0, 0, 0, 0.2);\n\tborder-style: solid;\n\tborder-width: 0 1px 1px 0;\n\tmargin-left: -6px;\n\tbackground-color: #fff;\n\tmargin-top: -6px;\n\twidth: 12px;\n\theight: 12px;\n\t-webkit-transform: rotate(45deg);\n\t-ms-transform: rotate(45deg);\n\ttransform: rotate(45deg);\n"])));
1784
+ var mapPinWrapper = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n\t&:hover,\n\t&:focus {\n\t\tz-index: 200;\n\t}\n"])));
1785
+
1786
+ var Marker = components.Marker;
1787
+ var recordResultClick$2 = Actions.recordResultClick;
1788
+ var GoogleMapMarker = {
1789
+ name: 'GoogleMapMarker',
1790
+ props: {
1791
+ index: VueTypes.number,
1792
+ marker: VueTypes.object.isRequired,
1793
+ getPosition: VueTypes.func.isRequired,
1794
+ defaultPin: VueTypes.string,
1795
+ renderItem: VueTypes.func,
1796
+ setOpenMarkers: VueTypes.func.isRequired,
1797
+ handlePreserveCenter: VueTypes.func.isRequired,
1798
+ autoClosePopover: VueTypes.bool,
1799
+ openMarkers: VueTypes.object,
1800
+ renderPopover: VueTypes.func,
1801
+ highlightMarkerOnHover: VueTypes.bool
1802
+ },
1803
+ data: function data() {
1804
+ return {
1805
+ zIndex: 0,
1806
+ markerIcon: null
1807
+ };
1808
+ },
1809
+ methods: {
1810
+ increaseMarkerZIndex: function increaseMarkerZIndex() {
1811
+ var handlePreserveCenter = this.$props.handlePreserveCenter;
1812
+
1813
+ if (this.highlightMarkerOnHover) {
1814
+ this.zIndex += 1;
1815
+ }
1816
+
1817
+ handlePreserveCenter(true);
1818
+ },
1819
+ removeMarkerZIndex: function removeMarkerZIndex() {
1820
+ var handlePreserveCenter = this.$props.handlePreserveCenter;
1821
+
1822
+ if (this.highlightMarkerOnHover) {
1823
+ this.zIndex -= 1;
1824
+ }
1825
+
1826
+ handlePreserveCenter(true);
1827
+ },
1828
+ openMarker: function openMarker() {
1829
+ var _ref, _extends2;
1830
+
1831
+ var _this$$props = this.$props,
1832
+ handleOpenMarkers = _this$$props.setOpenMarkers,
1833
+ openMarkers = _this$$props.openMarkers,
1834
+ marker = _this$$props.marker,
1835
+ autoClosePopover = _this$$props.autoClosePopover,
1836
+ handlePreserveCenter = _this$$props.handlePreserveCenter;
1837
+ var id = marker._id;
1838
+ var newOpenMarkers = autoClosePopover ? (_ref = {}, _ref[id] = true, _ref) : _extends({}, openMarkers, (_extends2 = {}, _extends2[id] = true, _extends2));
1839
+ handleOpenMarkers(newOpenMarkers);
1840
+ handlePreserveCenter(true);
1841
+ this.triggerAnalytics();
1842
+ this.$emit('open-marker-popover', marker);
1843
+ },
1844
+ closeMarker: function closeMarker() {
1845
+ var _this$$props2 = this.$props,
1846
+ handleOpenMarkers = _this$$props2.setOpenMarkers,
1847
+ marker = _this$$props2.marker,
1848
+ autoClosePopover = _this$$props2.autoClosePopover,
1849
+ handlePreserveCenter = _this$$props2.handlePreserveCenter,
1850
+ openMarkers = _this$$props2.openMarkers;
1851
+ var id = marker._id;
1852
+
1853
+ var del = openMarkers[id],
1854
+ activeMarkers = _objectWithoutPropertiesLoose(openMarkers, [id].map(_toPropertyKey));
1855
+
1856
+ var newOpenMarkers = autoClosePopover ? {} : activeMarkers;
1857
+ handleOpenMarkers(newOpenMarkers);
1858
+ handlePreserveCenter(true);
1859
+ this.$emit('close-marker-popover', marker);
1860
+ },
1861
+ triggerAnalytics: function triggerAnalytics() {
1862
+ this.recordResultClick(this.index, this.marker._id);
1863
+ },
1864
+ renderPopoverClick: function renderPopoverClick(item, includeExternalSettings) {
1865
+ var _this = this;
1866
+
1867
+ if (includeExternalSettings === void 0) {
1868
+ includeExternalSettings = false;
1869
+ }
1870
+
1871
+ var h = this.$createElement;
1872
+ var additionalProps = {};
1873
+ var _this$$props3 = this.$props,
1874
+ getPosition = _this$$props3.getPosition,
1875
+ _renderPopover = _this$$props3.renderPopover,
1876
+ openMarkers = _this$$props3.openMarkers;
1877
+
1878
+ if (includeExternalSettings) {
1879
+ // to render pop-over correctly with MarkerWithLabel
1880
+ additionalProps = {
1881
+ position: getPosition(item),
1882
+ defaultOptions: {
1883
+ pixelOffset: new window.google.maps.Size(0, -30)
1884
+ }
1885
+ };
1886
+ }
1887
+
1888
+ if (item._id in openMarkers) {
1889
+ return h(InfoWindowWrapper$1, {
1890
+ "key": item._id + "-InfoWindow",
1891
+ "attrs": {
1892
+ "id": item._id,
1893
+ "renderPopover": function renderPopover(_handleClose) {
1894
+ return _renderPopover({
1895
+ item: item,
1896
+ handleClose: function handleClose() {
1897
+ _handleClose();
1898
+
1899
+ _this.closeMarker();
1900
+ }
1901
+ });
1902
+ },
1903
+ "infoWindowProps": {
1904
+ zIndex: 500,
1905
+ position: additionalProps.position,
1906
+ options: additionalProps.defaultOptions
1907
+ },
1908
+ "events": {
1909
+ closeclick: function closeclick() {
1910
+ return _this.closeMarker();
1911
+ }
1912
+ }
1913
+ }
1914
+ });
1915
+ }
1916
+
1917
+ return null;
1918
+ }
1919
+ },
1920
+ render: function render() {
1921
+ var _this2 = this;
1922
+
1923
+ var h = arguments[0];
1924
+ var _this$$props4 = this.$props,
1925
+ getPosition = _this$$props4.getPosition,
1926
+ renderItem = _this$$props4.renderItem,
1927
+ defaultPin = _this$$props4.defaultPin,
1928
+ renderPopover = _this$$props4.renderPopover,
1929
+ customMarkerProps = _this$$props4.markerProps,
1930
+ marker = _this$$props4.marker;
1931
+ var markerProps = {};
1932
+
1933
+ if (this.zIndex) {
1934
+ markerProps.zIndex = window.google.maps.Marker.MAX_ZINDEX + this.zIndex;
1935
+ }
1936
+
1937
+ if (renderItem) {
1938
+ marker.setIcon = function (icon) {
1939
+ _this2.markerIcon = icon;
1940
+ };
1941
+
1942
+ var data = renderItem(marker);
1943
+
1944
+ if ('label' in data) {
1945
+ return h(MarkerWithLabel, {
1946
+ "key": marker._id,
1947
+ "attrs": {
1948
+ "metaData": marker,
1949
+ "marker": getPosition(marker),
1950
+ "labelAnchor": new window.google.maps.Point(0, 30),
1951
+ "handleMouseOver": this.increaseMarkerZIndex,
1952
+ "handleMouseOut": this.removeMarkerZIndex,
1953
+ "handleClick": this.openMarker,
1954
+ "zIndex": markerProps.zIndex,
1955
+ "renderMarker": function renderMarker() {
1956
+ return h("div", {
1957
+ "attrs": {
1958
+ "css": mapPinWrapper
1959
+ }
1960
+ }, [h(MapPin, [data.label]), h(MapPinArrow), renderPopover ? _this2.renderPopoverClick(marker, true) : null]);
1961
+ }
1962
+ },
1963
+ "props": _extends({}, customMarkerProps)
1964
+ });
1965
+ }
1966
+
1967
+ if ('icon' in data) {
1968
+ markerProps.icon = data.icon;
1969
+ } else {
1970
+ return h(MarkerWithLabel, {
1971
+ "key": marker._id,
1972
+ "attrs": {
1973
+ "metaData": marker,
1974
+ "marker": getPosition(marker),
1975
+ "handleClick": this.openMarker,
1976
+ "handleMouseOver": this.increaseMarkerZIndex,
1977
+ "handleMouseOut": this.removeMarkerZIndex,
1978
+ "zIndex": markerProps.zIndex,
1979
+ "renderMarker": function renderMarker() {
1980
+ return h("div", {
1981
+ "attrs": {
1982
+ "css": mapPinWrapper
1983
+ }
1984
+ }, [typeof data.custom === 'function' ? data.custom(marker) : data.custom, renderPopover ? _this2.renderPopoverClick(marker, true) : null]);
1985
+ }
1986
+ },
1987
+ "props": _extends({}, customMarkerProps)
1988
+ });
1989
+ }
1990
+ } else if (defaultPin) {
1991
+ markerProps.icon = {
1992
+ url: defaultPin
1993
+ };
1994
+ }
1995
+
1996
+ return h(Marker, {
1997
+ "key": marker._id,
1998
+ "attrs": {
1999
+ "zIndex": markerProps.zIndex,
2000
+ "position": getPosition(marker),
2001
+ "options": {
2002
+ metaData: marker
2003
+ },
2004
+ "icon": this.markerIcon || markerProps.icon
2005
+ },
2006
+ "on": {
2007
+ "click": function click() {
2008
+ return _this2.openMarker();
2009
+ },
2010
+ "mouseover": this.increaseMarkerZIndex,
2011
+ "mouseout": this.removeMarkerZIndex
2012
+ },
2013
+ "props": _extends({}, customMarkerProps)
2014
+ }, [renderPopover ? this.renderPopoverClick(marker) : null]);
2015
+ }
2016
+ };
2017
+ var mapDispatchToProps$2 = {
2018
+ recordResultClick: recordResultClick$2
2019
+ };
2020
+ var GoogleMapMarker$1 = connect(function () {
2021
+ return null;
2022
+ }, mapDispatchToProps$2)(GoogleMapMarker);
2023
+
2024
+ var Cluster = components.Cluster;
2025
+ var GoogleMapMarkers = {
2026
+ name: 'GoogleMapMarkers',
2027
+ props: {
2028
+ resultsToRender: VueTypes.array,
2029
+ getPosition: VueTypes.func,
2030
+ renderItem: VueTypes.func,
2031
+ renderClusterPopover: VueTypes.func,
2032
+ defaultPin: VueTypes.string,
2033
+ autoClosePopover: VueTypes.bool,
2034
+ handlePreserveCenter: VueTypes.func,
2035
+ renderPopover: VueTypes.func,
2036
+ markerProps: VueTypes.object,
2037
+ clusterProps: VueTypes.object,
2038
+ showMarkerClusters: VueTypes.bool,
2039
+ highlightMarkerOnHover: VueTypes.bool
2040
+ },
2041
+ data: function data() {
2042
+ return {
2043
+ openMarkers: {},
2044
+ clickedCluster: null,
2045
+ clusterMarkers: []
2046
+ };
2047
+ },
2048
+ methods: {
2049
+ setOpenMarkers: function setOpenMarkers(openMarkers) {
2050
+ this.openMarkers = openMarkers;
2051
+ },
2052
+ getAdditionalProps: function getAdditionalProps() {
2053
+ return {
2054
+ position: {
2055
+ lat: this.clickedCluster.getCenter().lat(),
2056
+ lng: this.clickedCluster.getCenter().lng()
2057
+ },
2058
+ defaultOptions: {
2059
+ pixelOffset: new window.google.maps.Size(0, -30)
2060
+ }
2061
+ };
2062
+ },
2063
+ closeMarker: function closeMarker() {
2064
+ this.clickedCluster = null;
2065
+ this.clusterMarkers = [];
2066
+ this.$emit('close-cluster-popover');
2067
+ }
2068
+ },
2069
+ render: function render() {
2070
+ var _this = this;
2071
+
2072
+ var h = arguments[0];
2073
+ var resultsToRender = this.$props.resultsToRender;
2074
+ var openMarkers = this.openMarkers;
2075
+ var markerProps = {
2076
+ openMarkers: openMarkers,
2077
+ setMarkerOnTop: this.setMarkerOnTop,
2078
+ setOpenMarkers: this.setOpenMarkers,
2079
+ getPosition: this.getPosition,
2080
+ renderItem: this.renderItem,
2081
+ defaultPin: this.defaultPin,
2082
+ autoClosePopover: this.autoClosePopover,
2083
+ handlePreserveCenter: this.handlePreserveCenter,
2084
+ renderPopover: this.renderPopover,
2085
+ markerProps: this.markerProps,
2086
+ showMarkerClusters: this.showMarkerClusters,
2087
+ highlightMarkerOnHover: this.highlightMarkerOnHover
2088
+ };
2089
+
2090
+ if (this.showMarkerClusters) {
2091
+ return h("div", [h(Cluster, {
2092
+ "props": _extends({}, this.clusterProps),
2093
+ "on": {
2094
+ "click": function click(cluster) {
2095
+ var markers = cluster.markers.map(function (i) {
2096
+ return i.metaData;
2097
+ });
2098
+ _this.clickedCluster = cluster;
2099
+ _this.clusterMarkers = markers;
2100
+
2101
+ _this.$emit('open-cluster-popover', _this.clusterMarkers);
2102
+ }
2103
+ },
2104
+ "ref": "clusterRef"
2105
+ }, [h(ClusterManager, {
2106
+ "attrs": {
2107
+ "getPosition": markerProps.getPosition,
2108
+ "markers": resultsToRender,
2109
+ "defaultPin": markerProps.defaultPin,
2110
+ "renderItem": markerProps.renderItem,
2111
+ "markerProps": markerProps.markerProps,
2112
+ "handlePreserveCenter": markerProps.handlePreserveCenter,
2113
+ "autoClosePopover": markerProps.autoClosePopover,
2114
+ "renderPopover": markerProps.renderPopover,
2115
+ "highlightMarkerOnHover": markerProps.highlightMarkerOnHover
2116
+ },
2117
+ "on": _extends({}, this.$listeners)
2118
+ })]), this.clickedCluster && this.renderClusterPopover ? h(InfoWindowWrapper$1, {
2119
+ "attrs": {
2120
+ "id": "cluster",
2121
+ "infoWindowProps": {
2122
+ zIndex: 500,
2123
+ position: this.getAdditionalProps().position,
2124
+ options: this.getAdditionalProps().defaultOptions
2125
+ },
2126
+ "renderPopover": function renderPopover(_handleClose) {
2127
+ return _this.renderClusterPopover({
2128
+ markers: _this.clusterMarkers,
2129
+ cluster: _this.clickedCluster,
2130
+ handleClose: function handleClose() {
2131
+ _handleClose();
2132
+
2133
+ _this.closeMarker();
2134
+ }
2135
+ });
2136
+ },
2137
+ "events": {
2138
+ closeclick: this.closeMarker
2139
+ }
2140
+ }
2141
+ }) : null]);
2142
+ }
2143
+
2144
+ return h("div", [resultsToRender.map(function (marker, index) {
2145
+ return h(GoogleMapMarker$1, {
2146
+ "attrs": {
2147
+ "index": index,
2148
+ "marker": marker
2149
+ },
2150
+ "props": _extends({}, markerProps),
2151
+ "on": _extends({}, _this.$listeners)
2152
+ });
2153
+ })]);
2154
+ }
2155
+ };
2156
+
2157
+ var Map = components.MapLayer;
2158
+ var ReactiveGoogleMap = {
2159
+ name: 'ReactiveGoogleMap',
2160
+ props: {
2161
+ className: types.string,
2162
+ componentId: types.stringRequired,
2163
+ dataField: types.stringRequired,
2164
+ defaultQuery: VueTypes.func,
2165
+ loader: types.title,
2166
+ defaultZoom: VueTypes.number.def(13),
2167
+ react: types.react,
2168
+ size: types.number,
2169
+ sortBy: types.sortBy,
2170
+ URLParams: VueTypes.bool,
2171
+ mapProps: VueTypes.object,
2172
+ showMarkers: VueTypes.bool.def(true),
2173
+ showMarkerClusters: VueTypes.bool.def(false),
2174
+ searchAsMove: VueTypes.bool.def(false),
2175
+ searchAsMoveLabel: VueTypes.string,
2176
+ markerProps: VueTypes.object,
2177
+ clusterProps: VueTypes.object,
2178
+ renderItem: VueTypes.func,
2179
+ showSearchAsMove: VueTypes.bool.def(true),
2180
+ autoClosePopover: VueTypes.bool,
2181
+ pagination: VueTypes.bool,
2182
+ defaultPin: VueTypes.string,
2183
+ autoCenter: VueTypes.bool,
2184
+ defaultCenter: types.location,
2185
+ center: types.location,
2186
+ defaultRadius: types.number,
2187
+ unit: types.string,
2188
+ pages: VueTypes.number.def(5),
2189
+ calculateMarkers: VueTypes.func,
2190
+ highlightMarkerOnHover: VueTypes.bool.def(true)
2191
+ },
2192
+ methods: {
2193
+ renderMap: function renderMap(_ref) {
2194
+ var _this = this;
2195
+
2196
+ var resultsToRender = _ref.resultsToRender,
2197
+ center = _ref.center,
2198
+ zoom = _ref.zoom,
2199
+ handleZoomChange = _ref.handleZoomChange,
2200
+ handleOnDragEnd = _ref.handleOnDragEnd,
2201
+ handleOnIdle = _ref.handleOnIdle,
2202
+ renderSearchAsMove = _ref.renderSearchAsMove,
2203
+ handlePreserveCenter = _ref.handlePreserveCenter,
2204
+ getPosition = _ref.getPosition,
2205
+ autoClosePopover = _ref.autoClosePopover,
2206
+ defaultPin = _ref.defaultPin;
2207
+ var h = this.$createElement;
2208
+ var style = {
2209
+ width: '100%',
2210
+ height: '100%',
2211
+ position: 'relative'
2212
+ };
2213
+ return h("div", {
2214
+ "style": style
2215
+ }, [h(Map, {
2216
+ "ref": "mapRef",
2217
+ "attrs": {
2218
+ "map-type-id": "terrain",
2219
+ "options": {
2220
+ zoomControl: true
2221
+ },
2222
+ "center": center,
2223
+ "zoom": zoom
2224
+ },
2225
+ "style": {
2226
+ height: '100%'
2227
+ },
2228
+ "props": _extends({}, this.mapProps),
2229
+ "on": {
2230
+ "zoom_changed": handleZoomChange,
2231
+ "dragend": handleOnDragEnd,
2232
+ "idle": handleOnIdle
2233
+ }
2234
+ }, [this.showMarkers ? h(GoogleMapMarkers, {
2235
+ "attrs": {
2236
+ "resultsToRender": resultsToRender,
2237
+ "getPosition": getPosition,
2238
+ "markerProps": this.markerProps,
2239
+ "clusterProps": this.clusterProps,
2240
+ "handlePreserveCenter": handlePreserveCenter,
2241
+ "highlightMarkerOnHover": this.highlightMarkerOnHover,
2242
+ "renderItem": this.$scopedSlots.renderItem ? function () {
2243
+ return {
2244
+ custom: _this.$scopedSlots.renderItem
2245
+ };
2246
+ } : this.renderItem,
2247
+ "defaultPin": defaultPin,
2248
+ "autoClosePopover": autoClosePopover,
2249
+ "renderPopover": this.$scopedSlots.renderPopover,
2250
+ "renderClusterPopover": this.$scopedSlots.renderClusterPopover,
2251
+ "showMarkerClusters": this.showMarkerClusters
2252
+ },
2253
+ "on": _extends({}, this.$listeners)
2254
+ }) : null]), renderSearchAsMove()]);
2255
+ },
2256
+ getMapRef: function getMapRef() {
2257
+ return this.mapRef;
2258
+ }
2259
+ },
2260
+ mounted: function mounted() {
2261
+ var _this2 = this;
2262
+
2263
+ if (this.$refs.mapRef) {
2264
+ this.$refs.mapRef.$mapPromise.then(function (map) {
2265
+ _this2.mapRef = map;
2266
+ });
2267
+ }
2268
+ },
2269
+ render: function render() {
2270
+ var h = arguments[0];
2271
+ return h(RMConnected, _mergeJSXProps([{
2272
+ "attrs": {
2273
+ "getMapRef": this.getMapRef,
2274
+ "renderMap": this.renderMap,
2275
+ "componentId": this.componentId,
2276
+ "className": this.className,
2277
+ "dataField": this.dataField,
2278
+ "defaultZoom": this.defaultZoom,
2279
+ "react": this.react,
2280
+ "size": this.size,
2281
+ "sortBy": this.sortBy,
2282
+ "pagination": this.pagination,
2283
+ "uRLParams": this.URLParams,
2284
+ "defaultSearchAsMove": this.searchAsMove,
2285
+ "showSearchAsMove": this.showSearchAsMove,
2286
+ "searchAsMoveLabel": this.searchAsMoveLabel,
2287
+ "showMarkers": this.showMarkers,
2288
+ "markerProps": this.markerProps,
2289
+ "autoClosePopover": this.autoClosePopover,
2290
+ "defaultPin": this.defaultPin,
2291
+ "defaultQuery": this.defaultQuery,
2292
+ "autoCenter": this.autoCenter,
2293
+ "defaultCenter": this.defaultCenter,
2294
+ "defaultRadius": this.defaultRadius,
2295
+ "unit": this.unit,
2296
+ "pages": this.pages,
2297
+ "center": this.center,
2298
+ "loader": this.loader,
2299
+ "calculateMarkers": this.calculateMarkers
2300
+ }
2301
+ }, {
2302
+ scopedSlots: this.$scopedSlots,
2303
+ on: this.$listeners
2304
+ }]));
2305
+ }
2306
+ };
2307
+
2308
+ ReactiveGoogleMap.install = function (Vue, options) {
2309
+ Vue.component(ReactiveGoogleMap.name, ReactiveGoogleMap);
2310
+
2311
+ if (!options || !options.key) {
2312
+ console.error('ReactiveSearch: map key is required to use ReactiveGoogleMap component');
2313
+ }
2314
+
2315
+ Vue.use(GmapVue, {
2316
+ load: {
2317
+ key: options.key,
2318
+ libraries: 'places'
2319
+ },
2320
+ installComponents: false
2321
+ });
2322
+ }; // Add componentType for SSR
2323
+
2324
+
2325
+ ReactiveGoogleMap.componentType = componentTypes.reactiveMap;
2326
+
2327
+ export default ReactiveGoogleMap;