@blaze-cms/plugin-google-maps-fe 0.123.0-alpha.24 → 0.123.0-alpha.28

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 +27 -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 +87 -153
  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 +76 -123
  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 +4 -4
  55. package/src/GoogleMaps/GoogleMaps.js +40 -27
  56. package/src/GoogleMaps/GoogleMapsFactory.js +11 -4
  57. package/src/GoogleMaps/GoogleMapsRender.js +23 -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 +59 -99
  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
@@ -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,CAACC,QAAT,CAAkB,GAAlB,CAAJ,EAA4B;AAC1B,UAAM,CAACC,YAAD,EAAeC,YAAf,IAA+BH,QAAQ,CAACI,KAAT,CAAe,GAAf,CAArC;AACA,WAAQ,GAAEL,GAAI,IAAGG,YAAa,MAAKC,YAAa,IAAhD;AACD;;AACD,SAAQ,GAAEJ,GAAI,IAAGC,QAAS,EAA1B;AACD,CAPH,EAOK,EAPL,EAQGK,IARH,EADF;;AAWA,MAAMC,oBAAoB,GAAG,CAACC,UAAD,EAAaC,UAAb,KAA4B;AACvD,QAAM;AAAEX,IAAAA,UAAU,GAAG,EAAf;AAAmBY,IAAAA,iBAAiB,GAAG;AAAvC,MAA8CD,UAApD;AAEA,QAAM,CAACE,GAAD,IAAQC,MAAM,CAACC,IAAP,CAAYH,iBAAZ,EAA+BI,MAA/B,CAAsCC,IAA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,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,14 +30,13 @@ 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({
@@ -45,7 +44,7 @@ const addShapeListeners = (map, router, shape, entityData, imageData, shapeInsta
45
44
  });
46
45
  shapeInstance.addListener(CLICK, event => {
47
46
  closeInfoWindows();
48
- const content = ReactDOMServer.renderToString(InfoWindowContent(entityData, imageData, displayItems, dataSummaries, url));
47
+ const content = ReactDOMServer.renderToString(InfoWindowContent(imageData, dataSummaries, url, shapeData));
49
48
  infoWindow.setContent(content);
50
49
  infoWindow.setPosition(event.latLng);
51
50
  infoWindow.open(map, shapeInstance);
@@ -86,46 +85,16 @@ 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);
97
+ const InfoWindowContent = (imageData, dataSummaries, url, shapeData) => {
129
98
  const summariesWithContent = dataSummaries.map(dataSummary => {
130
99
  const {
131
100
  elementTitle,
@@ -135,13 +104,10 @@ 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];
141
-
142
- if (!summaryPropsWithContent.length) {
143
- return null;
144
- }
110
+ if (!summaryPropsWithContent.length) return null;
145
111
 
146
112
  const getDataSummaryComponent = () => {
147
113
  const component = /*#__PURE__*/React.createElement(SummaryComponent, {
@@ -158,11 +124,10 @@ const InfoWindowContent = (entityData, imageData, displayItems, dataSummaries, u
158
124
 
159
125
  return getDataSummaryComponent();
160
126
  });
161
- let image = {};
162
127
  const {
163
128
  imageId
164
- } = entityRecordData || {};
165
- if (imageId) [image] = imageData.getFiles.filter(({
129
+ } = shapeData || {};
130
+ const image = imageData.find(({
166
131
  id
167
132
  }) => id === imageId);
168
133
  const shouldShowImage = image && image.url;
@@ -186,19 +151,18 @@ const InfoWindowContent = (entityData, imageData, displayItems, dataSummaries, u
186
151
  return /*#__PURE__*/React.createElement(React.Fragment, null, shouldShowImage && getImageElement(), summariesWithContent);
187
152
  };
188
153
 
189
- const setMarker = (map, router, shape, data, imageData) => {
154
+ const setMarker = (map, router, shape, imageData) => {
190
155
  const {
191
- latitude,
192
- longitude,
193
- entity,
194
156
  label = '',
195
157
  markerWidth = 50,
196
- markerHeight = 50
158
+ markerHeight = 50,
159
+ latitude,
160
+ longitude,
161
+ imageId
197
162
  } = shape;
198
163
 
199
164
  if (isPositionCorrect(latitude, longitude)) {
200
- const entityData = entity ? data[entity] || [] : [];
201
- const iconUrl = getIconUrl(shape, imageData);
165
+ const iconUrl = getIconUrl(imageId, imageData);
202
166
  const icon = iconUrl ? {
203
167
  url: iconUrl,
204
168
  scaledSize: new window.google.maps.Size(markerWidth || 50, markerHeight || 50)
@@ -212,60 +176,54 @@ const setMarker = (map, router, shape, data, imageData) => {
212
176
  icon,
213
177
  title: label || ''
214
178
  });
215
- addShapeListeners(map, router, shape, entityData, imageData, marker);
179
+ addShapeListeners(map, router, shape, imageData, marker);
216
180
  shapesArray.push(marker);
217
181
  marker.setMap(map);
218
182
  }
219
183
  };
220
184
 
221
- const setPolyline = (map, router, shape, data, imageData) => {
185
+ const setPolyline = (map, router, shape, imageData) => {
222
186
  const {
223
- paths,
224
- entity
187
+ paths
225
188
  } = shape;
226
189
  const path = getPath(paths);
227
190
 
228
191
  if (path.length) {
229
- const entityData = entity ? data[entity] || [] : [];
230
192
  const polyline = new window.google.maps.Polyline(_objectSpread({
231
193
  path,
232
194
  geodesic: true
233
195
  }, setStyleOptions(shape)));
234
- addShapeListeners(map, router, shape, entityData, imageData, polyline);
196
+ addShapeListeners(map, router, shape, imageData, polyline);
235
197
  shapesArray.push(polyline);
236
198
  polyline.setMap(map);
237
199
  }
238
200
  };
239
201
 
240
- const setPolygon = (map, router, shape, data, imageData) => {
202
+ const setPolygon = (map, router, shape, imageData) => {
241
203
  const {
242
- paths: unParsedPaths,
243
- entity
204
+ paths: unParsedPaths
244
205
  } = shape;
245
206
  const paths = getPath(unParsedPaths);
246
207
 
247
208
  if (paths.length) {
248
- const entityData = entity ? data[entity] || [] : [];
249
209
  const polygon = new window.google.maps.Polygon(_objectSpread({
250
210
  paths
251
211
  }, setStyleOptions(shape)));
252
- addShapeListeners(map, router, shape, entityData, imageData, polygon);
212
+ addShapeListeners(map, router, shape, imageData, polygon);
253
213
  shapesArray.push(polygon);
254
214
  polygon.setMap(map);
255
215
  }
256
216
  };
257
217
 
258
- const setRectangle = (map, router, shape, data, imageData) => {
218
+ const setRectangle = (map, router, shape, imageData) => {
259
219
  const {
260
220
  northBound,
261
221
  southBound,
262
222
  eastBound,
263
- westBound,
264
- entity
223
+ westBound
265
224
  } = shape;
266
225
 
267
226
  if (areRectangleBoundsNumbers([northBound, southBound, eastBound, westBound])) {
268
- const entityData = entity ? data[entity] || [] : [];
269
227
  const rectangle = new window.google.maps.Rectangle(_objectSpread(_objectSpread({}, setStyleOptions(shape)), {}, {
270
228
  map,
271
229
  bounds: {
@@ -275,22 +233,20 @@ const setRectangle = (map, router, shape, data, imageData) => {
275
233
  west: westBound
276
234
  }
277
235
  }));
278
- addShapeListeners(map, router, shape, entityData, imageData, rectangle);
236
+ addShapeListeners(map, router, shape, imageData, rectangle);
279
237
  shapesArray.push(rectangle);
280
238
  rectangle.setMap(map);
281
239
  }
282
240
  };
283
241
 
284
- const setCircle = (map, router, shape, data, imageData) => {
242
+ const setCircle = (map, router, shape, imageData) => {
285
243
  const {
286
244
  latitude,
287
245
  longitude,
288
- radius,
289
- entity
246
+ radius
290
247
  } = shape;
291
248
 
292
249
  if (isPositionCorrect(latitude, longitude) && isNumber(radius)) {
293
- const entityData = entity ? data[entity] || [] : [];
294
250
  const circle = new window.google.maps.Circle(_objectSpread(_objectSpread({}, setStyleOptions(shape)), {}, {
295
251
  map,
296
252
  center: {
@@ -299,62 +255,59 @@ const setCircle = (map, router, shape, data, imageData) => {
299
255
  },
300
256
  radius
301
257
  }));
302
- addShapeListeners(map, router, shape, entityData, imageData, circle);
258
+ addShapeListeners(map, router, shape, imageData, circle);
303
259
  shapesArray.push(circle);
304
260
  circle.setMap(map);
305
261
  }
306
262
  };
307
263
 
308
- const setShapes = (map, router, shapes, data, imageData) => {
264
+ const setShapes = (map, router, shapes, imageData) => {
309
265
  const mapZoom = map.getZoom();
310
266
  clearShapes();
267
+ shapes.forEach(shape => {
268
+ const {
269
+ type,
270
+ minZoom,
271
+ maxZoom
272
+ } = shape;
273
+
274
+ if (mapZoom >= minZoom && mapZoom <= maxZoom) {
275
+ switch (type) {
276
+ case MARKER:
277
+ {
278
+ setMarker(map, router, shape, imageData);
279
+ break;
280
+ }
281
+
282
+ case POLYLINE:
283
+ {
284
+ setPolyline(map, router, shape, imageData);
285
+ break;
286
+ }
311
287
 
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:
288
+ case POLYGON:
289
+ {
290
+ setPolygon(map, router, shape, imageData);
353
291
  break;
354
- }
292
+ }
293
+
294
+ case RECTANGLE:
295
+ {
296
+ setRectangle(map, router, shape, imageData);
297
+ break;
298
+ }
299
+
300
+ case CIRCLE:
301
+ {
302
+ setCircle(map, router, shape, imageData);
303
+ break;
304
+ }
305
+
306
+ default:
307
+ break;
355
308
  }
356
- });
357
- }
309
+ }
310
+ });
358
311
  };
359
312
 
360
313
  export default setShapes;