@blaze-cms/plugin-google-maps-fe 0.146.0-node18.1 → 0.146.0-rc-eagle-3.0
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 +3 -9
- package/lib/GoogleMaps/GoogleMaps.js +68 -90
- package/lib/GoogleMaps/GoogleMaps.js.map +1 -1
- package/lib/GoogleMaps/GoogleMapsFactory.js +21 -22
- package/lib/GoogleMaps/GoogleMapsFactory.js.map +1 -1
- package/lib/GoogleMaps/GoogleMapsHtml.js +9 -11
- package/lib/GoogleMaps/GoogleMapsHtml.js.map +1 -1
- package/lib/GoogleMaps/GoogleMapsRender.js +43 -37
- package/lib/GoogleMaps/GoogleMapsRender.js.map +1 -1
- package/lib/GoogleMaps/helpers/add-zoom-listener.js +5 -8
- package/lib/GoogleMaps/helpers/add-zoom-listener.js.map +1 -1
- package/lib/GoogleMaps/helpers/build-map-shapes.js +48 -48
- package/lib/GoogleMaps/helpers/build-map-shapes.js.map +1 -1
- package/lib/GoogleMaps/helpers/build-map-type-ids.js +4 -5
- package/lib/GoogleMaps/helpers/build-map-type-ids.js.map +1 -1
- package/lib/GoogleMaps/helpers/build-query.js +22 -28
- package/lib/GoogleMaps/helpers/build-query.js.map +1 -1
- package/lib/GoogleMaps/helpers/build-shapes-configs.js +84 -111
- package/lib/GoogleMaps/helpers/build-shapes-configs.js.map +1 -1
- package/lib/GoogleMaps/helpers/get-center-coordinates.js +20 -23
- package/lib/GoogleMaps/helpers/get-center-coordinates.js.map +1 -1
- package/lib/GoogleMaps/helpers/get-image-ids.js +9 -18
- package/lib/GoogleMaps/helpers/get-image-ids.js.map +1 -1
- package/lib/GoogleMaps/helpers/get-path.js +13 -16
- package/lib/GoogleMaps/helpers/get-path.js.map +1 -1
- package/lib/GoogleMaps/helpers/index.js +14 -15
- package/lib/GoogleMaps/helpers/index.js.map +1 -1
- package/lib/GoogleMaps/helpers/set-map-options.js +41 -44
- package/lib/GoogleMaps/helpers/set-map-options.js.map +1 -1
- package/lib/GoogleMaps/helpers/set-shapes.js +175 -245
- package/lib/GoogleMaps/helpers/set-shapes.js.map +1 -1
- package/lib/GoogleMaps/hooks/index.js +4 -5
- package/lib/GoogleMaps/hooks/index.js.map +1 -1
- package/lib/GoogleMaps/hooks/use-get-entity-schemas.js +14 -20
- package/lib/GoogleMaps/hooks/use-get-entity-schemas.js.map +1 -1
- package/lib/GoogleMaps/hooks/use-get-images.js +21 -22
- package/lib/GoogleMaps/hooks/use-get-images.js.map +1 -1
- package/lib/GoogleMaps/index.js +2 -3
- package/lib/GoogleMaps/index.js.map +1 -1
- package/lib/GoogleMaps/queries.js +49 -22
- package/lib/GoogleMaps/queries.js.map +1 -1
- package/lib/constants.js +35 -36
- package/lib/constants.js.map +1 -1
- package/lib/index.js +14 -43
- package/lib/index.js.map +1 -1
- package/lib-es/GoogleMaps/GoogleMaps.js +3 -1
- package/lib-es/GoogleMaps/GoogleMaps.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/add-zoom-listener.js +1 -1
- package/lib-es/GoogleMaps/helpers/add-zoom-listener.js.map +1 -1
- package/lib-es/GoogleMaps/helpers/build-query.js +3 -1
- package/lib-es/GoogleMaps/helpers/build-query.js.map +1 -1
- package/package.json +15 -10
- package/src/GoogleMaps/GoogleMaps.js +4 -1
- package/src/GoogleMaps/helpers/add-zoom-listener.js +1 -1
- package/src/GoogleMaps/helpers/build-query.js +3 -1
- package/babel.config.js +0 -3
- package/jest.config.js +0 -3
|
@@ -1,36 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
require("core-js/modules/es.array.filter.js");
|
|
5
|
-
require("core-js/modules/es.object.define-properties.js");
|
|
6
|
-
require("core-js/modules/es.object.define-property.js");
|
|
7
|
-
require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
8
|
-
require("core-js/modules/es.object.get-own-property-descriptors.js");
|
|
9
|
-
require("core-js/modules/es.weak-map.js");
|
|
10
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
11
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
12
4
|
Object.defineProperty(exports, "__esModule", {
|
|
13
5
|
value: true
|
|
14
6
|
});
|
|
15
|
-
exports
|
|
7
|
+
exports.default = void 0;
|
|
16
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
17
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
18
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
20
|
-
require("core-js/modules/es.array.every.js");
|
|
21
|
-
require("core-js/modules/es.array.find.js");
|
|
22
|
-
require("core-js/modules/es.array.for-each.js");
|
|
23
|
-
require("core-js/modules/es.array.includes.js");
|
|
24
|
-
require("core-js/modules/es.array.iterator.js");
|
|
25
|
-
require("core-js/modules/es.array.map.js");
|
|
26
|
-
require("core-js/modules/es.array.reduce.js");
|
|
27
|
-
require("core-js/modules/es.object.keys.js");
|
|
28
|
-
require("core-js/modules/es.object.to-string.js");
|
|
29
|
-
require("core-js/modules/es.promise.js");
|
|
30
|
-
require("core-js/modules/es.string.includes.js");
|
|
31
|
-
require("core-js/modules/es.string.iterator.js");
|
|
32
|
-
require("core-js/modules/web.dom-collections.for-each.js");
|
|
33
|
-
require("core-js/modules/web.dom-collections.iterator.js");
|
|
34
10
|
var _react = _interopRequireDefault(require("react"));
|
|
35
11
|
var _lodash = _interopRequireDefault(require("lodash.isnumber"));
|
|
36
12
|
var ReactDOMServer = _interopRequireWildcard(require("react-dom/server"));
|
|
@@ -39,240 +15,184 @@ var _client = require("@apollo/client");
|
|
|
39
15
|
var _reactPageBuilder = require("@blaze-cms/react-page-builder");
|
|
40
16
|
var _getPath = _interopRequireDefault(require("./get-path"));
|
|
41
17
|
var _constants = require("../../constants");
|
|
42
|
-
|
|
43
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
44
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
18
|
+
const _excluded = ["elementTitle", "type", "propsToDisplay"];
|
|
19
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
45
21
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
46
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
22
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
|
+
const shapesArray = [];
|
|
24
|
+
const infoWindowArray = [];
|
|
25
|
+
const clearShapes = () => {
|
|
50
26
|
if (shapesArray.length) {
|
|
51
|
-
shapesArray.forEach(
|
|
52
|
-
return shape.setMap(null);
|
|
53
|
-
});
|
|
27
|
+
shapesArray.forEach(shape => shape.setMap(null));
|
|
54
28
|
shapesArray.length = 0;
|
|
55
29
|
}
|
|
56
30
|
};
|
|
57
|
-
|
|
31
|
+
const closeInfoWindows = () => {
|
|
58
32
|
if (infoWindowArray.length) {
|
|
59
|
-
infoWindowArray.forEach(
|
|
60
|
-
return infoWindow.close();
|
|
61
|
-
});
|
|
33
|
+
infoWindowArray.forEach(infoWindow => infoWindow.close());
|
|
62
34
|
infoWindowArray.length = 0;
|
|
63
35
|
}
|
|
64
36
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
enableInfoPane =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
37
|
+
const addShapeListeners = (map, router, shape, imageData, shapeInstance, client) => {
|
|
38
|
+
const {
|
|
39
|
+
enableInfoPane = false,
|
|
40
|
+
dataSummaries = [],
|
|
41
|
+
url,
|
|
42
|
+
shapeData
|
|
43
|
+
} = shape;
|
|
72
44
|
if (enableInfoPane) {
|
|
73
|
-
|
|
45
|
+
const infoWindow = new window.google.maps.InfoWindow({
|
|
74
46
|
content: ''
|
|
75
47
|
});
|
|
76
|
-
shapeInstance.addListener(_constants.CLICK,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
_context.next = 4;
|
|
85
|
-
return infoWindowContent(imageData, dataSummaries, url, shapeData, client);
|
|
86
|
-
case 4:
|
|
87
|
-
_context.t1 = _context.sent;
|
|
88
|
-
content = _context.t0.renderToString.call(_context.t0, _context.t1);
|
|
89
|
-
infoWindow.setContent(content);
|
|
90
|
-
infoWindow.setPosition(event.latLng);
|
|
91
|
-
infoWindow.open(map, shapeInstance);
|
|
92
|
-
infoWindowArray.push(infoWindow);
|
|
93
|
-
case 10:
|
|
94
|
-
case "end":
|
|
95
|
-
return _context.stop();
|
|
96
|
-
}
|
|
97
|
-
}, _callee);
|
|
98
|
-
}));
|
|
99
|
-
return function (_x) {
|
|
100
|
-
return _ref.apply(this, arguments);
|
|
101
|
-
};
|
|
102
|
-
}());
|
|
48
|
+
shapeInstance.addListener(_constants.CLICK, async event => {
|
|
49
|
+
closeInfoWindows();
|
|
50
|
+
const content = ReactDOMServer.renderToString(await infoWindowContent(imageData, dataSummaries, url, shapeData, client));
|
|
51
|
+
infoWindow.setContent(content);
|
|
52
|
+
infoWindow.setPosition(event.latLng);
|
|
53
|
+
infoWindow.open(map, shapeInstance);
|
|
54
|
+
infoWindowArray.push(infoWindow);
|
|
55
|
+
});
|
|
103
56
|
} else if (url) {
|
|
104
|
-
shapeInstance.addListener(_constants.CLICK,
|
|
57
|
+
shapeInstance.addListener(_constants.CLICK, () => {
|
|
105
58
|
router.push(url);
|
|
106
59
|
});
|
|
107
60
|
}
|
|
108
61
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
62
|
+
const setStyleOptions = shape => {
|
|
63
|
+
const {
|
|
64
|
+
strokeColor,
|
|
65
|
+
strokeOpacity,
|
|
66
|
+
strokeWeight,
|
|
67
|
+
fillColor,
|
|
68
|
+
fillOpacity
|
|
69
|
+
} = shape;
|
|
70
|
+
const styleSettings = {
|
|
71
|
+
strokeColor,
|
|
72
|
+
fillColor,
|
|
73
|
+
strokeOpacity,
|
|
74
|
+
strokeWeight,
|
|
75
|
+
fillOpacity
|
|
121
76
|
};
|
|
122
|
-
return _objectSpread({}, Object.keys(styleSettings).reduce(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
77
|
+
return _objectSpread({}, Object.keys(styleSettings).reduce((acc, key) => {
|
|
78
|
+
const settingValue = styleSettings[key];
|
|
79
|
+
const shouldValueBeNumber = !key.includes(_constants.COLOR);
|
|
80
|
+
const hasValuePassedCondition = shouldValueBeNumber ? (0, _lodash.default)(settingValue) : settingValue;
|
|
126
81
|
if (hasValuePassedCondition) acc[key] = settingValue;
|
|
127
82
|
return acc;
|
|
128
83
|
}, {}));
|
|
129
84
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
var isPositionCorrect = function isPositionCorrect(lat, lng) {
|
|
136
|
-
return (0, _lodash["default"])(lat) && (0, _lodash["default"])(lng);
|
|
137
|
-
};
|
|
138
|
-
var getIconUrl = function getIconUrl(imageId, imageData) {
|
|
85
|
+
const areRectangleBoundsNumbers = bounds => bounds.every(bound => (0, _lodash.default)(bound));
|
|
86
|
+
const isPositionCorrect = (lat, lng) => (0, _lodash.default)(lat) && (0, _lodash.default)(lng);
|
|
87
|
+
const getIconUrl = (imageId, imageData) => {
|
|
139
88
|
if (!imageId) return '';
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
89
|
+
const image = imageData.find(({
|
|
90
|
+
id
|
|
91
|
+
}) => id === imageId);
|
|
144
92
|
if (!image || !image.url) return '';
|
|
145
93
|
return image.url;
|
|
146
94
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}, /*#__PURE__*/_react["default"].createElement(SummaryComponent, {
|
|
178
|
-
key: type,
|
|
179
|
-
modifier: modifier,
|
|
180
|
-
elementTitle: elementTitle,
|
|
181
|
-
summaryPropsWithContent: summaryPropsWithContent
|
|
182
|
-
}));
|
|
183
|
-
if (isTypeHeading && url) return /*#__PURE__*/_react["default"].createElement(_nextjsComponents.Link, {
|
|
184
|
-
href: url
|
|
185
|
-
}, component);
|
|
186
|
-
return component;
|
|
187
|
-
};
|
|
188
|
-
return _context2.abrupt("return", getDataSummaryComponent());
|
|
189
|
-
case 11:
|
|
190
|
-
case "end":
|
|
191
|
-
return _context2.stop();
|
|
192
|
-
}
|
|
193
|
-
}, _callee2);
|
|
194
|
-
}));
|
|
195
|
-
return function (_x7) {
|
|
196
|
-
return _ref4.apply(this, arguments);
|
|
197
|
-
};
|
|
198
|
-
}()));
|
|
199
|
-
case 2:
|
|
200
|
-
summariesWithContent = _context3.sent;
|
|
201
|
-
_ref5 = shapeData || {}, imageId = _ref5.imageId;
|
|
202
|
-
image = imageData.find(function (_ref6) {
|
|
203
|
-
var id = _ref6.id;
|
|
204
|
-
return id === imageId;
|
|
205
|
-
});
|
|
206
|
-
shouldShowImage = image && image.url;
|
|
207
|
-
getImageElement = function getImageElement() {
|
|
208
|
-
var imageUrl = image.url,
|
|
209
|
-
data = image.data;
|
|
210
|
-
var imageElement = /*#__PURE__*/_react["default"].createElement("img", {
|
|
211
|
-
className: "info__window",
|
|
212
|
-
src: imageUrl,
|
|
213
|
-
alt: data && data.altText ? data.altText : ''
|
|
214
|
-
});
|
|
215
|
-
if (url) return /*#__PURE__*/_react["default"].createElement(_nextjsComponents.Link, {
|
|
216
|
-
href: url
|
|
217
|
-
}, imageElement);
|
|
218
|
-
return imageElement;
|
|
219
|
-
};
|
|
220
|
-
return _context3.abrupt("return", /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, shouldShowImage && getImageElement(), summariesWithContent));
|
|
221
|
-
case 8:
|
|
222
|
-
case "end":
|
|
223
|
-
return _context3.stop();
|
|
224
|
-
}
|
|
225
|
-
}, _callee3);
|
|
95
|
+
const infoWindowContent = async (imageData, dataSummaries, url, shapeData, client) => {
|
|
96
|
+
const summariesWithContent = await Promise.all(dataSummaries.map(async dataSummary => {
|
|
97
|
+
const {
|
|
98
|
+
elementTitle,
|
|
99
|
+
type,
|
|
100
|
+
propsToDisplay
|
|
101
|
+
} = dataSummary,
|
|
102
|
+
otherProps = (0, _objectWithoutProperties2.default)(dataSummary, _excluded);
|
|
103
|
+
const isTypeHeading = type === _constants.HEADING_LARGE;
|
|
104
|
+
const summaryPropsWithContent = (0, _reactPageBuilder.buildPropsToDisplayWithContent)(shapeData, propsToDisplay);
|
|
105
|
+
const modifier = (0, _reactPageBuilder.getClassModifiers)(_constants.LIST, otherProps);
|
|
106
|
+
const SummaryComponent = _reactPageBuilder.summaryComponents[type];
|
|
107
|
+
await SummaryComponent.render.preload(); // preload dynamic nextjs component
|
|
108
|
+
|
|
109
|
+
if (!summaryPropsWithContent.length) return null;
|
|
110
|
+
const getDataSummaryComponent = () => {
|
|
111
|
+
const component = /*#__PURE__*/_react.default.createElement(_client.ApolloProvider, {
|
|
112
|
+
client: client
|
|
113
|
+
}, /*#__PURE__*/_react.default.createElement(SummaryComponent, {
|
|
114
|
+
key: type,
|
|
115
|
+
modifier: modifier,
|
|
116
|
+
elementTitle: elementTitle,
|
|
117
|
+
summaryPropsWithContent: summaryPropsWithContent
|
|
118
|
+
}));
|
|
119
|
+
if (isTypeHeading && url) return /*#__PURE__*/_react.default.createElement(_nextjsComponents.Link, {
|
|
120
|
+
href: url
|
|
121
|
+
}, component);
|
|
122
|
+
return component;
|
|
123
|
+
};
|
|
124
|
+
return getDataSummaryComponent();
|
|
226
125
|
}));
|
|
227
|
-
|
|
228
|
-
|
|
126
|
+
const {
|
|
127
|
+
imageId
|
|
128
|
+
} = shapeData || {};
|
|
129
|
+
const image = imageData.find(({
|
|
130
|
+
id
|
|
131
|
+
}) => id === imageId);
|
|
132
|
+
const shouldShowImage = image && image.url;
|
|
133
|
+
const getImageElement = () => {
|
|
134
|
+
const {
|
|
135
|
+
url: imageUrl,
|
|
136
|
+
data
|
|
137
|
+
} = image;
|
|
138
|
+
const imageElement = /*#__PURE__*/_react.default.createElement("img", {
|
|
139
|
+
className: "info__window",
|
|
140
|
+
src: imageUrl,
|
|
141
|
+
alt: data && data.altText ? data.altText : ''
|
|
142
|
+
});
|
|
143
|
+
if (url) return /*#__PURE__*/_react.default.createElement(_nextjsComponents.Link, {
|
|
144
|
+
href: url
|
|
145
|
+
}, imageElement);
|
|
146
|
+
return imageElement;
|
|
229
147
|
};
|
|
230
|
-
|
|
148
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, shouldShowImage && getImageElement(), summariesWithContent);
|
|
149
|
+
};
|
|
231
150
|
function getIcon(imageData, shape) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
markerWidth =
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
151
|
+
const {
|
|
152
|
+
imageId,
|
|
153
|
+
markerWidth = 50,
|
|
154
|
+
markerHeight = 50,
|
|
155
|
+
strokeColor,
|
|
156
|
+
strokeOpacity,
|
|
157
|
+
strokeWeight,
|
|
158
|
+
fillColor,
|
|
159
|
+
fillOpacity,
|
|
160
|
+
svgPath
|
|
161
|
+
} = shape;
|
|
162
|
+
const iconUrl = getIconUrl(imageId, imageData);
|
|
163
|
+
const icon = iconUrl ? {
|
|
245
164
|
url: iconUrl,
|
|
246
165
|
scaledSize: new window.google.maps.Size(markerWidth || 50, markerHeight || 50)
|
|
247
166
|
} : null;
|
|
248
167
|
if (icon) return icon;
|
|
249
168
|
if (!svgPath && !fillColor && !strokeColor) return {}; // any can be true for custom marker
|
|
250
169
|
|
|
251
|
-
|
|
170
|
+
const svgMarker = {
|
|
252
171
|
path: svgPath || _constants.DEFAULT_CUSTOM_MARKER_PATH,
|
|
253
|
-
strokeColor
|
|
254
|
-
strokeOpacity
|
|
255
|
-
strokeWeight
|
|
256
|
-
fillColor
|
|
257
|
-
fillOpacity
|
|
172
|
+
strokeColor,
|
|
173
|
+
strokeOpacity,
|
|
174
|
+
strokeWeight,
|
|
175
|
+
fillColor,
|
|
176
|
+
fillOpacity,
|
|
258
177
|
rotation: 0,
|
|
259
178
|
scale: 2
|
|
260
179
|
};
|
|
261
180
|
return svgMarker;
|
|
262
181
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
label =
|
|
266
|
-
latitude
|
|
267
|
-
longitude
|
|
182
|
+
const setMarker = (map, router, shape, imageData, client) => {
|
|
183
|
+
const {
|
|
184
|
+
label = '',
|
|
185
|
+
latitude,
|
|
186
|
+
longitude
|
|
187
|
+
} = shape;
|
|
268
188
|
if (isPositionCorrect(latitude, longitude)) {
|
|
269
|
-
|
|
270
|
-
|
|
189
|
+
const svgMarker = getIcon(imageData, shape);
|
|
190
|
+
const marker = new window.google.maps.Marker({
|
|
271
191
|
position: {
|
|
272
192
|
lat: latitude,
|
|
273
193
|
lng: longitude
|
|
274
194
|
},
|
|
275
|
-
map
|
|
195
|
+
map,
|
|
276
196
|
icon: svgMarker,
|
|
277
197
|
title: label || ''
|
|
278
198
|
});
|
|
@@ -281,12 +201,14 @@ var setMarker = function setMarker(map, router, shape, imageData, client) {
|
|
|
281
201
|
marker.setMap(map);
|
|
282
202
|
}
|
|
283
203
|
};
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
204
|
+
const setPolyline = (map, router, shape, imageData) => {
|
|
205
|
+
const {
|
|
206
|
+
paths
|
|
207
|
+
} = shape;
|
|
208
|
+
const path = (0, _getPath.default)(paths);
|
|
287
209
|
if (path.length) {
|
|
288
|
-
|
|
289
|
-
path
|
|
210
|
+
const polyline = new window.google.maps.Polyline(_objectSpread({
|
|
211
|
+
path,
|
|
290
212
|
geodesic: true
|
|
291
213
|
}, setStyleOptions(shape)));
|
|
292
214
|
addShapeListeners(map, router, shape, imageData, polyline);
|
|
@@ -294,26 +216,30 @@ var setPolyline = function setPolyline(map, router, shape, imageData) {
|
|
|
294
216
|
polyline.setMap(map);
|
|
295
217
|
}
|
|
296
218
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
219
|
+
const setPolygon = (map, router, shape, imageData) => {
|
|
220
|
+
const {
|
|
221
|
+
paths: unParsedPaths
|
|
222
|
+
} = shape;
|
|
223
|
+
const paths = (0, _getPath.default)(unParsedPaths);
|
|
300
224
|
if (paths.length) {
|
|
301
|
-
|
|
302
|
-
paths
|
|
225
|
+
const polygon = new window.google.maps.Polygon(_objectSpread({
|
|
226
|
+
paths
|
|
303
227
|
}, setStyleOptions(shape)));
|
|
304
228
|
addShapeListeners(map, router, shape, imageData, polygon);
|
|
305
229
|
shapesArray.push(polygon);
|
|
306
230
|
polygon.setMap(map);
|
|
307
231
|
}
|
|
308
232
|
};
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
233
|
+
const setRectangle = (map, router, shape, imageData) => {
|
|
234
|
+
const {
|
|
235
|
+
northBound,
|
|
236
|
+
southBound,
|
|
237
|
+
eastBound,
|
|
238
|
+
westBound
|
|
239
|
+
} = shape;
|
|
314
240
|
if (areRectangleBoundsNumbers([northBound, southBound, eastBound, westBound])) {
|
|
315
|
-
|
|
316
|
-
map
|
|
241
|
+
const rectangle = new window.google.maps.Rectangle(_objectSpread(_objectSpread({}, setStyleOptions(shape)), {}, {
|
|
242
|
+
map,
|
|
317
243
|
bounds: {
|
|
318
244
|
north: northBound,
|
|
319
245
|
south: southBound,
|
|
@@ -326,31 +252,35 @@ var setRectangle = function setRectangle(map, router, shape, imageData) {
|
|
|
326
252
|
rectangle.setMap(map);
|
|
327
253
|
}
|
|
328
254
|
};
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
255
|
+
const setCircle = (map, router, shape, imageData) => {
|
|
256
|
+
const {
|
|
257
|
+
latitude,
|
|
258
|
+
longitude,
|
|
259
|
+
radius
|
|
260
|
+
} = shape;
|
|
261
|
+
if (isPositionCorrect(latitude, longitude) && (0, _lodash.default)(radius)) {
|
|
262
|
+
const circle = new window.google.maps.Circle(_objectSpread(_objectSpread({}, setStyleOptions(shape)), {}, {
|
|
263
|
+
map,
|
|
336
264
|
center: {
|
|
337
265
|
lat: latitude,
|
|
338
266
|
lng: longitude
|
|
339
267
|
},
|
|
340
|
-
radius
|
|
268
|
+
radius
|
|
341
269
|
}));
|
|
342
270
|
addShapeListeners(map, router, shape, imageData, circle);
|
|
343
271
|
shapesArray.push(circle);
|
|
344
272
|
circle.setMap(map);
|
|
345
273
|
}
|
|
346
274
|
};
|
|
347
|
-
|
|
348
|
-
|
|
275
|
+
const setShapes = (map, router, shapes, imageData, client) => {
|
|
276
|
+
const mapZoom = map.getZoom();
|
|
349
277
|
clearShapes();
|
|
350
|
-
shapes.forEach(
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
278
|
+
shapes.forEach(shape => {
|
|
279
|
+
const {
|
|
280
|
+
type,
|
|
281
|
+
minZoom,
|
|
282
|
+
maxZoom
|
|
283
|
+
} = shape;
|
|
354
284
|
if (mapZoom >= minZoom && mapZoom <= maxZoom) {
|
|
355
285
|
switch (type) {
|
|
356
286
|
case _constants.MARKER:
|
|
@@ -384,5 +314,5 @@ var setShapes = function setShapes(map, router, shapes, imageData, client) {
|
|
|
384
314
|
}
|
|
385
315
|
});
|
|
386
316
|
};
|
|
387
|
-
var _default = exports
|
|
317
|
+
var _default = exports.default = setShapes;
|
|
388
318
|
//# sourceMappingURL=set-shapes.js.map
|