@cashub/ui 0.19.3 → 0.19.5
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/map/GoogleMap.js
CHANGED
|
@@ -17,6 +17,8 @@ var _GoogleMapContainer = _interopRequireDefault(require("./subComponent/GoogleM
|
|
|
17
17
|
|
|
18
18
|
var _GoogleMapPopup = _interopRequireDefault(require("./subComponent/GoogleMapPopup"));
|
|
19
19
|
|
|
20
|
+
var _GoogleMarkerSpiderfier = _interopRequireDefault(require("./subComponent/GoogleMarkerSpiderfier"));
|
|
21
|
+
|
|
20
22
|
var _map_icon = _interopRequireDefault(require("../assets/icons/map_icon1.png"));
|
|
21
23
|
|
|
22
24
|
var _map_icon2 = _interopRequireDefault(require("../assets/icons/map_icon4.png"));
|
|
@@ -223,6 +225,7 @@ var Map = function Map(_ref3) {
|
|
|
223
225
|
rotateControl: false,
|
|
224
226
|
fullscreenControl: false,
|
|
225
227
|
minZoom: 3,
|
|
228
|
+
maxZoom: 20,
|
|
226
229
|
restriction: {
|
|
227
230
|
latLngBounds: {
|
|
228
231
|
east: 179.9999,
|
|
@@ -283,6 +286,11 @@ var Map = function Map(_ref3) {
|
|
|
283
286
|
map.addListener('click', function () {
|
|
284
287
|
popup.setMap(null);
|
|
285
288
|
});
|
|
289
|
+
var oms = new _GoogleMarkerSpiderfier.default(map, {
|
|
290
|
+
markersWontMove: true,
|
|
291
|
+
markersWontHide: true,
|
|
292
|
+
basicFormatEvents: true
|
|
293
|
+
});
|
|
286
294
|
locations.forEach(function (location) {
|
|
287
295
|
var latitude = location.latitude,
|
|
288
296
|
longitude = location.longitude;
|
|
@@ -302,6 +310,7 @@ var Map = function Map(_ref3) {
|
|
|
302
310
|
|
|
303
311
|
var marker = new window.google.maps.Marker({
|
|
304
312
|
icon: icon,
|
|
313
|
+
map: map,
|
|
305
314
|
position: {
|
|
306
315
|
lat: latitude,
|
|
307
316
|
lng: longitude
|
|
@@ -324,14 +333,45 @@ var Map = function Map(_ref3) {
|
|
|
324
333
|
}
|
|
325
334
|
|
|
326
335
|
markers.push(marker);
|
|
336
|
+
oms.addMarker(marker);
|
|
327
337
|
});
|
|
328
|
-
new _markerclusterer.MarkerClusterer({
|
|
338
|
+
var markerClusterer = new _markerclusterer.MarkerClusterer({
|
|
329
339
|
map: map,
|
|
330
340
|
markers: markers,
|
|
331
341
|
algorithm: new _markerclusterer.SuperClusterAlgorithm({
|
|
332
342
|
radius: 120
|
|
333
|
-
})
|
|
343
|
+
}),
|
|
344
|
+
onClusterClick: function onClusterClick(event, cluster, map) {
|
|
345
|
+
// fix: cluster marker spiderfier
|
|
346
|
+
// const targetPosition = cluster.markers[0].getPosition().toJSON();
|
|
347
|
+
// const isAllSamePosition = cluster.markers.every((marker) => {
|
|
348
|
+
// const position = marker.getPosition().toJSON();
|
|
349
|
+
// return (
|
|
350
|
+
// targetPosition.lat === position.lat &&
|
|
351
|
+
// targetPosition.lng === position.lng
|
|
352
|
+
// );
|
|
353
|
+
// });
|
|
354
|
+
// if (isAllSamePosition) {
|
|
355
|
+
// return;
|
|
356
|
+
// }
|
|
357
|
+
// fix: need to call twice to actually work
|
|
358
|
+
map.fitBounds(cluster.bounds);
|
|
359
|
+
map.fitBounds(cluster.bounds); // check current view has marker, if not set view to first marker
|
|
360
|
+
|
|
361
|
+
var currentBounds = map.getBounds();
|
|
362
|
+
var found = cluster.markers.find(function (marker) {
|
|
363
|
+
return currentBounds.contains(marker.getPosition());
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
if (!found) {
|
|
367
|
+
map.setCenter(cluster.markers[0].getPosition());
|
|
368
|
+
}
|
|
369
|
+
}
|
|
334
370
|
});
|
|
371
|
+
return function () {
|
|
372
|
+
popup.setMap(null);
|
|
373
|
+
markerClusterer.setMap(null);
|
|
374
|
+
};
|
|
335
375
|
}
|
|
336
376
|
}, [map, locations, checkPrimaryLocation, customPopup]); // geofencing
|
|
337
377
|
|
|
@@ -34,7 +34,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
34
34
|
var GoogleMapPopup = /*#__PURE__*/_createClass(function GoogleMapPopup(options) {
|
|
35
35
|
_classCallCheck(this, GoogleMapPopup);
|
|
36
36
|
|
|
37
|
-
// wrap class to prevent cannot reference maps during
|
|
37
|
+
// wrap class to prevent cannot reference maps during runtime
|
|
38
38
|
// because google map library will load after render map only
|
|
39
39
|
var MapPopup = /*#__PURE__*/function (_window$google$maps$O) {
|
|
40
40
|
_inherits(MapPopup, _window$google$maps$O);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
9
|
+
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
|
|
14
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
|
|
16
|
+
var GoogleMarkerSpiderfier = /*#__PURE__*/_createClass(function GoogleMarkerSpiderfier(map, options) {
|
|
17
|
+
_classCallCheck(this, GoogleMarkerSpiderfier);
|
|
18
|
+
|
|
19
|
+
_defineProperty(this, "oms", void 0);
|
|
20
|
+
|
|
21
|
+
// dynamic import to prevent cannot reference maps during runtime
|
|
22
|
+
// because google map library will load after render map only
|
|
23
|
+
var OverlappingMarkerSpiderfier = require('overlapping-marker-spiderfier');
|
|
24
|
+
|
|
25
|
+
this.oms = new OverlappingMarkerSpiderfier(map, options);
|
|
26
|
+
return this.oms;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
var _default = GoogleMarkerSpiderfier;
|
|
30
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cashub/ui",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "CASHUB Team",
|
|
6
6
|
"description": "CASHUB UI components library",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"leaflet-draw": "^1.0.4",
|
|
26
26
|
"lodash.uniqueid": "^4.0.1",
|
|
27
27
|
"moment": "^2.29.3",
|
|
28
|
+
"overlapping-marker-spiderfier": "^1.1.4",
|
|
28
29
|
"qrcode.react": "^3.0.2",
|
|
29
30
|
"rc-time-picker": "^3.7.3",
|
|
30
31
|
"react-chartjs-2": "^3.3.0",
|