@cashub/ui 0.19.2 → 0.19.4
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,13 +333,40 @@ var Map = function Map(_ref3) {
|
|
|
324
333
|
}
|
|
325
334
|
|
|
326
335
|
markers.push(marker);
|
|
336
|
+
oms.addMarker(marker);
|
|
327
337
|
});
|
|
328
338
|
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
|
});
|
|
335
371
|
}
|
|
336
372
|
}, [map, locations, checkPrimaryLocation, customPopup]); // geofencing
|
|
@@ -7,12 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
9
9
|
|
|
10
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
-
|
|
12
|
-
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); } }
|
|
13
|
-
|
|
14
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
-
|
|
16
10
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
11
|
|
|
18
12
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
@@ -29,94 +23,108 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
29
23
|
|
|
30
24
|
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; }
|
|
31
25
|
|
|
26
|
+
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); } }
|
|
27
|
+
|
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
29
|
+
|
|
30
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
31
|
+
|
|
32
32
|
// custom popup
|
|
33
33
|
// https://developers.google.com/maps/documentation/javascript/examples/overlay-popup
|
|
34
|
-
var GoogleMapPopup = /*#__PURE__*/function (
|
|
35
|
-
|
|
34
|
+
var GoogleMapPopup = /*#__PURE__*/_createClass(function GoogleMapPopup(options) {
|
|
35
|
+
_classCallCheck(this, GoogleMapPopup);
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
// wrap class to prevent cannot reference maps during runtime
|
|
38
|
+
// because google map library will load after render map only
|
|
39
|
+
var MapPopup = /*#__PURE__*/function (_window$google$maps$O) {
|
|
40
|
+
_inherits(MapPopup, _window$google$maps$O);
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
var _this;
|
|
42
|
+
var _super = _createSuper(MapPopup);
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
offset = _ref.offset;
|
|
44
|
+
function MapPopup() {
|
|
45
|
+
var _this;
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
48
|
+
maxWidth = _ref.maxWidth,
|
|
49
|
+
offset = _ref.offset;
|
|
47
50
|
|
|
48
|
-
|
|
51
|
+
_classCallCheck(this, MapPopup);
|
|
49
52
|
|
|
50
|
-
|
|
53
|
+
_this = _super.call(this); // This zero-height div is positioned at the bottom of the tip.
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "position", void 0);
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
_defineProperty(_assertThisInitialized(_this), "containerDiv", void 0);
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
_defineProperty(_assertThisInitialized(_this), "offset", 16);
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
_this.containerDiv = document.createElement('div');
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
_this.containerDiv.style.maxWidth = "".concat(maxWidth, "px");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (offset) {
|
|
65
|
-
_this.offset = offset;
|
|
66
|
-
} // Optionally stop clicks, etc., from bubbling up to the map.
|
|
63
|
+
_this.containerDiv.classList.add('google-popup-content-wrapper');
|
|
67
64
|
|
|
65
|
+
if (maxWidth) {
|
|
66
|
+
_this.containerDiv.style.maxWidth = "".concat(maxWidth, "px");
|
|
67
|
+
}
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
/** Called when the popup is added to the map. */
|
|
69
|
+
if (offset) {
|
|
70
|
+
_this.offset = offset;
|
|
71
|
+
} // Optionally stop clicks, etc., from bubbling up to the map.
|
|
73
72
|
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
value: function onAdd() {
|
|
78
|
-
this.getPanes().floatPane.appendChild(this.containerDiv);
|
|
74
|
+
MapPopup.preventMapHitsAndGesturesFrom(_this.containerDiv);
|
|
75
|
+
return _this;
|
|
79
76
|
}
|
|
80
|
-
/** Called when the popup is
|
|
77
|
+
/** Called when the popup is added to the map. */
|
|
81
78
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.
|
|
79
|
+
|
|
80
|
+
_createClass(MapPopup, [{
|
|
81
|
+
key: "onAdd",
|
|
82
|
+
value: function onAdd() {
|
|
83
|
+
this.getPanes().floatPane.appendChild(this.containerDiv);
|
|
87
84
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this.containerDiv.style.left = "".concat(divPosition.x, "px");
|
|
97
|
-
this.containerDiv.style.top = "".concat(divPosition.y - this.offset, "px");
|
|
85
|
+
/** Called when the popup is removed from the map. */
|
|
86
|
+
|
|
87
|
+
}, {
|
|
88
|
+
key: "onRemove",
|
|
89
|
+
value: function onRemove() {
|
|
90
|
+
if (this.containerDiv.parentElement) {
|
|
91
|
+
this.containerDiv.parentElement.removeChild(this.containerDiv);
|
|
92
|
+
}
|
|
98
93
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (_typeof(content) === 'object') {
|
|
111
|
-
this.containerDiv.replaceChildren(content);
|
|
112
|
-
} else {
|
|
113
|
-
this.containerDiv.innerHTML = content;
|
|
94
|
+
/** Called each frame when the popup needs to draw itself. */
|
|
95
|
+
|
|
96
|
+
}, {
|
|
97
|
+
key: "draw",
|
|
98
|
+
value: function draw() {
|
|
99
|
+
if (this.position) {
|
|
100
|
+
var divPosition = this.getProjection().fromLatLngToDivPixel(this.position);
|
|
101
|
+
this.containerDiv.style.left = "".concat(divPosition.x, "px");
|
|
102
|
+
this.containerDiv.style.top = "".concat(divPosition.y - this.offset, "px");
|
|
103
|
+
}
|
|
114
104
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
105
|
+
}, {
|
|
106
|
+
key: "setPosition",
|
|
107
|
+
value: function setPosition(position) {
|
|
108
|
+
this.position = position;
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
key: "setContent",
|
|
112
|
+
value: function setContent(content) {
|
|
113
|
+
if (!content) return;
|
|
114
|
+
|
|
115
|
+
if (_typeof(content) === 'object') {
|
|
116
|
+
this.containerDiv.replaceChildren(content);
|
|
117
|
+
} else {
|
|
118
|
+
this.containerDiv.innerHTML = content;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}]);
|
|
122
|
+
|
|
123
|
+
return MapPopup;
|
|
124
|
+
}(window.google.maps.OverlayView);
|
|
117
125
|
|
|
118
|
-
return
|
|
119
|
-
}
|
|
126
|
+
return new MapPopup(options);
|
|
127
|
+
});
|
|
120
128
|
|
|
121
129
|
var _default = GoogleMapPopup;
|
|
122
130
|
exports.default = _default;
|
|
@@ -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.4",
|
|
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",
|