@blaze-cms/plugin-google-maps-fe 0.123.0-alpha.27 → 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.
- package/CHANGELOG.md +11 -0
- package/lib/GoogleMaps/GoogleMaps.js +68 -40
- package/lib/GoogleMaps/GoogleMaps.js.map +1 -1
- package/lib/GoogleMaps/GoogleMapsFactory.js +8 -4
- package/lib/GoogleMaps/GoogleMapsFactory.js.map +1 -1
- package/lib/GoogleMaps/GoogleMapsRender.js +24 -41
- package/lib/GoogleMaps/GoogleMapsRender.js.map +1 -1
- package/lib/GoogleMaps/helpers/add-zoom-listener.js +3 -50
- package/lib/GoogleMaps/helpers/add-zoom-listener.js.map +1 -1
- package/lib/GoogleMaps/helpers/build-map-shapes.js +97 -0
- package/lib/GoogleMaps/helpers/build-map-shapes.js.map +1 -0
- package/lib/GoogleMaps/helpers/build-query.js +24 -14
- package/lib/GoogleMaps/helpers/build-query.js.map +1 -1
- package/lib/GoogleMaps/helpers/build-shapes-configs.js +196 -0
- package/lib/GoogleMaps/helpers/build-shapes-configs.js.map +1 -0
- package/lib/GoogleMaps/helpers/get-center-coordinates.js +49 -0
- package/lib/GoogleMaps/helpers/get-center-coordinates.js.map +1 -0
- package/lib/GoogleMaps/helpers/get-image-ids.js +16 -14
- package/lib/GoogleMaps/helpers/get-image-ids.js.map +1 -1
- package/lib/GoogleMaps/helpers/index.js +21 -5
- package/lib/GoogleMaps/helpers/index.js.map +1 -1
- package/lib/GoogleMaps/helpers/set-shapes.js +87 -153
- package/lib/GoogleMaps/helpers/set-shapes.js.map +1 -1
- package/lib/GoogleMaps/hooks/use-get-images.js +3 -2
- package/lib/GoogleMaps/hooks/use-get-images.js.map +1 -1
- package/lib/GoogleMaps/queries.js +22 -4
- package/lib/GoogleMaps/queries.js.map +1 -1
- package/lib-es/GoogleMaps/GoogleMaps.js +51 -25
- package/lib-es/GoogleMaps/GoogleMaps.js.map +1 -1
- package/lib-es/GoogleMaps/GoogleMapsFactory.js +10 -6
- package/lib-es/GoogleMaps/GoogleMapsFactory.js.map +1 -1
- package/lib-es/GoogleMaps/GoogleMapsRender.js +24 -32
- package/lib-es/GoogleMaps/GoogleMapsRender.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/add-zoom-listener.js +3 -23
- package/lib-es/GoogleMaps/helpers/add-zoom-listener.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/build-map-shapes.js +86 -0
- package/lib-es/GoogleMaps/helpers/build-map-shapes.js.map +1 -0
- package/lib-es/GoogleMaps/helpers/build-query.js +17 -8
- package/lib-es/GoogleMaps/helpers/build-query.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/build-shapes-configs.js +134 -0
- package/lib-es/GoogleMaps/helpers/build-shapes-configs.js.map +1 -0
- package/lib-es/GoogleMaps/helpers/get-center-coordinates.js +31 -0
- package/lib-es/GoogleMaps/helpers/get-center-coordinates.js.map +1 -0
- package/lib-es/GoogleMaps/helpers/get-image-ids.js +9 -14
- package/lib-es/GoogleMaps/helpers/get-image-ids.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/index.js +4 -2
- package/lib-es/GoogleMaps/helpers/index.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/set-shapes.js +76 -123
- package/lib-es/GoogleMaps/helpers/set-shapes.js.map +1 -1
- package/lib-es/GoogleMaps/hooks/use-get-images.js +4 -3
- package/lib-es/GoogleMaps/hooks/use-get-images.js.map +1 -1
- package/lib-es/GoogleMaps/queries.js +23 -2
- package/lib-es/GoogleMaps/queries.js.map +1 -1
- package/package.json +2 -2
- package/src/GoogleMaps/GoogleMaps.js +40 -27
- package/src/GoogleMaps/GoogleMapsFactory.js +11 -4
- package/src/GoogleMaps/GoogleMapsRender.js +23 -21
- package/src/GoogleMaps/helpers/add-zoom-listener.js +3 -22
- package/src/GoogleMaps/helpers/build-map-shapes.js +70 -0
- package/src/GoogleMaps/helpers/build-query.js +25 -10
- package/src/GoogleMaps/helpers/build-shapes-configs.js +110 -0
- package/src/GoogleMaps/helpers/get-center-coordinates.js +24 -0
- package/src/GoogleMaps/helpers/get-image-ids.js +6 -15
- package/src/GoogleMaps/helpers/index.js +12 -2
- package/src/GoogleMaps/helpers/set-shapes.js +59 -99
- package/src/GoogleMaps/hooks/use-get-images.js +4 -3
- package/src/GoogleMaps/queries.js +30 -3
- package/lib/GoogleMaps/helpers/set-entity-configs.js +0 -144
- package/lib/GoogleMaps/helpers/set-entity-configs.js.map +0 -1
- package/lib-es/GoogleMaps/helpers/set-entity-configs.js +0 -94
- package/lib-es/GoogleMaps/helpers/set-entity-configs.js.map +0 -1
- package/src/GoogleMaps/helpers/set-entity-configs.js +0 -84
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import flatten from 'lodash.flatten';
|
|
2
|
+
import { IMAGE_ID, URL, ID } from '../../constants';
|
|
3
|
+
|
|
4
|
+
const getPropValues = properties =>
|
|
5
|
+
properties
|
|
6
|
+
.reduce((acc, property) => {
|
|
7
|
+
if (property.includes('.')) {
|
|
8
|
+
const [relationName, relationProp] = property.split('.');
|
|
9
|
+
return `${acc} ${relationName} { ${relationProp} }`;
|
|
10
|
+
}
|
|
11
|
+
return `${acc} ${property}`;
|
|
12
|
+
}, '')
|
|
13
|
+
.trim();
|
|
14
|
+
|
|
15
|
+
const getUpdatedPropsQuery = (propsQuery, entityData) => {
|
|
16
|
+
const { properties = {}, dynamicProperties = {} } = entityData;
|
|
17
|
+
|
|
18
|
+
const [url] = Object.keys(dynamicProperties).filter(prop => prop === URL);
|
|
19
|
+
const hasImage = !!Object.keys(properties).filter(prop => prop === IMAGE_ID).length;
|
|
20
|
+
|
|
21
|
+
let updatedPropsQuery = hasImage ? `${propsQuery} ${IMAGE_ID}` : propsQuery;
|
|
22
|
+
updatedPropsQuery = url ? `${updatedPropsQuery} ${URL}` : updatedPropsQuery;
|
|
23
|
+
|
|
24
|
+
return updatedPropsQuery;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const buildFilterQueryString = filter => {
|
|
28
|
+
const [filterKey, filterValue] = filter.split('/');
|
|
29
|
+
const filterKeyword = `${filterKey}.keyword`;
|
|
30
|
+
return { bool: { should: [{ match: { [filterKeyword]: filterValue } }] } };
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const buildFilters = filters => {
|
|
34
|
+
if (!filters || !filters.length) return null;
|
|
35
|
+
const filterQueryProps = filters.map(buildFilterQueryString);
|
|
36
|
+
return { bool: { should: filterQueryProps } };
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const buiildShapeProps = (shape, shapeKey, dataSummaries, parentId, entityData, entityGroup) => {
|
|
40
|
+
const { displayItems = [], filterBy } = shape;
|
|
41
|
+
const { latProp, lonProp, entity } = entityGroup;
|
|
42
|
+
const { actions } = entityData;
|
|
43
|
+
const action = actions ? actions.getAllPublished || actions.getAll : '';
|
|
44
|
+
|
|
45
|
+
const dataSummaryProps = dataSummaries
|
|
46
|
+
.reduce((acc, { propsToDisplay }) => {
|
|
47
|
+
const propsToDisplayValues = flatten(
|
|
48
|
+
propsToDisplay.map(({ propertiesToDisplay }) => propertiesToDisplay)
|
|
49
|
+
);
|
|
50
|
+
const propsToDisplayString = getPropValues(propsToDisplayValues);
|
|
51
|
+
|
|
52
|
+
return `${acc} ${propsToDisplayString}`;
|
|
53
|
+
}, '')
|
|
54
|
+
.trim();
|
|
55
|
+
const ids = [];
|
|
56
|
+
displayItems.length ? ids.push(displayItems[0]) : ids.push(parentId);
|
|
57
|
+
|
|
58
|
+
const filtersObject = buildFilters(filterBy);
|
|
59
|
+
let propsQuery = dataSummaryProps ? `${dataSummaryProps}` : '';
|
|
60
|
+
propsQuery = getUpdatedPropsQuery(propsQuery, entityData);
|
|
61
|
+
if (latProp && lonProp) {
|
|
62
|
+
propsQuery = `${propsQuery} ${formatProp(latProp)} ${formatProp(lonProp)}`;
|
|
63
|
+
}
|
|
64
|
+
if (ids.length && !propsQuery.includes(ID)) propsQuery = `${propsQuery.trim()} ${ID}`;
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
shapeKey,
|
|
68
|
+
entity,
|
|
69
|
+
propsQuery,
|
|
70
|
+
ids,
|
|
71
|
+
action,
|
|
72
|
+
filtersObject
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const formatProp = prop => {
|
|
77
|
+
if (!prop.includes('.')) return prop;
|
|
78
|
+
|
|
79
|
+
const [mainProp, nestedProp] = prop.split('.');
|
|
80
|
+
return `${mainProp}{${nestedProp}}`;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const buildShapesConfig = (schemas, entityGroups, parent) => {
|
|
84
|
+
if (!schemas || !entityGroups) return [];
|
|
85
|
+
const { itemId, itemEntity } = parent;
|
|
86
|
+
const shapeGroups = [];
|
|
87
|
+
entityGroups.forEach((entityGroup, i) => {
|
|
88
|
+
const { entity, shapes, dataSummaries = [] } = entityGroup;
|
|
89
|
+
const parentId = entity === itemEntity && itemId;
|
|
90
|
+
if (!entity) return null;
|
|
91
|
+
const entityData = schemas[entity] || {};
|
|
92
|
+
|
|
93
|
+
shapes.filter(Boolean).forEach((shape, shapeIndex) => {
|
|
94
|
+
const shapeKey = `shape${i}${shapeIndex}`;
|
|
95
|
+
const shapeValues = buiildShapeProps(
|
|
96
|
+
shape,
|
|
97
|
+
shapeKey,
|
|
98
|
+
dataSummaries,
|
|
99
|
+
parentId,
|
|
100
|
+
entityData,
|
|
101
|
+
entityGroup
|
|
102
|
+
);
|
|
103
|
+
shapeGroups.push({ ...shapeValues, shapeOptions: shape, entityOptions: entityGroup });
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
return shapeGroups;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default buildShapesConfig;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import isNumber from 'lodash.isnumber';
|
|
2
|
+
|
|
3
|
+
const getCenterCoordinates = (mapShapes, otherProps) => {
|
|
4
|
+
const centerCoordinates = [];
|
|
5
|
+
|
|
6
|
+
const { centerLatitude, centerLongitude } = otherProps;
|
|
7
|
+
const useDefaultCenter =
|
|
8
|
+
centerLatitude !== 0 &&
|
|
9
|
+
centerLongitude !== 0 &&
|
|
10
|
+
isNumber(centerLatitude) &&
|
|
11
|
+
isNumber(centerLongitude);
|
|
12
|
+
|
|
13
|
+
if (useDefaultCenter) return [{ latitude: centerLatitude, longitude: centerLongitude }];
|
|
14
|
+
|
|
15
|
+
const useAsCenterShapes = mapShapes.filter(({ useAsCenter }) => useAsCenter);
|
|
16
|
+
const shapesForCenter = useAsCenterShapes.length ? useAsCenterShapes : mapShapes;
|
|
17
|
+
shapesForCenter.forEach(({ latitude, longitude }) => {
|
|
18
|
+
if (isNumber(latitude) && isNumber(longitude)) centerCoordinates.push({ latitude, longitude });
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return centerCoordinates;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default getCenterCoordinates;
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
const getImageIds =
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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(({ shapeData, imageId }) => {
|
|
4
|
+
if (imageId) ids.push(imageId);
|
|
5
|
+
if (shapeData.imageId) ids.push(shapeData.imageId);
|
|
14
6
|
});
|
|
15
|
-
|
|
16
|
-
return images;
|
|
7
|
+
return [...new Set(ids)];
|
|
17
8
|
};
|
|
18
9
|
|
|
19
10
|
export default getImageIds;
|
|
@@ -1,7 +1,17 @@
|
|
|
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
|
|
4
|
+
import buildShapesConfig from './build-shapes-configs';
|
|
5
5
|
import setMapOptions from './set-map-options';
|
|
6
|
+
import getCenterCoordinates from './get-center-coordinates';
|
|
7
|
+
import buildMapShapes from './build-map-shapes';
|
|
6
8
|
|
|
7
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
addZoomListener,
|
|
11
|
+
buildQuery,
|
|
12
|
+
getImageIds,
|
|
13
|
+
buildShapesConfig,
|
|
14
|
+
setMapOptions,
|
|
15
|
+
getCenterCoordinates,
|
|
16
|
+
buildMapShapes
|
|
17
|
+
};
|
|
@@ -37,10 +37,8 @@ const closeInfoWindows = () => {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const addShapeListeners = (map, router, shape,
|
|
41
|
-
const {
|
|
42
|
-
|
|
43
|
-
const url = getEntityUrl(displayItems, entity, entityData);
|
|
40
|
+
const addShapeListeners = (map, router, shape, imageData, shapeInstance) => {
|
|
41
|
+
const { enableInfoPane = false, dataSummaries = [], url, shapeData } = shape;
|
|
44
42
|
|
|
45
43
|
if (enableInfoPane) {
|
|
46
44
|
const infoWindow = new window.google.maps.InfoWindow({
|
|
@@ -50,7 +48,7 @@ const addShapeListeners = (map, router, shape, entityData, imageData, shapeInsta
|
|
|
50
48
|
shapeInstance.addListener(CLICK, event => {
|
|
51
49
|
closeInfoWindows();
|
|
52
50
|
const content = ReactDOMServer.renderToString(
|
|
53
|
-
InfoWindowContent(
|
|
51
|
+
InfoWindowContent(imageData, dataSummaries, url, shapeData)
|
|
54
52
|
);
|
|
55
53
|
infoWindow.setContent(content);
|
|
56
54
|
infoWindow.setPosition(event.latLng);
|
|
@@ -83,51 +81,22 @@ const areRectangleBoundsNumbers = bounds => bounds.every(bound => isNumber(bound
|
|
|
83
81
|
|
|
84
82
|
const isPositionCorrect = (lat, lng) => isNumber(lat) && isNumber(lng);
|
|
85
83
|
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (
|
|
90
|
-
const [entityId] = displayItems;
|
|
91
|
-
const [entityRecord] = entityData.filter(({ id }) => id === entityId);
|
|
92
|
-
if (entityRecord) {
|
|
93
|
-
({ url = '' } = entityRecord);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return url;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const getImageUrl = (imageData, imageId) => {
|
|
101
|
-
const [image] = imageData.getFiles.filter(({ id }) => id === imageId);
|
|
102
|
-
if (image) return image.url;
|
|
84
|
+
const getIconUrl = (imageId, imageData) => {
|
|
85
|
+
if (!imageId) return '';
|
|
86
|
+
const image = imageData.find(({ id }) => id === imageId);
|
|
87
|
+
if (!image || !image.url) return '';
|
|
103
88
|
|
|
104
|
-
return
|
|
89
|
+
return image.url;
|
|
105
90
|
};
|
|
106
91
|
|
|
107
|
-
const
|
|
108
|
-
const { imageId } = shape;
|
|
109
|
-
|
|
110
|
-
if (!imageData.getFiles) return '';
|
|
111
|
-
|
|
112
|
-
return imageId ? getImageUrl(imageData, imageId) : '';
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const InfoWindowContent = (entityData, imageData, displayItems, dataSummaries, url) => {
|
|
116
|
-
const [entityId] = displayItems;
|
|
117
|
-
const [entityRecordData] = entityData.filter(({ id }) => id === entityId);
|
|
118
|
-
|
|
92
|
+
const InfoWindowContent = (imageData, dataSummaries, url, shapeData) => {
|
|
119
93
|
const summariesWithContent = dataSummaries.map(dataSummary => {
|
|
120
94
|
const { elementTitle, type, propsToDisplay, ...otherProps } = dataSummary;
|
|
121
95
|
const isTypeHeading = type === HEADING_LARGE;
|
|
122
|
-
const summaryPropsWithContent = buildPropsToDisplayWithContent(
|
|
123
|
-
entityRecordData,
|
|
124
|
-
propsToDisplay
|
|
125
|
-
);
|
|
96
|
+
const summaryPropsWithContent = buildPropsToDisplayWithContent(shapeData, propsToDisplay);
|
|
126
97
|
const modifier = getClassModifiers(LIST, otherProps);
|
|
127
98
|
const SummaryComponent = summaryComponents[type];
|
|
128
|
-
if (!summaryPropsWithContent.length)
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
99
|
+
if (!summaryPropsWithContent.length) return null;
|
|
131
100
|
|
|
132
101
|
const getDataSummaryComponent = () => {
|
|
133
102
|
const component = (
|
|
@@ -146,10 +115,8 @@ const InfoWindowContent = (entityData, imageData, displayItems, dataSummaries, u
|
|
|
146
115
|
|
|
147
116
|
return getDataSummaryComponent();
|
|
148
117
|
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const { imageId } = entityRecordData || {};
|
|
152
|
-
if (imageId) [image] = imageData.getFiles.filter(({ id }) => id === imageId);
|
|
118
|
+
const { imageId } = shapeData || {};
|
|
119
|
+
const image = imageData.find(({ id }) => id === imageId);
|
|
153
120
|
const shouldShowImage = image && image.url;
|
|
154
121
|
|
|
155
122
|
const getImageElement = () => {
|
|
@@ -171,12 +138,11 @@ const InfoWindowContent = (entityData, imageData, displayItems, dataSummaries, u
|
|
|
171
138
|
);
|
|
172
139
|
};
|
|
173
140
|
|
|
174
|
-
const setMarker = (map, router, shape,
|
|
175
|
-
const {
|
|
176
|
-
if (isPositionCorrect(latitude, longitude)) {
|
|
177
|
-
const entityData = entity ? data[entity] || [] : [];
|
|
141
|
+
const setMarker = (map, router, shape, imageData) => {
|
|
142
|
+
const { label = '', markerWidth = 50, markerHeight = 50, latitude, longitude, imageId } = shape;
|
|
178
143
|
|
|
179
|
-
|
|
144
|
+
if (isPositionCorrect(latitude, longitude)) {
|
|
145
|
+
const iconUrl = getIconUrl(imageId, imageData);
|
|
180
146
|
|
|
181
147
|
const icon = iconUrl
|
|
182
148
|
? {
|
|
@@ -192,7 +158,7 @@ const setMarker = (map, router, shape, data, imageData) => {
|
|
|
192
158
|
title: label || ''
|
|
193
159
|
});
|
|
194
160
|
|
|
195
|
-
addShapeListeners(map, router, shape,
|
|
161
|
+
addShapeListeners(map, router, shape, imageData, marker);
|
|
196
162
|
|
|
197
163
|
shapesArray.push(marker);
|
|
198
164
|
|
|
@@ -200,19 +166,18 @@ const setMarker = (map, router, shape, data, imageData) => {
|
|
|
200
166
|
}
|
|
201
167
|
};
|
|
202
168
|
|
|
203
|
-
const setPolyline = (map, router, shape,
|
|
204
|
-
const { paths
|
|
169
|
+
const setPolyline = (map, router, shape, imageData) => {
|
|
170
|
+
const { paths } = shape;
|
|
205
171
|
const path = getPath(paths);
|
|
206
172
|
|
|
207
173
|
if (path.length) {
|
|
208
|
-
const entityData = entity ? data[entity] || [] : [];
|
|
209
174
|
const polyline = new window.google.maps.Polyline({
|
|
210
175
|
path,
|
|
211
176
|
geodesic: true,
|
|
212
177
|
...setStyleOptions(shape)
|
|
213
178
|
});
|
|
214
179
|
|
|
215
|
-
addShapeListeners(map, router, shape,
|
|
180
|
+
addShapeListeners(map, router, shape, imageData, polyline);
|
|
216
181
|
|
|
217
182
|
shapesArray.push(polyline);
|
|
218
183
|
|
|
@@ -220,18 +185,17 @@ const setPolyline = (map, router, shape, data, imageData) => {
|
|
|
220
185
|
}
|
|
221
186
|
};
|
|
222
187
|
|
|
223
|
-
const setPolygon = (map, router, shape,
|
|
224
|
-
const { paths: unParsedPaths
|
|
188
|
+
const setPolygon = (map, router, shape, imageData) => {
|
|
189
|
+
const { paths: unParsedPaths } = shape;
|
|
225
190
|
const paths = getPath(unParsedPaths);
|
|
226
191
|
|
|
227
192
|
if (paths.length) {
|
|
228
|
-
const entityData = entity ? data[entity] || [] : [];
|
|
229
193
|
const polygon = new window.google.maps.Polygon({
|
|
230
194
|
paths,
|
|
231
195
|
...setStyleOptions(shape)
|
|
232
196
|
});
|
|
233
197
|
|
|
234
|
-
addShapeListeners(map, router, shape,
|
|
198
|
+
addShapeListeners(map, router, shape, imageData, polygon);
|
|
235
199
|
|
|
236
200
|
shapesArray.push(polygon);
|
|
237
201
|
|
|
@@ -239,10 +203,9 @@ const setPolygon = (map, router, shape, data, imageData) => {
|
|
|
239
203
|
}
|
|
240
204
|
};
|
|
241
205
|
|
|
242
|
-
const setRectangle = (map, router, shape,
|
|
243
|
-
const { northBound, southBound, eastBound, westBound
|
|
206
|
+
const setRectangle = (map, router, shape, imageData) => {
|
|
207
|
+
const { northBound, southBound, eastBound, westBound } = shape;
|
|
244
208
|
if (areRectangleBoundsNumbers([northBound, southBound, eastBound, westBound])) {
|
|
245
|
-
const entityData = entity ? data[entity] || [] : [];
|
|
246
209
|
const rectangle = new window.google.maps.Rectangle({
|
|
247
210
|
...setStyleOptions(shape),
|
|
248
211
|
map,
|
|
@@ -254,7 +217,7 @@ const setRectangle = (map, router, shape, data, imageData) => {
|
|
|
254
217
|
}
|
|
255
218
|
});
|
|
256
219
|
|
|
257
|
-
addShapeListeners(map, router, shape,
|
|
220
|
+
addShapeListeners(map, router, shape, imageData, rectangle);
|
|
258
221
|
|
|
259
222
|
shapesArray.push(rectangle);
|
|
260
223
|
|
|
@@ -262,10 +225,9 @@ const setRectangle = (map, router, shape, data, imageData) => {
|
|
|
262
225
|
}
|
|
263
226
|
};
|
|
264
227
|
|
|
265
|
-
const setCircle = (map, router, shape,
|
|
266
|
-
const { latitude, longitude, radius
|
|
228
|
+
const setCircle = (map, router, shape, imageData) => {
|
|
229
|
+
const { latitude, longitude, radius } = shape;
|
|
267
230
|
if (isPositionCorrect(latitude, longitude) && isNumber(radius)) {
|
|
268
|
-
const entityData = entity ? data[entity] || [] : [];
|
|
269
231
|
const circle = new window.google.maps.Circle({
|
|
270
232
|
...setStyleOptions(shape),
|
|
271
233
|
map,
|
|
@@ -273,7 +235,7 @@ const setCircle = (map, router, shape, data, imageData) => {
|
|
|
273
235
|
radius
|
|
274
236
|
});
|
|
275
237
|
|
|
276
|
-
addShapeListeners(map, router, shape,
|
|
238
|
+
addShapeListeners(map, router, shape, imageData, circle);
|
|
277
239
|
|
|
278
240
|
shapesArray.push(circle);
|
|
279
241
|
|
|
@@ -281,42 +243,40 @@ const setCircle = (map, router, shape, data, imageData) => {
|
|
|
281
243
|
}
|
|
282
244
|
};
|
|
283
245
|
|
|
284
|
-
const setShapes = (map, router, shapes,
|
|
246
|
+
const setShapes = (map, router, shapes, imageData) => {
|
|
285
247
|
const mapZoom = map.getZoom();
|
|
286
248
|
clearShapes();
|
|
287
249
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
break;
|
|
305
|
-
}
|
|
306
|
-
case RECTANGLE: {
|
|
307
|
-
setRectangle(map, router, shape, data, imageData);
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
case CIRCLE: {
|
|
311
|
-
setCircle(map, router, shape, data, imageData);
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
default:
|
|
315
|
-
break;
|
|
250
|
+
shapes.forEach(shape => {
|
|
251
|
+
const { type, minZoom, maxZoom } = shape;
|
|
252
|
+
|
|
253
|
+
if (mapZoom >= minZoom && mapZoom <= maxZoom) {
|
|
254
|
+
switch (type) {
|
|
255
|
+
case MARKER: {
|
|
256
|
+
setMarker(map, router, shape, imageData);
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
case POLYLINE: {
|
|
260
|
+
setPolyline(map, router, shape, imageData);
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
case POLYGON: {
|
|
264
|
+
setPolygon(map, router, shape, imageData);
|
|
265
|
+
break;
|
|
316
266
|
}
|
|
267
|
+
case RECTANGLE: {
|
|
268
|
+
setRectangle(map, router, shape, imageData);
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
case CIRCLE: {
|
|
272
|
+
setCircle(map, router, shape, imageData);
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
default:
|
|
276
|
+
break;
|
|
317
277
|
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
278
|
+
}
|
|
279
|
+
});
|
|
320
280
|
};
|
|
321
281
|
|
|
322
282
|
export default setShapes;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useQuery } from '@apollo/client';
|
|
2
|
-
import {
|
|
2
|
+
import { generateWhereQuery, generateQueryString } from '../queries';
|
|
3
3
|
|
|
4
4
|
const useGetImages = imageIds => {
|
|
5
5
|
const queryName = 'getFiles';
|
|
6
|
-
const action =
|
|
6
|
+
const action = generateWhereQuery(generateQueryString(queryName, queryName, 'id url data'));
|
|
7
7
|
const { data = {}, loading, error } = useQuery(action, {
|
|
8
|
-
variables: { where: { id: { _in: imageIds } } }
|
|
8
|
+
variables: { where: { id: { _in: imageIds } } },
|
|
9
|
+
skip: !imageIds || !imageIds.length
|
|
9
10
|
});
|
|
10
11
|
return { data, loading, error };
|
|
11
12
|
};
|
|
@@ -12,16 +12,43 @@ const GET_ENTITY_SCHEMAS = gql`
|
|
|
12
12
|
`;
|
|
13
13
|
|
|
14
14
|
const generateQuery = queryString => gql`
|
|
15
|
-
query getEntityData
|
|
15
|
+
query getEntityData {
|
|
16
16
|
${queryString}
|
|
17
17
|
}
|
|
18
18
|
`;
|
|
19
19
|
|
|
20
|
+
const generateWhereQuery = queryString => gql`
|
|
21
|
+
query getEntityData($where: JSON){
|
|
22
|
+
${queryString}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
20
25
|
const generateQueryString = (action, query, props) => `
|
|
21
26
|
${query}: ${action}(where: $where){
|
|
22
27
|
${props}
|
|
23
|
-
__typename
|
|
24
28
|
}
|
|
25
29
|
`;
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
const generateIdsQuery = (query, props, action, ids) => `
|
|
32
|
+
${query}: ${action}(where: { id: { _in: ${JSON.stringify(ids)} } }){
|
|
33
|
+
${props}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
const generateFiltersQuery = (query, props, rawQUery, filterQueryKey) => `
|
|
38
|
+
${query}: searchPublishedContent(rawQueryStringified: ${JSON.stringify(rawQUery)}){
|
|
39
|
+
results {
|
|
40
|
+
...on ${filterQueryKey} {
|
|
41
|
+
${props}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
GET_ENTITY_SCHEMAS,
|
|
49
|
+
generateQuery,
|
|
50
|
+
generateQueryString,
|
|
51
|
+
generateIdsQuery,
|
|
52
|
+
generateFiltersQuery,
|
|
53
|
+
generateWhereQuery
|
|
54
|
+
};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.object.define-property.js");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports["default"] = void 0;
|
|
11
|
-
|
|
12
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
-
|
|
14
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
-
|
|
16
|
-
require("core-js/modules/es.string.trim.js");
|
|
17
|
-
|
|
18
|
-
require("core-js/modules/es.array.reduce.js");
|
|
19
|
-
|
|
20
|
-
require("core-js/modules/es.object.to-string.js");
|
|
21
|
-
|
|
22
|
-
require("core-js/modules/es.array.includes.js");
|
|
23
|
-
|
|
24
|
-
require("core-js/modules/es.string.includes.js");
|
|
25
|
-
|
|
26
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
27
|
-
|
|
28
|
-
require("core-js/modules/es.string.split.js");
|
|
29
|
-
|
|
30
|
-
require("core-js/modules/es.array.concat.js");
|
|
31
|
-
|
|
32
|
-
require("core-js/modules/es.array.map.js");
|
|
33
|
-
|
|
34
|
-
require("core-js/modules/es.array.filter.js");
|
|
35
|
-
|
|
36
|
-
require("core-js/modules/es.object.keys.js");
|
|
37
|
-
|
|
38
|
-
var _lodash = _interopRequireDefault(require("lodash.flatten"));
|
|
39
|
-
|
|
40
|
-
var _constants = require("../../constants");
|
|
41
|
-
|
|
42
|
-
var getPropValues = function getPropValues(properties) {
|
|
43
|
-
return properties.reduce(function (acc, property) {
|
|
44
|
-
if (property.includes('.')) {
|
|
45
|
-
var _property$split = property.split('.'),
|
|
46
|
-
_property$split2 = (0, _slicedToArray2["default"])(_property$split, 2),
|
|
47
|
-
relationName = _property$split2[0],
|
|
48
|
-
relationProp = _property$split2[1];
|
|
49
|
-
|
|
50
|
-
return "".concat(acc, " ").concat(relationName, " { ").concat(relationProp, " }");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return "".concat(acc, " ").concat(property);
|
|
54
|
-
}, '').trim();
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
var buildEntityValues = function buildEntityValues(shapes, dataSummaries) {
|
|
58
|
-
var imageIds = [];
|
|
59
|
-
var dataSummaryProps = dataSummaries.reduce(function (acc, _ref) {
|
|
60
|
-
var propsToDisplay = _ref.propsToDisplay;
|
|
61
|
-
var propsToDisplayValues = (0, _lodash["default"])(propsToDisplay.map(function (_ref2) {
|
|
62
|
-
var propertiesToDisplay = _ref2.propertiesToDisplay;
|
|
63
|
-
return propertiesToDisplay;
|
|
64
|
-
}));
|
|
65
|
-
var propsToDisplayString = getPropValues(propsToDisplayValues);
|
|
66
|
-
return "".concat(acc, " ").concat(propsToDisplayString);
|
|
67
|
-
}, '').trim();
|
|
68
|
-
var propsQuery = dataSummaryProps ? "".concat(dataSummaryProps) : '';
|
|
69
|
-
var ids = shapes.reduce(function (accVal, _ref3) {
|
|
70
|
-
var imageId = _ref3.imageId,
|
|
71
|
-
displayItems = _ref3.displayItems;
|
|
72
|
-
if (displayItems && displayItems.length) accVal.push(displayItems[0]);
|
|
73
|
-
if (imageId) imageIds.push(imageId);
|
|
74
|
-
return accVal;
|
|
75
|
-
}, []);
|
|
76
|
-
return {
|
|
77
|
-
propsQuery: propsQuery,
|
|
78
|
-
ids: ids,
|
|
79
|
-
imageIds: imageIds
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
var getUpdatedPropsQuery = function getUpdatedPropsQuery(propsQuery, entityData) {
|
|
84
|
-
var _entityData$propertie = entityData.properties,
|
|
85
|
-
properties = _entityData$propertie === void 0 ? {} : _entityData$propertie,
|
|
86
|
-
_entityData$dynamicPr = entityData.dynamicProperties,
|
|
87
|
-
dynamicProperties = _entityData$dynamicPr === void 0 ? {} : _entityData$dynamicPr;
|
|
88
|
-
|
|
89
|
-
var _Object$keys$filter = Object.keys(dynamicProperties).filter(function (prop) {
|
|
90
|
-
return prop === _constants.URL;
|
|
91
|
-
}),
|
|
92
|
-
_Object$keys$filter2 = (0, _slicedToArray2["default"])(_Object$keys$filter, 1),
|
|
93
|
-
url = _Object$keys$filter2[0];
|
|
94
|
-
|
|
95
|
-
var hasImage = !!Object.keys(properties).filter(function (prop) {
|
|
96
|
-
return prop === _constants.IMAGE_ID;
|
|
97
|
-
}).length;
|
|
98
|
-
var updatedPropsQuery = hasImage ? "".concat(propsQuery, " ").concat(_constants.IMAGE_ID) : propsQuery;
|
|
99
|
-
updatedPropsQuery = url ? "".concat(updatedPropsQuery, " ").concat(_constants.URL) : updatedPropsQuery;
|
|
100
|
-
return updatedPropsQuery;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
var setEntityConfigs = function setEntityConfigs(schemas, entityGroups) {
|
|
104
|
-
if (!schemas) return {};
|
|
105
|
-
return entityGroups.reduce(function (acc, entityGroup) {
|
|
106
|
-
var entity = entityGroup.entity,
|
|
107
|
-
shapes = entityGroup.shapes,
|
|
108
|
-
_entityGroup$dataSumm = entityGroup.dataSummaries,
|
|
109
|
-
dataSummaries = _entityGroup$dataSumm === void 0 ? [] : _entityGroup$dataSumm;
|
|
110
|
-
|
|
111
|
-
if (entity) {
|
|
112
|
-
var entityData = schemas[entity] || {};
|
|
113
|
-
var actions = entityData.actions;
|
|
114
|
-
var action = actions ? actions.getAllPublished || actions.getAll : '';
|
|
115
|
-
|
|
116
|
-
var _buildEntityValues = buildEntityValues(shapes.filter(Boolean), dataSummaries),
|
|
117
|
-
propsQuery = _buildEntityValues.propsQuery,
|
|
118
|
-
ids = _buildEntityValues.ids,
|
|
119
|
-
imageIds = _buildEntityValues.imageIds;
|
|
120
|
-
|
|
121
|
-
propsQuery = getUpdatedPropsQuery(propsQuery, entityData);
|
|
122
|
-
|
|
123
|
-
if (acc[entity]) {
|
|
124
|
-
propsQuery = "".concat(acc[entity].propsQuery, " ").concat(propsQuery);
|
|
125
|
-
ids = [].concat((0, _toConsumableArray2["default"])(acc[entity].ids), (0, _toConsumableArray2["default"])(ids));
|
|
126
|
-
imageIds = [].concat((0, _toConsumableArray2["default"])(acc[entity].imageIds), (0, _toConsumableArray2["default"])(imageIds));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (ids.length && !propsQuery.includes(_constants.ID)) propsQuery = "".concat(propsQuery.trim(), " ").concat(_constants.ID);
|
|
130
|
-
acc[entity] = {
|
|
131
|
-
propsQuery: propsQuery,
|
|
132
|
-
ids: ids,
|
|
133
|
-
action: action,
|
|
134
|
-
imageIds: imageIds
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return acc;
|
|
139
|
-
}, {});
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
var _default = setEntityConfigs;
|
|
143
|
-
exports["default"] = _default;
|
|
144
|
-
//# sourceMappingURL=set-entity-configs.js.map
|