@blaze-cms/plugin-google-maps-fe 0.123.0-alpha.25 → 0.123.0-alpha.29

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 (72) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/lib/GoogleMaps/GoogleMaps.js +68 -40
  3. package/lib/GoogleMaps/GoogleMaps.js.map +1 -1
  4. package/lib/GoogleMaps/GoogleMapsFactory.js +8 -4
  5. package/lib/GoogleMaps/GoogleMapsFactory.js.map +1 -1
  6. package/lib/GoogleMaps/GoogleMapsRender.js +24 -41
  7. package/lib/GoogleMaps/GoogleMapsRender.js.map +1 -1
  8. package/lib/GoogleMaps/helpers/add-zoom-listener.js +3 -50
  9. package/lib/GoogleMaps/helpers/add-zoom-listener.js.map +1 -1
  10. package/lib/GoogleMaps/helpers/build-map-shapes.js +97 -0
  11. package/lib/GoogleMaps/helpers/build-map-shapes.js.map +1 -0
  12. package/lib/GoogleMaps/helpers/build-query.js +24 -14
  13. package/lib/GoogleMaps/helpers/build-query.js.map +1 -1
  14. package/lib/GoogleMaps/helpers/build-shapes-configs.js +196 -0
  15. package/lib/GoogleMaps/helpers/build-shapes-configs.js.map +1 -0
  16. package/lib/GoogleMaps/helpers/get-center-coordinates.js +49 -0
  17. package/lib/GoogleMaps/helpers/get-center-coordinates.js.map +1 -0
  18. package/lib/GoogleMaps/helpers/get-image-ids.js +16 -14
  19. package/lib/GoogleMaps/helpers/get-image-ids.js.map +1 -1
  20. package/lib/GoogleMaps/helpers/index.js +21 -5
  21. package/lib/GoogleMaps/helpers/index.js.map +1 -1
  22. package/lib/GoogleMaps/helpers/set-shapes.js +213 -200
  23. package/lib/GoogleMaps/helpers/set-shapes.js.map +1 -1
  24. package/lib/GoogleMaps/hooks/use-get-images.js +3 -2
  25. package/lib/GoogleMaps/hooks/use-get-images.js.map +1 -1
  26. package/lib/GoogleMaps/queries.js +22 -4
  27. package/lib/GoogleMaps/queries.js.map +1 -1
  28. package/lib-es/GoogleMaps/GoogleMaps.js +51 -25
  29. package/lib-es/GoogleMaps/GoogleMaps.js.map +1 -1
  30. package/lib-es/GoogleMaps/GoogleMapsFactory.js +10 -6
  31. package/lib-es/GoogleMaps/GoogleMapsFactory.js.map +1 -1
  32. package/lib-es/GoogleMaps/GoogleMapsRender.js +24 -32
  33. package/lib-es/GoogleMaps/GoogleMapsRender.js.map +1 -1
  34. package/lib-es/GoogleMaps/helpers/add-zoom-listener.js +3 -23
  35. package/lib-es/GoogleMaps/helpers/add-zoom-listener.js.map +1 -1
  36. package/lib-es/GoogleMaps/helpers/build-map-shapes.js +86 -0
  37. package/lib-es/GoogleMaps/helpers/build-map-shapes.js.map +1 -0
  38. package/lib-es/GoogleMaps/helpers/build-query.js +17 -8
  39. package/lib-es/GoogleMaps/helpers/build-query.js.map +1 -1
  40. package/lib-es/GoogleMaps/helpers/build-shapes-configs.js +134 -0
  41. package/lib-es/GoogleMaps/helpers/build-shapes-configs.js.map +1 -0
  42. package/lib-es/GoogleMaps/helpers/get-center-coordinates.js +31 -0
  43. package/lib-es/GoogleMaps/helpers/get-center-coordinates.js.map +1 -0
  44. package/lib-es/GoogleMaps/helpers/get-image-ids.js +9 -14
  45. package/lib-es/GoogleMaps/helpers/get-image-ids.js.map +1 -1
  46. package/lib-es/GoogleMaps/helpers/index.js +4 -2
  47. package/lib-es/GoogleMaps/helpers/index.js.map +1 -1
  48. package/lib-es/GoogleMaps/helpers/set-shapes.js +80 -125
  49. package/lib-es/GoogleMaps/helpers/set-shapes.js.map +1 -1
  50. package/lib-es/GoogleMaps/hooks/use-get-images.js +4 -3
  51. package/lib-es/GoogleMaps/hooks/use-get-images.js.map +1 -1
  52. package/lib-es/GoogleMaps/queries.js +23 -2
  53. package/lib-es/GoogleMaps/queries.js.map +1 -1
  54. package/package.json +3 -3
  55. package/src/GoogleMaps/GoogleMaps.js +40 -27
  56. package/src/GoogleMaps/GoogleMapsFactory.js +11 -4
  57. package/src/GoogleMaps/GoogleMapsRender.js +22 -21
  58. package/src/GoogleMaps/helpers/add-zoom-listener.js +3 -22
  59. package/src/GoogleMaps/helpers/build-map-shapes.js +70 -0
  60. package/src/GoogleMaps/helpers/build-query.js +25 -10
  61. package/src/GoogleMaps/helpers/build-shapes-configs.js +110 -0
  62. package/src/GoogleMaps/helpers/get-center-coordinates.js +24 -0
  63. package/src/GoogleMaps/helpers/get-image-ids.js +6 -15
  64. package/src/GoogleMaps/helpers/index.js +12 -2
  65. package/src/GoogleMaps/helpers/set-shapes.js +87 -123
  66. package/src/GoogleMaps/hooks/use-get-images.js +4 -3
  67. package/src/GoogleMaps/queries.js +30 -3
  68. package/lib/GoogleMaps/helpers/set-entity-configs.js +0 -144
  69. package/lib/GoogleMaps/helpers/set-entity-configs.js.map +0 -1
  70. package/lib-es/GoogleMaps/helpers/set-entity-configs.js +0 -94
  71. package/lib-es/GoogleMaps/helpers/set-entity-configs.js.map +0 -1
  72. package/src/GoogleMaps/helpers/set-entity-configs.js +0 -84
@@ -1,20 +1,29 @@
1
- import { generateQuery, generateQueryString } from '../queries';
1
+ import { generateQuery, generateIdsQuery, generateFiltersQuery } from '../queries';
2
2
 
3
3
  const buildQuery = entityConfigs => {
4
4
  const entityIds = [];
5
- const queryString = Object.keys(entityConfigs).reduce((acc, entityConfig) => {
5
+ const rawQueryStringified = '';
6
+ const queryString = entityConfigs.map(entityConfig => {
6
7
  const {
7
8
  action,
8
9
  ids,
9
- propsQuery
10
- } = entityConfigs[entityConfig];
10
+ entity,
11
+ propsQuery,
12
+ shapeKey,
13
+ filtersObject
14
+ } = entityConfig;
15
+ if (!action) return '';
16
+ const formatedEntity = `${entity[0].toUpperCase()}${entity.slice(1)}`;
17
+ const filterQueryKey = action.indexOf('Published') !== -1 ? `Published${formatedEntity}` : formatedEntity;
11
18
  entityIds.push(...ids);
12
- const singleItemQuery = action ? generateQueryString(action, entityConfig, propsQuery.trim() || 'id') : '';
13
- return `${acc}${singleItemQuery}`;
14
- }, '');
19
+ const props = propsQuery.trim() || 'id';
20
+ const singleItemQuery = filtersObject ? generateFiltersQuery(shapeKey, props, JSON.stringify(filtersObject), filterQueryKey) : generateIdsQuery(shapeKey, props, action, ids);
21
+ return singleItemQuery;
22
+ }).join(' ');
15
23
  return {
16
24
  query: queryString ? generateQuery(queryString) : '',
17
- ids: entityIds
25
+ ids: entityIds,
26
+ rawQueryStringified
18
27
  };
19
28
  };
20
29
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/GoogleMaps/helpers/build-query.js"],"names":["generateQuery","generateQueryString","buildQuery","entityConfigs","entityIds","queryString","Object","keys","reduce","acc","entityConfig","action","ids","propsQuery","push","singleItemQuery","trim","query"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,mBAAxB,QAAmD,YAAnD;;AAEA,MAAMC,UAAU,GAAGC,aAAa,IAAI;AAClC,QAAMC,SAAS,GAAG,EAAlB;AACA,QAAMC,WAAW,GAAGC,MAAM,CAACC,IAAP,CAAYJ,aAAZ,EAA2BK,MAA3B,CAAkC,CAACC,GAAD,EAAMC,YAAN,KAAuB;AAC3E,UAAM;AAAEC,MAAAA,MAAF;AAAUC,MAAAA,GAAV;AAAeC,MAAAA;AAAf,QAA8BV,aAAa,CAACO,YAAD,CAAjD;AACAN,IAAAA,SAAS,CAACU,IAAV,CAAe,GAAGF,GAAlB;AACA,UAAMG,eAAe,GAAGJ,MAAM,GAC1BV,mBAAmB,CAACU,MAAD,EAASD,YAAT,EAAuBG,UAAU,CAACG,IAAX,MAAqB,IAA5C,CADO,GAE1B,EAFJ;AAGA,WAAQ,GAAEP,GAAI,GAAEM,eAAgB,EAAhC;AACD,GAPmB,EAOjB,EAPiB,CAApB;AAQA,SAAO;AAAEE,IAAAA,KAAK,EAAEZ,WAAW,GAAGL,aAAa,CAACK,WAAD,CAAhB,GAAgC,EAApD;AAAwDO,IAAAA,GAAG,EAAER;AAA7D,GAAP;AACD,CAXD;;AAaA,eAAeF,UAAf","sourcesContent":["import { generateQuery, generateQueryString } from '../queries';\n\nconst buildQuery = entityConfigs => {\n const entityIds = [];\n const queryString = Object.keys(entityConfigs).reduce((acc, entityConfig) => {\n const { action, ids, propsQuery } = entityConfigs[entityConfig];\n entityIds.push(...ids);\n const singleItemQuery = action\n ? generateQueryString(action, entityConfig, propsQuery.trim() || 'id')\n : '';\n return `${acc}${singleItemQuery}`;\n }, '');\n return { query: queryString ? generateQuery(queryString) : '', ids: entityIds };\n};\n\nexport default buildQuery;\n"],"file":"build-query.js"}
1
+ {"version":3,"sources":["../../../src/GoogleMaps/helpers/build-query.js"],"names":["generateQuery","generateIdsQuery","generateFiltersQuery","buildQuery","entityConfigs","entityIds","rawQueryStringified","queryString","map","entityConfig","action","ids","entity","propsQuery","shapeKey","filtersObject","formatedEntity","toUpperCase","slice","filterQueryKey","indexOf","push","props","trim","singleItemQuery","JSON","stringify","join","query"],"mappings":"AAAA,SAASA,aAAT,EAAwBC,gBAAxB,EAA0CC,oBAA1C,QAAsE,YAAtE;;AAEA,MAAMC,UAAU,GAAGC,aAAa,IAAI;AAClC,QAAMC,SAAS,GAAG,EAAlB;AACA,QAAMC,mBAAmB,GAAG,EAA5B;AACA,QAAMC,WAAW,GAAGH,aAAa,CAC9BI,GADiB,CACbC,YAAY,IAAI;AACnB,UAAM;AAAEC,MAAAA,MAAF;AAAUC,MAAAA,GAAV;AAAeC,MAAAA,MAAf;AAAuBC,MAAAA,UAAvB;AAAmCC,MAAAA,QAAnC;AAA6CC,MAAAA;AAA7C,QAA+DN,YAArE;AACA,QAAI,CAACC,MAAL,EAAa,OAAO,EAAP;AACb,UAAMM,cAAc,GAAI,GAAEJ,MAAM,CAAC,CAAD,CAAN,CAAUK,WAAV,EAAwB,GAAEL,MAAM,CAACM,KAAP,CAAa,CAAb,CAAgB,EAApE;AACA,UAAMC,cAAc,GAClBT,MAAM,CAACU,OAAP,CAAe,WAAf,MAAgC,CAAC,CAAjC,GAAsC,YAAWJ,cAAe,EAAhE,GAAoEA,cADtE;AAGAX,IAAAA,SAAS,CAACgB,IAAV,CAAe,GAAGV,GAAlB;AACA,UAAMW,KAAK,GAAGT,UAAU,CAACU,IAAX,MAAqB,IAAnC;AACA,UAAMC,eAAe,GAAGT,aAAa,GACjCb,oBAAoB,CAACY,QAAD,EAAWQ,KAAX,EAAkBG,IAAI,CAACC,SAAL,CAAeX,aAAf,CAAlB,EAAiDI,cAAjD,CADa,GAEjClB,gBAAgB,CAACa,QAAD,EAAWQ,KAAX,EAAkBZ,MAAlB,EAA0BC,GAA1B,CAFpB;AAIA,WAAOa,eAAP;AACD,GAfiB,EAgBjBG,IAhBiB,CAgBZ,GAhBY,CAApB;AAkBA,SAAO;AACLC,IAAAA,KAAK,EAAErB,WAAW,GAAGP,aAAa,CAACO,WAAD,CAAhB,GAAgC,EAD7C;AAELI,IAAAA,GAAG,EAAEN,SAFA;AAGLC,IAAAA;AAHK,GAAP;AAKD,CA1BD;;AA4BA,eAAeH,UAAf","sourcesContent":["import { generateQuery, generateIdsQuery, generateFiltersQuery } from '../queries';\n\nconst buildQuery = entityConfigs => {\n const entityIds = [];\n const rawQueryStringified = '';\n const queryString = entityConfigs\n .map(entityConfig => {\n const { action, ids, entity, propsQuery, shapeKey, filtersObject } = entityConfig;\n if (!action) return '';\n const formatedEntity = `${entity[0].toUpperCase()}${entity.slice(1)}`;\n const filterQueryKey =\n action.indexOf('Published') !== -1 ? `Published${formatedEntity}` : formatedEntity;\n\n entityIds.push(...ids);\n const props = propsQuery.trim() || 'id';\n const singleItemQuery = filtersObject\n ? generateFiltersQuery(shapeKey, props, JSON.stringify(filtersObject), filterQueryKey)\n : generateIdsQuery(shapeKey, props, action, ids);\n\n return singleItemQuery;\n })\n .join(' ');\n\n return {\n query: queryString ? generateQuery(queryString) : '',\n ids: entityIds,\n rawQueryStringified\n };\n};\n\nexport default buildQuery;\n"],"file":"build-query.js"}
@@ -0,0 +1,134 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ import flatten from 'lodash.flatten';
8
+ import { IMAGE_ID, URL, ID } from '../../constants';
9
+
10
+ const getPropValues = properties => properties.reduce((acc, property) => {
11
+ if (property.includes('.')) {
12
+ const [relationName, relationProp] = property.split('.');
13
+ return `${acc} ${relationName} { ${relationProp} }`;
14
+ }
15
+
16
+ return `${acc} ${property}`;
17
+ }, '').trim();
18
+
19
+ const getUpdatedPropsQuery = (propsQuery, entityData) => {
20
+ const {
21
+ properties = {},
22
+ dynamicProperties = {}
23
+ } = entityData;
24
+ const [url] = Object.keys(dynamicProperties).filter(prop => prop === URL);
25
+ const hasImage = !!Object.keys(properties).filter(prop => prop === IMAGE_ID).length;
26
+ let updatedPropsQuery = hasImage ? `${propsQuery} ${IMAGE_ID}` : propsQuery;
27
+ updatedPropsQuery = url ? `${updatedPropsQuery} ${URL}` : updatedPropsQuery;
28
+ return updatedPropsQuery;
29
+ };
30
+
31
+ const buildFilterQueryString = filter => {
32
+ const [filterKey, filterValue] = filter.split('/');
33
+ const filterKeyword = `${filterKey}.keyword`;
34
+ return {
35
+ bool: {
36
+ should: [{
37
+ match: {
38
+ [filterKeyword]: filterValue
39
+ }
40
+ }]
41
+ }
42
+ };
43
+ };
44
+
45
+ const buildFilters = filters => {
46
+ if (!filters || !filters.length) return null;
47
+ const filterQueryProps = filters.map(buildFilterQueryString);
48
+ return {
49
+ bool: {
50
+ should: filterQueryProps
51
+ }
52
+ };
53
+ };
54
+
55
+ const buiildShapeProps = (shape, shapeKey, dataSummaries, parentId, entityData, entityGroup) => {
56
+ const {
57
+ displayItems = [],
58
+ filterBy
59
+ } = shape;
60
+ const {
61
+ latProp,
62
+ lonProp,
63
+ entity
64
+ } = entityGroup;
65
+ const {
66
+ actions
67
+ } = entityData;
68
+ const action = actions ? actions.getAllPublished || actions.getAll : '';
69
+ const dataSummaryProps = dataSummaries.reduce((acc, {
70
+ propsToDisplay
71
+ }) => {
72
+ const propsToDisplayValues = flatten(propsToDisplay.map(({
73
+ propertiesToDisplay
74
+ }) => propertiesToDisplay));
75
+ const propsToDisplayString = getPropValues(propsToDisplayValues);
76
+ return `${acc} ${propsToDisplayString}`;
77
+ }, '').trim();
78
+ const ids = [];
79
+ displayItems.length ? ids.push(displayItems[0]) : ids.push(parentId);
80
+ const filtersObject = buildFilters(filterBy);
81
+ let propsQuery = dataSummaryProps ? `${dataSummaryProps}` : '';
82
+ propsQuery = getUpdatedPropsQuery(propsQuery, entityData);
83
+
84
+ if (latProp && lonProp) {
85
+ propsQuery = `${propsQuery} ${formatProp(latProp)} ${formatProp(lonProp)}`;
86
+ }
87
+
88
+ if (ids.length && !propsQuery.includes(ID)) propsQuery = `${propsQuery.trim()} ${ID}`;
89
+ return {
90
+ shapeKey,
91
+ entity,
92
+ propsQuery,
93
+ ids,
94
+ action,
95
+ filtersObject
96
+ };
97
+ };
98
+
99
+ const formatProp = prop => {
100
+ if (!prop.includes('.')) return prop;
101
+ const [mainProp, nestedProp] = prop.split('.');
102
+ return `${mainProp}{${nestedProp}}`;
103
+ };
104
+
105
+ const buildShapesConfig = (schemas, entityGroups, parent) => {
106
+ if (!schemas || !entityGroups) return [];
107
+ const {
108
+ itemId,
109
+ itemEntity
110
+ } = parent;
111
+ const shapeGroups = [];
112
+ entityGroups.forEach((entityGroup, i) => {
113
+ const {
114
+ entity,
115
+ shapes,
116
+ dataSummaries = []
117
+ } = entityGroup;
118
+ const parentId = entity === itemEntity && itemId;
119
+ if (!entity) return null;
120
+ const entityData = schemas[entity] || {};
121
+ shapes.filter(Boolean).forEach((shape, shapeIndex) => {
122
+ const shapeKey = `shape${i}${shapeIndex}`;
123
+ const shapeValues = buiildShapeProps(shape, shapeKey, dataSummaries, parentId, entityData, entityGroup);
124
+ shapeGroups.push(_objectSpread(_objectSpread({}, shapeValues), {}, {
125
+ shapeOptions: shape,
126
+ entityOptions: entityGroup
127
+ }));
128
+ });
129
+ });
130
+ return shapeGroups;
131
+ };
132
+
133
+ export default buildShapesConfig;
134
+ //# sourceMappingURL=build-shapes-configs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/GoogleMaps/helpers/build-shapes-configs.js"],"names":["flatten","IMAGE_ID","URL","ID","getPropValues","properties","reduce","acc","property","includes","relationName","relationProp","split","trim","getUpdatedPropsQuery","propsQuery","entityData","dynamicProperties","url","Object","keys","filter","prop","hasImage","length","updatedPropsQuery","buildFilterQueryString","filterKey","filterValue","filterKeyword","bool","should","match","buildFilters","filters","filterQueryProps","map","buiildShapeProps","shape","shapeKey","dataSummaries","parentId","entityGroup","displayItems","filterBy","latProp","lonProp","entity","actions","action","getAllPublished","getAll","dataSummaryProps","propsToDisplay","propsToDisplayValues","propertiesToDisplay","propsToDisplayString","ids","push","filtersObject","formatProp","mainProp","nestedProp","buildShapesConfig","schemas","entityGroups","parent","itemId","itemEntity","shapeGroups","forEach","i","shapes","Boolean","shapeIndex","shapeValues","shapeOptions","entityOptions"],"mappings":";;;;;;AAAA,OAAOA,OAAP,MAAoB,gBAApB;AACA,SAASC,QAAT,EAAmBC,GAAnB,EAAwBC,EAAxB,QAAkC,iBAAlC;;AAEA,MAAMC,aAAa,GAAGC,UAAU,IAC9BA,UAAU,CACPC,MADH,CACU,CAACC,GAAD,EAAMC,QAAN,KAAmB;AACzB,MAAIA,QAAQ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V,MAAyBF,MAA/B;AACA,QAAMG,WAAW,GAAG,EAApB;AACAJ,EAAAA,YAAY,CAACK,OAAb,CAAqB,CAAC5B,WAAD,EAAc6B,CAAd,KAAoB;AACvC,UAAM;AAAExB,MAAAA,MAAF;AAAUyB,MAAAA,MAAV;AAAkBhC,MAAAA,aAAa,GAAG;AAAlC,QAAyCE,WAA/C;AACA,UAAMD,QAAQ,GAAGM,MAAM,KAAKqB,UAAX,IAAyBD,MAA1C;AACA,QAAI,CAACpB,MAAL,EAAa,OAAO,IAAP;AACb,UAAM/B,UAAU,GAAGgD,OAAO,CAACjB,MAAD,CAAP,IAAmB,EAAtC;AAEAyB,IAAAA,MAAM,CAACnD,MAAP,CAAcoD,OAAd,EAAuBH,OAAvB,CAA+B,CAAChC,KAAD,EAAQoC,UAAR,KAAuB;AACpD,YAAMnC,QAAQ,GAAI,QAAOgC,CAAE,GAAEG,UAAW,EAAxC;AACA,YAAMC,WAAW,GAAGtC,gBAAgB,CAClCC,KADkC,EAElCC,QAFkC,EAGlCC,aAHkC,EAIlCC,QAJkC,EAKlCzB,UALkC,EAMlC0B,WANkC,CAApC;AAQA2B,MAAAA,WAAW,CAACX,IAAZ,iCAAsBiB,WAAtB;AAAmCC,QAAAA,YAAY,EAAEtC,KAAjD;AAAwDuC,QAAAA,aAAa,EAAEnC;AAAvE;AACD,KAXD;AAYD,GAlBD;AAoBA,SAAO2B,WAAP;AACD,CAzBD;;AA2BA,eAAeN,iBAAf","sourcesContent":["import flatten from 'lodash.flatten';\nimport { IMAGE_ID, URL, ID } from '../../constants';\n\nconst getPropValues = properties =>\n properties\n .reduce((acc, property) => {\n if (property.includes('.')) {\n const [relationName, relationProp] = property.split('.');\n return `${acc} ${relationName} { ${relationProp} }`;\n }\n return `${acc} ${property}`;\n }, '')\n .trim();\n\nconst getUpdatedPropsQuery = (propsQuery, entityData) => {\n const { properties = {}, dynamicProperties = {} } = entityData;\n\n const [url] = Object.keys(dynamicProperties).filter(prop => prop === URL);\n const hasImage = !!Object.keys(properties).filter(prop => prop === IMAGE_ID).length;\n\n let updatedPropsQuery = hasImage ? `${propsQuery} ${IMAGE_ID}` : propsQuery;\n updatedPropsQuery = url ? `${updatedPropsQuery} ${URL}` : updatedPropsQuery;\n\n return updatedPropsQuery;\n};\n\nconst buildFilterQueryString = filter => {\n const [filterKey, filterValue] = filter.split('/');\n const filterKeyword = `${filterKey}.keyword`;\n return { bool: { should: [{ match: { [filterKeyword]: filterValue } }] } };\n};\n\nconst buildFilters = filters => {\n if (!filters || !filters.length) return null;\n const filterQueryProps = filters.map(buildFilterQueryString);\n return { bool: { should: filterQueryProps } };\n};\n\nconst buiildShapeProps = (shape, shapeKey, dataSummaries, parentId, entityData, entityGroup) => {\n const { displayItems = [], filterBy } = shape;\n const { latProp, lonProp, entity } = entityGroup;\n const { actions } = entityData;\n const action = actions ? actions.getAllPublished || actions.getAll : '';\n\n const dataSummaryProps = dataSummaries\n .reduce((acc, { propsToDisplay }) => {\n const propsToDisplayValues = flatten(\n propsToDisplay.map(({ propertiesToDisplay }) => propertiesToDisplay)\n );\n const propsToDisplayString = getPropValues(propsToDisplayValues);\n\n return `${acc} ${propsToDisplayString}`;\n }, '')\n .trim();\n const ids = [];\n displayItems.length ? ids.push(displayItems[0]) : ids.push(parentId);\n\n const filtersObject = buildFilters(filterBy);\n let propsQuery = dataSummaryProps ? `${dataSummaryProps}` : '';\n propsQuery = getUpdatedPropsQuery(propsQuery, entityData);\n if (latProp && lonProp) {\n propsQuery = `${propsQuery} ${formatProp(latProp)} ${formatProp(lonProp)}`;\n }\n if (ids.length && !propsQuery.includes(ID)) propsQuery = `${propsQuery.trim()} ${ID}`;\n\n return {\n shapeKey,\n entity,\n propsQuery,\n ids,\n action,\n filtersObject\n };\n};\n\nconst formatProp = prop => {\n if (!prop.includes('.')) return prop;\n\n const [mainProp, nestedProp] = prop.split('.');\n return `${mainProp}{${nestedProp}}`;\n};\n\nconst buildShapesConfig = (schemas, entityGroups, parent) => {\n if (!schemas || !entityGroups) return [];\n const { itemId, itemEntity } = parent;\n const shapeGroups = [];\n entityGroups.forEach((entityGroup, i) => {\n const { entity, shapes, dataSummaries = [] } = entityGroup;\n const parentId = entity === itemEntity && itemId;\n if (!entity) return null;\n const entityData = schemas[entity] || {};\n\n shapes.filter(Boolean).forEach((shape, shapeIndex) => {\n const shapeKey = `shape${i}${shapeIndex}`;\n const shapeValues = buiildShapeProps(\n shape,\n shapeKey,\n dataSummaries,\n parentId,\n entityData,\n entityGroup\n );\n shapeGroups.push({ ...shapeValues, shapeOptions: shape, entityOptions: entityGroup });\n });\n });\n\n return shapeGroups;\n};\n\nexport default buildShapesConfig;\n"],"file":"build-shapes-configs.js"}
@@ -0,0 +1,31 @@
1
+ import isNumber from 'lodash.isnumber';
2
+
3
+ const getCenterCoordinates = (mapShapes, otherProps) => {
4
+ const centerCoordinates = [];
5
+ const {
6
+ centerLatitude,
7
+ centerLongitude
8
+ } = otherProps;
9
+ const useDefaultCenter = centerLatitude !== 0 && centerLongitude !== 0 && isNumber(centerLatitude) && isNumber(centerLongitude);
10
+ if (useDefaultCenter) return [{
11
+ latitude: centerLatitude,
12
+ longitude: centerLongitude
13
+ }];
14
+ const useAsCenterShapes = mapShapes.filter(({
15
+ useAsCenter
16
+ }) => useAsCenter);
17
+ const shapesForCenter = useAsCenterShapes.length ? useAsCenterShapes : mapShapes;
18
+ shapesForCenter.forEach(({
19
+ latitude,
20
+ longitude
21
+ }) => {
22
+ if (isNumber(latitude) && isNumber(longitude)) centerCoordinates.push({
23
+ latitude,
24
+ longitude
25
+ });
26
+ });
27
+ return centerCoordinates;
28
+ };
29
+
30
+ export default getCenterCoordinates;
31
+ //# sourceMappingURL=get-center-coordinates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/GoogleMaps/helpers/get-center-coordinates.js"],"names":["isNumber","getCenterCoordinates","mapShapes","otherProps","centerCoordinates","centerLatitude","centerLongitude","useDefaultCenter","latitude","longitude","useAsCenterShapes","filter","useAsCenter","shapesForCenter","length","forEach","push"],"mappings":"AAAA,OAAOA,QAAP,MAAqB,iBAArB;;AAEA,MAAMC,oBAAoB,GAAG,CAACC,SAAD,EAAYC,UAAZ,KAA2B;AACtD,QAAMC,iBAAiB,GAAG,EAA1B;AAEA,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,MAAsCH,UAA5C;AACA,QAAMI,gBAAgB,GACpBF,cAAc,KAAK,CAAnB,IACAC,eAAe,KAAK,CADpB,IAEAN,QAAQ,CAACK,cAAD,CAFR,IAGAL,QAAQ,CAACM,eAAD,CAJV;AAMA,MAAIC,gBAAJ,EAAsB,OAAO,CAAC;AAAEC,IAAAA,QAAQ,EAAEH,cAAZ;AAA4BI,IAAAA,SAAS,EAAEH;AAAvC,GAAD,CAAP;AAEtB,QAAMI,iBAAiB,GAAGR,SAAS,CAACS,MAAV,CAAiB,CAAC;AAAEC,IAAAA;AAAF,GAAD,KAAqBA,WAAtC,CAA1B;AACA,QAAMC,eAAe,GAAGH,iBAAiB,CAACI,MAAlB,GAA2BJ,iBAA3B,GAA+CR,SAAvE;AACAW,EAAAA,eAAe,CAACE,OAAhB,CAAwB,CAAC;AAAEP,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAD,KAA6B;AACnD,QAAIT,QAAQ,CAACQ,QAAD,CAAR,IAAsBR,QAAQ,CAACS,SAAD,CAAlC,EAA+CL,iBAAiB,CAACY,IAAlB,CAAuB;AAAER,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,KAAvB;AAChD,GAFD;AAIA,SAAOL,iBAAP;AACD,CAnBD;;AAqBA,eAAeH,oBAAf","sourcesContent":["import isNumber from 'lodash.isnumber';\n\nconst getCenterCoordinates = (mapShapes, otherProps) => {\n const centerCoordinates = [];\n\n const { centerLatitude, centerLongitude } = otherProps;\n const useDefaultCenter =\n centerLatitude !== 0 &&\n centerLongitude !== 0 &&\n isNumber(centerLatitude) &&\n isNumber(centerLongitude);\n\n if (useDefaultCenter) return [{ latitude: centerLatitude, longitude: centerLongitude }];\n\n const useAsCenterShapes = mapShapes.filter(({ useAsCenter }) => useAsCenter);\n const shapesForCenter = useAsCenterShapes.length ? useAsCenterShapes : mapShapes;\n shapesForCenter.forEach(({ latitude, longitude }) => {\n if (isNumber(latitude) && isNumber(longitude)) centerCoordinates.push({ latitude, longitude });\n });\n\n return centerCoordinates;\n};\n\nexport default getCenterCoordinates;\n"],"file":"get-center-coordinates.js"}
@@ -1,18 +1,13 @@
1
- const getImageIds = (entityConfigs, entityData) => {
2
- const images = [];
3
- Object.keys(entityConfigs).forEach(entityConfig => {
4
- const {
5
- imageIds
6
- } = entityConfigs[entityConfig];
7
- images.push(...imageIds);
8
-
9
- if (entityData[entityConfig] && entityData[entityConfig].length) {
10
- entityData[entityConfig].forEach(entity => {
11
- if (entity.imageId) images.push(entity.imageId);
12
- });
13
- }
1
+ const getImageIds = mapShapes => {
2
+ const ids = [];
3
+ mapShapes.forEach(({
4
+ shapeData,
5
+ imageId
6
+ }) => {
7
+ if (imageId) ids.push(imageId);
8
+ if (shapeData.imageId) ids.push(shapeData.imageId);
14
9
  });
15
- return images;
10
+ return [...new Set(ids)];
16
11
  };
17
12
 
18
13
  export default getImageIds;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/GoogleMaps/helpers/get-image-ids.js"],"names":["getImageIds","entityConfigs","entityData","images","Object","keys","forEach","entityConfig","imageIds","push","length","entity","imageId"],"mappings":"AAAA,MAAMA,WAAW,GAAG,CAACC,aAAD,EAAgBC,UAAhB,KAA+B;AACjD,QAAMC,MAAM,GAAG,EAAf;AAEAC,EAAAA,MAAM,CAACC,IAAP,CAAYJ,aAAZ,EAA2BK,OAA3B,CAAmCC,YAAY,IAAI;AACjD,UAAM;AAAEC,MAAAA;AAAF,QAAeP,aAAa,CAACM,YAAD,CAAlC;AAEAJ,IAAAA,MAAM,CAACM,IAAP,CAAY,GAAGD,QAAf;;AAEA,QAAIN,UAAU,CAACK,YAAD,CAAV,IAA4BL,UAAU,CAACK,YAAD,CAAV,CAAyBG,MAAzD,EAAiE;AAC/DR,MAAAA,UAAU,CAACK,YAAD,CAAV,CAAyBD,OAAzB,CAAiCK,MAAM,IAAI;AACzC,YAAIA,MAAM,CAACC,OAAX,EAAoBT,MAAM,CAACM,IAAP,CAAYE,MAAM,CAACC,OAAnB;AACrB,OAFD;AAGD;AACF,GAVD;AAYA,SAAOT,MAAP;AACD,CAhBD;;AAkBA,eAAeH,WAAf","sourcesContent":["const getImageIds = (entityConfigs, entityData) => {\n const images = [];\n\n Object.keys(entityConfigs).forEach(entityConfig => {\n const { imageIds } = entityConfigs[entityConfig];\n\n images.push(...imageIds);\n\n if (entityData[entityConfig] && entityData[entityConfig].length) {\n entityData[entityConfig].forEach(entity => {\n if (entity.imageId) images.push(entity.imageId);\n });\n }\n });\n\n return images;\n};\n\nexport default getImageIds;\n"],"file":"get-image-ids.js"}
1
+ {"version":3,"sources":["../../../src/GoogleMaps/helpers/get-image-ids.js"],"names":["getImageIds","mapShapes","ids","forEach","shapeData","imageId","push","Set"],"mappings":"AAAA,MAAMA,WAAW,GAAGC,SAAS,IAAI;AAC/B,QAAMC,GAAG,GAAG,EAAZ;AACAD,EAAAA,SAAS,CAACE,OAAV,CAAkB,CAAC;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,GAAD,KAA4B;AAC5C,QAAIA,OAAJ,EAAaH,GAAG,CAACI,IAAJ,CAASD,OAAT;AACb,QAAID,SAAS,CAACC,OAAd,EAAuBH,GAAG,CAACI,IAAJ,CAASF,SAAS,CAACC,OAAnB;AACxB,GAHD;AAIA,SAAO,CAAC,GAAG,IAAIE,GAAJ,CAAQL,GAAR,CAAJ,CAAP;AACD,CAPD;;AASA,eAAeF,WAAf","sourcesContent":["const getImageIds = mapShapes => {\n const ids = [];\n mapShapes.forEach(({ shapeData, imageId }) => {\n if (imageId) ids.push(imageId);\n if (shapeData.imageId) ids.push(shapeData.imageId);\n });\n return [...new Set(ids)];\n};\n\nexport default getImageIds;\n"],"file":"get-image-ids.js"}
@@ -1,7 +1,9 @@
1
1
  import addZoomListener from './add-zoom-listener';
2
2
  import buildQuery from './build-query';
3
3
  import getImageIds from './get-image-ids';
4
- import setEntityConfigs from './set-entity-configs';
4
+ import buildShapesConfig from './build-shapes-configs';
5
5
  import setMapOptions from './set-map-options';
6
- export { addZoomListener, buildQuery, getImageIds, setEntityConfigs, setMapOptions };
6
+ import getCenterCoordinates from './get-center-coordinates';
7
+ import buildMapShapes from './build-map-shapes';
8
+ export { addZoomListener, buildQuery, getImageIds, buildShapesConfig, setMapOptions, getCenterCoordinates, buildMapShapes };
7
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/GoogleMaps/helpers/index.js"],"names":["addZoomListener","buildQuery","getImageIds","setEntityConfigs","setMapOptions"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,qBAA5B;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AAEA,SAASJ,eAAT,EAA0BC,UAA1B,EAAsCC,WAAtC,EAAmDC,gBAAnD,EAAqEC,aAArE","sourcesContent":["import addZoomListener from './add-zoom-listener';\nimport buildQuery from './build-query';\nimport getImageIds from './get-image-ids';\nimport setEntityConfigs from './set-entity-configs';\nimport setMapOptions from './set-map-options';\n\nexport { addZoomListener, buildQuery, getImageIds, setEntityConfigs, setMapOptions };\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/GoogleMaps/helpers/index.js"],"names":["addZoomListener","buildQuery","getImageIds","buildShapesConfig","setMapOptions","getCenterCoordinates","buildMapShapes"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,qBAA5B;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AAEA,SACEN,eADF,EAEEC,UAFF,EAGEC,WAHF,EAIEC,iBAJF,EAKEC,aALF,EAMEC,oBANF,EAOEC,cAPF","sourcesContent":["import addZoomListener from './add-zoom-listener';\nimport buildQuery from './build-query';\nimport getImageIds from './get-image-ids';\nimport buildShapesConfig from './build-shapes-configs';\nimport setMapOptions from './set-map-options';\nimport getCenterCoordinates from './get-center-coordinates';\nimport buildMapShapes from './build-map-shapes';\n\nexport {\n addZoomListener,\n buildQuery,\n getImageIds,\n buildShapesConfig,\n setMapOptions,\n getCenterCoordinates,\n buildMapShapes\n};\n"],"file":"index.js"}
@@ -30,22 +30,21 @@ const closeInfoWindows = () => {
30
30
  }
31
31
  };
32
32
 
33
- const addShapeListeners = (map, router, shape, entityData, imageData, shapeInstance) => {
33
+ const addShapeListeners = (map, router, shape, imageData, shapeInstance) => {
34
34
  const {
35
- displayItems,
36
- entity,
37
35
  enableInfoPane = false,
38
- dataSummaries = []
36
+ dataSummaries = [],
37
+ url,
38
+ shapeData
39
39
  } = shape;
40
- const url = getEntityUrl(displayItems, entity, entityData);
41
40
 
42
41
  if (enableInfoPane) {
43
42
  const infoWindow = new window.google.maps.InfoWindow({
44
43
  content: ''
45
44
  });
46
- shapeInstance.addListener(CLICK, event => {
45
+ shapeInstance.addListener(CLICK, async event => {
47
46
  closeInfoWindows();
48
- const content = ReactDOMServer.renderToString(InfoWindowContent(entityData, imageData, displayItems, dataSummaries, url));
47
+ const content = ReactDOMServer.renderToString(await infoWindowContent(imageData, dataSummaries, url, shapeData));
49
48
  infoWindow.setContent(content);
50
49
  infoWindow.setPosition(event.latLng);
51
50
  infoWindow.open(map, shapeInstance);
@@ -86,47 +85,17 @@ const areRectangleBoundsNumbers = bounds => bounds.every(bound => isNumber(bound
86
85
 
87
86
  const isPositionCorrect = (lat, lng) => isNumber(lat) && isNumber(lng);
88
87
 
89
- const getEntityUrl = (displayItems, entity, entityData) => {
90
- let url = '';
91
-
92
- if (entity && displayItems) {
93
- const [entityId] = displayItems;
94
- const [entityRecord] = entityData.filter(({
95
- id
96
- }) => id === entityId);
97
-
98
- if (entityRecord) {
99
- ({
100
- url = ''
101
- } = entityRecord);
102
- }
103
- }
104
-
105
- return url;
106
- };
107
-
108
- const getImageUrl = (imageData, imageId) => {
109
- const [image] = imageData.getFiles.filter(({
88
+ const getIconUrl = (imageId, imageData) => {
89
+ if (!imageId) return '';
90
+ const image = imageData.find(({
110
91
  id
111
92
  }) => id === imageId);
112
- if (image) return image.url;
113
- return '';
93
+ if (!image || !image.url) return '';
94
+ return image.url;
114
95
  };
115
96
 
116
- const getIconUrl = (shape, imageData) => {
117
- const {
118
- imageId
119
- } = shape;
120
- if (!imageData.getFiles) return '';
121
- return imageId ? getImageUrl(imageData, imageId) : '';
122
- };
123
-
124
- const InfoWindowContent = (entityData, imageData, displayItems, dataSummaries, url) => {
125
- const [entityId] = displayItems;
126
- const [entityRecordData] = entityData.filter(({
127
- id
128
- }) => id === entityId);
129
- const summariesWithContent = dataSummaries.map(dataSummary => {
97
+ const infoWindowContent = async (imageData, dataSummaries, url, shapeData) => {
98
+ const summariesWithContent = await Promise.all(dataSummaries.map(async dataSummary => {
130
99
  const {
131
100
  elementTitle,
132
101
  type,
@@ -135,13 +104,12 @@ const InfoWindowContent = (entityData, imageData, displayItems, dataSummaries, u
135
104
  otherProps = _objectWithoutProperties(dataSummary, _excluded);
136
105
 
137
106
  const isTypeHeading = type === HEADING_LARGE;
138
- const summaryPropsWithContent = buildPropsToDisplayWithContent(entityRecordData, propsToDisplay);
107
+ const summaryPropsWithContent = buildPropsToDisplayWithContent(shapeData, propsToDisplay);
139
108
  const modifier = getClassModifiers(LIST, otherProps);
140
109
  const SummaryComponent = summaryComponents[type];
110
+ await SummaryComponent.render.preload(); // preload dynamic nextjs component
141
111
 
142
- if (!summaryPropsWithContent.length) {
143
- return null;
144
- }
112
+ if (!summaryPropsWithContent.length) return null;
145
113
 
146
114
  const getDataSummaryComponent = () => {
147
115
  const component = /*#__PURE__*/React.createElement(SummaryComponent, {
@@ -157,12 +125,11 @@ const InfoWindowContent = (entityData, imageData, displayItems, dataSummaries, u
157
125
  };
158
126
 
159
127
  return getDataSummaryComponent();
160
- });
161
- let image = {};
128
+ }));
162
129
  const {
163
130
  imageId
164
- } = entityRecordData || {};
165
- if (imageId) [image] = imageData.getFiles.filter(({
131
+ } = shapeData || {};
132
+ const image = imageData.find(({
166
133
  id
167
134
  }) => id === imageId);
168
135
  const shouldShowImage = image && image.url;
@@ -186,19 +153,18 @@ const InfoWindowContent = (entityData, imageData, displayItems, dataSummaries, u
186
153
  return /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowImage && getImageElement(), summariesWithContent);
187
154
  };
188
155
 
189
- const setMarker = (map, router, shape, data, imageData) => {
156
+ const setMarker = (map, router, shape, imageData) => {
190
157
  const {
191
- latitude,
192
- longitude,
193
- entity,
194
158
  label = '',
195
159
  markerWidth = 50,
196
- markerHeight = 50
160
+ markerHeight = 50,
161
+ latitude,
162
+ longitude,
163
+ imageId
197
164
  } = shape;
198
165
 
199
166
  if (isPositionCorrect(latitude, longitude)) {
200
- const entityData = entity ? data[entity] || [] : [];
201
- const iconUrl = getIconUrl(shape, imageData);
167
+ const iconUrl = getIconUrl(imageId, imageData);
202
168
  const icon = iconUrl ? {
203
169
  url: iconUrl,
204
170
  scaledSize: new window.google.maps.Size(markerWidth || 50, markerHeight || 50)
@@ -212,60 +178,54 @@ const setMarker = (map, router, shape, data, imageData) => {
212
178
  icon,
213
179
  title: label || ''
214
180
  });
215
- addShapeListeners(map, router, shape, entityData, imageData, marker);
181
+ addShapeListeners(map, router, shape, imageData, marker);
216
182
  shapesArray.push(marker);
217
183
  marker.setMap(map);
218
184
  }
219
185
  };
220
186
 
221
- const setPolyline = (map, router, shape, data, imageData) => {
187
+ const setPolyline = (map, router, shape, imageData) => {
222
188
  const {
223
- paths,
224
- entity
189
+ paths
225
190
  } = shape;
226
191
  const path = getPath(paths);
227
192
 
228
193
  if (path.length) {
229
- const entityData = entity ? data[entity] || [] : [];
230
194
  const polyline = new window.google.maps.Polyline(_objectSpread({
231
195
  path,
232
196
  geodesic: true
233
197
  }, setStyleOptions(shape)));
234
- addShapeListeners(map, router, shape, entityData, imageData, polyline);
198
+ addShapeListeners(map, router, shape, imageData, polyline);
235
199
  shapesArray.push(polyline);
236
200
  polyline.setMap(map);
237
201
  }
238
202
  };
239
203
 
240
- const setPolygon = (map, router, shape, data, imageData) => {
204
+ const setPolygon = (map, router, shape, imageData) => {
241
205
  const {
242
- paths: unParsedPaths,
243
- entity
206
+ paths: unParsedPaths
244
207
  } = shape;
245
208
  const paths = getPath(unParsedPaths);
246
209
 
247
210
  if (paths.length) {
248
- const entityData = entity ? data[entity] || [] : [];
249
211
  const polygon = new window.google.maps.Polygon(_objectSpread({
250
212
  paths
251
213
  }, setStyleOptions(shape)));
252
- addShapeListeners(map, router, shape, entityData, imageData, polygon);
214
+ addShapeListeners(map, router, shape, imageData, polygon);
253
215
  shapesArray.push(polygon);
254
216
  polygon.setMap(map);
255
217
  }
256
218
  };
257
219
 
258
- const setRectangle = (map, router, shape, data, imageData) => {
220
+ const setRectangle = (map, router, shape, imageData) => {
259
221
  const {
260
222
  northBound,
261
223
  southBound,
262
224
  eastBound,
263
- westBound,
264
- entity
225
+ westBound
265
226
  } = shape;
266
227
 
267
228
  if (areRectangleBoundsNumbers([northBound, southBound, eastBound, westBound])) {
268
- const entityData = entity ? data[entity] || [] : [];
269
229
  const rectangle = new window.google.maps.Rectangle(_objectSpread(_objectSpread({}, setStyleOptions(shape)), {}, {
270
230
  map,
271
231
  bounds: {
@@ -275,22 +235,20 @@ const setRectangle = (map, router, shape, data, imageData) => {
275
235
  west: westBound
276
236
  }
277
237
  }));
278
- addShapeListeners(map, router, shape, entityData, imageData, rectangle);
238
+ addShapeListeners(map, router, shape, imageData, rectangle);
279
239
  shapesArray.push(rectangle);
280
240
  rectangle.setMap(map);
281
241
  }
282
242
  };
283
243
 
284
- const setCircle = (map, router, shape, data, imageData) => {
244
+ const setCircle = (map, router, shape, imageData) => {
285
245
  const {
286
246
  latitude,
287
247
  longitude,
288
- radius,
289
- entity
248
+ radius
290
249
  } = shape;
291
250
 
292
251
  if (isPositionCorrect(latitude, longitude) && isNumber(radius)) {
293
- const entityData = entity ? data[entity] || [] : [];
294
252
  const circle = new window.google.maps.Circle(_objectSpread(_objectSpread({}, setStyleOptions(shape)), {}, {
295
253
  map,
296
254
  center: {
@@ -299,62 +257,59 @@ const setCircle = (map, router, shape, data, imageData) => {
299
257
  },
300
258
  radius
301
259
  }));
302
- addShapeListeners(map, router, shape, entityData, imageData, circle);
260
+ addShapeListeners(map, router, shape, imageData, circle);
303
261
  shapesArray.push(circle);
304
262
  circle.setMap(map);
305
263
  }
306
264
  };
307
265
 
308
- const setShapes = (map, router, shapes, data, imageData) => {
266
+ const setShapes = (map, router, shapes, imageData) => {
309
267
  const mapZoom = map.getZoom();
310
268
  clearShapes();
269
+ shapes.forEach(shape => {
270
+ const {
271
+ type,
272
+ minZoom,
273
+ maxZoom
274
+ } = shape;
275
+
276
+ if (mapZoom >= minZoom && mapZoom <= maxZoom) {
277
+ switch (type) {
278
+ case MARKER:
279
+ {
280
+ setMarker(map, router, shape, imageData);
281
+ break;
282
+ }
283
+
284
+ case POLYLINE:
285
+ {
286
+ setPolyline(map, router, shape, imageData);
287
+ break;
288
+ }
311
289
 
312
- if (shapes.length) {
313
- shapes.forEach(shape => {
314
- const {
315
- type: shapeType,
316
- minZoom,
317
- maxZoom
318
- } = shape;
319
-
320
- if (mapZoom >= minZoom && mapZoom <= maxZoom) {
321
- switch (shapeType) {
322
- case MARKER:
323
- {
324
- setMarker(map, router, shape, data, imageData);
325
- break;
326
- }
327
-
328
- case POLYLINE:
329
- {
330
- setPolyline(map, router, shape, data, imageData);
331
- break;
332
- }
333
-
334
- case POLYGON:
335
- {
336
- setPolygon(map, router, shape, data, imageData);
337
- break;
338
- }
339
-
340
- case RECTANGLE:
341
- {
342
- setRectangle(map, router, shape, data, imageData);
343
- break;
344
- }
345
-
346
- case CIRCLE:
347
- {
348
- setCircle(map, router, shape, data, imageData);
349
- break;
350
- }
351
-
352
- default:
290
+ case POLYGON:
291
+ {
292
+ setPolygon(map, router, shape, imageData);
353
293
  break;
354
- }
294
+ }
295
+
296
+ case RECTANGLE:
297
+ {
298
+ setRectangle(map, router, shape, imageData);
299
+ break;
300
+ }
301
+
302
+ case CIRCLE:
303
+ {
304
+ setCircle(map, router, shape, imageData);
305
+ break;
306
+ }
307
+
308
+ default:
309
+ break;
355
310
  }
356
- });
357
- }
311
+ }
312
+ });
358
313
  };
359
314
 
360
315
  export default setShapes;