@mint-ui/map 0.2.1-beta → 0.3.0-beta

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.
@@ -12,12 +12,14 @@ export interface MintMapProps extends MintMapEvents {
12
12
  visible?: boolean;
13
13
  markerCache?: boolean;
14
14
  markerCachePoolSize?: number;
15
+ boundsChangeThrottlingTime?: number;
15
16
  }
16
17
  export interface MintMapEvents {
17
18
  onBoundsChanged?: (bounds: Bounds) => void;
18
19
  onZoomChanged?: (level: number) => void;
19
20
  onLoad?: (map: MapVendorType, controller: MintMapController) => void;
20
21
  onClick?: (positon: Position) => void;
22
+ onMouseMove?: (positon: Position) => void;
21
23
  }
22
24
  export declare class Position {
23
25
  lat: number;
@@ -36,6 +38,7 @@ export declare class Bounds {
36
38
  private covertNWSEtoNESW;
37
39
  private covertNESWtoNWSE;
38
40
  getCenter(): Position;
41
+ includesPosition(pos: Position): boolean;
39
42
  getIncludedPositions(positions: Position[]): Position[];
40
43
  includes(positions: Position | Position[]): boolean;
41
44
  includesOnlyOnePoint(positions: Position[]): boolean;
@@ -65,7 +65,11 @@ var Bounds = function () {
65
65
  };
66
66
 
67
67
  Bounds.prototype.getCenter = function () {
68
- return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
68
+ return new Position(this.se.lat + (this.nw.lat - this.se.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
69
+ };
70
+
71
+ Bounds.prototype.includesPosition = function (pos) {
72
+ return this.nw.lng < pos.lng && this.se.lng > pos.lng && this.se.lat < pos.lat && this.nw.lat > pos.lat;
69
73
  };
70
74
 
71
75
  Bounds.prototype.getIncludedPositions = function (positions) {
@@ -74,7 +78,7 @@ var Bounds = function () {
74
78
  for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
75
79
  var pos = positions_1[_i];
76
80
 
77
- if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
81
+ if (this.includesPosition(pos)) {
78
82
  result.push(pos);
79
83
  }
80
84
  }
@@ -88,7 +92,7 @@ var Bounds = function () {
88
92
  for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
89
93
  var pos = positions_2[_i];
90
94
 
91
- if (this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng) {
95
+ if (!this.includesPosition(pos)) {
92
96
  return false;
93
97
  }
94
98
  }
@@ -100,7 +104,7 @@ var Bounds = function () {
100
104
  for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) {
101
105
  var pos = positions_3[_i];
102
106
 
103
- if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
107
+ if (this.includesPosition(pos)) {
104
108
  return true;
105
109
  }
106
110
  }
@@ -30,4 +30,6 @@ export declare abstract class MintMapController {
30
30
  buildUrl(baseUrl: string, param: {
31
31
  [key: string]: string | string[];
32
32
  }): string;
33
+ private processedTime;
34
+ checkBoundsChangeThrottleTime(): boolean;
33
35
  }
@@ -8,6 +8,7 @@ var MintMapController = function () {
8
8
  function MintMapController(props) {
9
9
  this.mapApiLoaded = false;
10
10
  this.mapInitialized = false;
11
+ this.processedTime = 0;
11
12
  this.mapProps = props;
12
13
  }
13
14
 
@@ -52,6 +53,18 @@ var MintMapController = function () {
52
53
  return "".concat(baseUrl, "?").concat(params);
53
54
  };
54
55
 
56
+ MintMapController.prototype.checkBoundsChangeThrottleTime = function () {
57
+ if (!this.mapProps.boundsChangeThrottlingTime) return true;
58
+ var time = new Date().getTime();
59
+
60
+ if (this.processedTime > 0 && time - this.processedTime < this.mapProps.boundsChangeThrottlingTime) {
61
+ return false;
62
+ } else {
63
+ this.processedTime = time;
64
+ return true;
65
+ }
66
+ };
67
+
55
68
  return MintMapController;
56
69
  }();
57
70
 
@@ -0,0 +1,18 @@
1
+ import { Bounds, Position } from "../../MintMap";
2
+ export interface ClusterInfo {
3
+ bounds: Bounds;
4
+ checked: boolean;
5
+ center: boolean;
6
+ centerPosition: Position;
7
+ incList: any;
8
+ itemList: Position[];
9
+ size: number;
10
+ }
11
+ export interface ClusterStatus {
12
+ total: number;
13
+ average: number;
14
+ min: number;
15
+ max: number;
16
+ }
17
+ export declare type ClusterSizeCalculator = (info: ClusterInfo, status: ClusterStatus) => number;
18
+ export declare const getClusterInfo: (basePixelSize: number, mapBounds: Bounds, mapWidth: number, mapHeight: number, itemList: Position[], sizeFunction?: ClusterSizeCalculator) => (ClusterInfo[] | Bounds[])[];
@@ -19,7 +19,7 @@ function MapPolygonWrapper(_a) {
19
19
  React.useEffect(function () {
20
20
  return function () {
21
21
  if (polygonRef.current) {
22
- console.log('polygon cleared', controller.clearDrawable(polygonRef.current));
22
+ controller.clearDrawable(polygonRef.current);
23
23
  }
24
24
  };
25
25
  }, []);
@@ -19,7 +19,7 @@ function MapPolylineWrapper(_a) {
19
19
  React.useEffect(function () {
20
20
  return function () {
21
21
  if (polylineRef.current) {
22
- console.log('polyline cleared', controller.clearDrawable(polylineRef.current));
22
+ controller.clearDrawable(polylineRef.current);
23
23
  }
24
24
  };
25
25
  }, []);
@@ -23,7 +23,13 @@ var GoogleMintMapController = function (_super) {
23
23
  _this.dragged = false;
24
24
 
25
25
  _this.destroyMap = function () {
26
- console.log("".concat(_this.type, " map destroy feature is not supported"));
26
+ try {
27
+ _this.map && google.maps.event.clearInstanceListeners(_this.map);
28
+ } catch (e) {
29
+ console.log('google map destroy error', e);
30
+ }
31
+
32
+ console.log("".concat(_this.type, " map destroyed"));
27
33
  };
28
34
 
29
35
  console.log("".concat(_this.type, " controller loadded"));
@@ -137,6 +143,16 @@ var GoogleMintMapController = function (_super) {
137
143
  GoogleMintMapController.prototype.updatePolygon = function (polygon, options) {
138
144
  if (polygon && polygon.native && polygon.native instanceof google.maps.Polygon) {
139
145
  var polygonOption = this.getValidOptions(options);
146
+
147
+ if (this.map && Array.isArray(options.position)) {
148
+ var outLine = options.position.map(function (elem) {
149
+ return Array.isArray(elem) ? new MintMap.Position(elem[1], elem[0]) : elem;
150
+ });
151
+ var paths = [outLine];
152
+ options.innerPositions && paths.push.apply(paths, options.innerPositions);
153
+ polygonOption.paths = paths;
154
+ }
155
+
140
156
  polygon.native.setOptions(polygonOption);
141
157
  }
142
158
  };
@@ -368,18 +384,28 @@ var GoogleMintMapController = function (_super) {
368
384
  minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
369
385
  zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
370
386
  disableDefaultUI: true,
371
- gestureHandling: 'greedy'
387
+ gestureHandling: 'greedy',
388
+ clickableIcons: false
372
389
  });
373
390
  map.addListener('idle', function () {
374
- _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
391
+ _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
375
392
  });
376
393
  map.addListener('zoom_changed', function () {
377
394
  _this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
378
395
  });
379
396
  map.addListener('click', function (e) {
397
+ if (!_this.mapProps.onClick) return;
398
+ var pos = new MintMap.Position(e.latLng.lat(), e.latLng.lng());
399
+ pos.offset = new MintMap.Offset(e.pixel.x, e.pixel.y);
400
+
401
+ _this.mapProps.onClick(pos);
402
+ });
403
+ map.addListener('mousemove', function (e) {
404
+ if (!_this.mapProps.onMouseMove) return;
380
405
  var pos = new MintMap.Position(e.latLng.lat(), e.latLng.lng());
381
406
  pos.offset = new MintMap.Offset(e.pixel.x, e.pixel.y);
382
- _this.mapProps.onClick && _this.mapProps.onClick(pos);
407
+
408
+ _this.mapProps.onMouseMove(pos);
383
409
  });
384
410
  this.map = map;
385
411
  this.mapInitialized = true;
@@ -151,8 +151,18 @@ var NaverMintMapController = function (_super) {
151
151
 
152
152
  NaverMintMapController.prototype.updatePolygon = function (polygon, options) {
153
153
  if (polygon && polygon.native && polygon.native instanceof naver.maps.Polygon) {
154
+ var paths = void 0;
155
+
156
+ if (Array.isArray(options.position)) {
157
+ var outLine = options.position.map(function (elem) {
158
+ return Array.isArray(elem) ? new MintMap.Position(elem[1], elem[0]) : elem;
159
+ });
160
+ paths = [outLine];
161
+ options.innerPositions && paths.push.apply(paths, options.innerPositions);
162
+ }
163
+
154
164
  polygon.native.setOptions({
155
- paths: polygon.native.getPaths(),
165
+ paths: paths || polygon.native.getPaths(),
156
166
  visible: options.visible === undefined || options.visible,
157
167
  strokeColor: options.lineColor,
158
168
  strokeWeight: options.lineSize,
@@ -416,17 +426,25 @@ var NaverMintMapController = function (_super) {
416
426
  _this.dragged = true;
417
427
  }
418
428
  });
419
- map.addListener('idle', function () {
420
- _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
429
+ map.addListener('idle', function (e) {
430
+ _this.map && _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
421
431
  });
422
432
  map.addListener('zoom_changed', function () {
423
433
  _this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
424
434
  });
425
435
  map.addListener('click', function (e) {
426
- console.log('map click', e);
436
+ if (!_this.mapProps.onClick) return;
427
437
  var pos = new MintMap.Position(e.coord.y, e.coord.x);
428
438
  pos.offset = new MintMap.Offset(e.offset.x, e.offset.y);
429
- _this.mapProps.onClick && _this.mapProps.onClick(pos);
439
+
440
+ _this.mapProps.onClick(pos);
441
+ });
442
+ map.addListener('mousemove', function (e) {
443
+ if (!_this.mapProps.onMouseMove) return;
444
+ var pos = new MintMap.Position(e.coord.y, e.coord.x);
445
+ pos.offset = new MintMap.Offset(e.offset.x, e.offset.y);
446
+
447
+ _this.mapProps.onMouseMove(pos);
430
448
  });
431
449
  this.map = map;
432
450
  this.mapInitialized = true;
@@ -455,14 +473,14 @@ var NaverMintMapController = function (_super) {
455
473
  NaverMintMapController.prototype.destroyMap = function () {
456
474
  var _a;
457
475
 
458
- console.log("".concat(this.type, " map destroyed"));
459
-
460
476
  try {
461
477
  this.map && this.map.destroy();
462
478
  (_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.destroy();
463
479
  } catch (e) {
464
480
  console.log('naver map destroy error', e);
465
481
  }
482
+
483
+ console.log("".concat(this.type, " map destroyed"));
466
484
  };
467
485
 
468
486
  NaverMintMapController.prototype.getCurrBounds = function () {
@@ -471,7 +489,7 @@ var NaverMintMapController = function (_super) {
471
489
  }
472
490
 
473
491
  var bounds = this.map.getBounds();
474
- return MintMap.Bounds.fromNWSE(new MintMap.Position(bounds.getMin().y, bounds.getMin().x), new MintMap.Position(bounds.getMax().y, bounds.getMax().x));
492
+ return MintMap.Bounds.fromNWSE(new MintMap.Position(bounds.getMax().y, bounds.getMin().x), new MintMap.Position(bounds.getMin().y, bounds.getMax().x));
475
493
  };
476
494
 
477
495
  NaverMintMapController.prototype.panningTo = function (targetCenter) {
package/dist/index.es.js CHANGED
@@ -319,6 +319,7 @@ var MintMapController = function () {
319
319
  function MintMapController(props) {
320
320
  this.mapApiLoaded = false;
321
321
  this.mapInitialized = false;
322
+ this.processedTime = 0;
322
323
  this.mapProps = props;
323
324
  }
324
325
 
@@ -363,6 +364,18 @@ var MintMapController = function () {
363
364
  return "".concat(baseUrl, "?").concat(params);
364
365
  };
365
366
 
367
+ MintMapController.prototype.checkBoundsChangeThrottleTime = function () {
368
+ if (!this.mapProps.boundsChangeThrottlingTime) return true;
369
+ var time = new Date().getTime();
370
+
371
+ if (this.processedTime > 0 && time - this.processedTime < this.mapProps.boundsChangeThrottlingTime) {
372
+ return false;
373
+ } else {
374
+ this.processedTime = time;
375
+ return true;
376
+ }
377
+ };
378
+
366
379
  return MintMapController;
367
380
  }();
368
381
 
@@ -535,8 +548,18 @@ var NaverMintMapController = function (_super) {
535
548
 
536
549
  NaverMintMapController.prototype.updatePolygon = function (polygon, options) {
537
550
  if (polygon && polygon.native && polygon.native instanceof naver.maps.Polygon) {
551
+ var paths = void 0;
552
+
553
+ if (Array.isArray(options.position)) {
554
+ var outLine = options.position.map(function (elem) {
555
+ return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
556
+ });
557
+ paths = [outLine];
558
+ options.innerPositions && paths.push.apply(paths, options.innerPositions);
559
+ }
560
+
538
561
  polygon.native.setOptions({
539
- paths: polygon.native.getPaths(),
562
+ paths: paths || polygon.native.getPaths(),
540
563
  visible: options.visible === undefined || options.visible,
541
564
  strokeColor: options.lineColor,
542
565
  strokeWeight: options.lineSize,
@@ -800,17 +823,25 @@ var NaverMintMapController = function (_super) {
800
823
  _this.dragged = true;
801
824
  }
802
825
  });
803
- map.addListener('idle', function () {
804
- _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
826
+ map.addListener('idle', function (e) {
827
+ _this.map && _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
805
828
  });
806
829
  map.addListener('zoom_changed', function () {
807
830
  _this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
808
831
  });
809
832
  map.addListener('click', function (e) {
810
- console.log('map click', e);
833
+ if (!_this.mapProps.onClick) return;
811
834
  var pos = new Position(e.coord.y, e.coord.x);
812
835
  pos.offset = new Offset(e.offset.x, e.offset.y);
813
- _this.mapProps.onClick && _this.mapProps.onClick(pos);
836
+
837
+ _this.mapProps.onClick(pos);
838
+ });
839
+ map.addListener('mousemove', function (e) {
840
+ if (!_this.mapProps.onMouseMove) return;
841
+ var pos = new Position(e.coord.y, e.coord.x);
842
+ pos.offset = new Offset(e.offset.x, e.offset.y);
843
+
844
+ _this.mapProps.onMouseMove(pos);
814
845
  });
815
846
  this.map = map;
816
847
  this.mapInitialized = true;
@@ -839,14 +870,14 @@ var NaverMintMapController = function (_super) {
839
870
  NaverMintMapController.prototype.destroyMap = function () {
840
871
  var _a;
841
872
 
842
- console.log("".concat(this.type, " map destroyed"));
843
-
844
873
  try {
845
874
  this.map && this.map.destroy();
846
875
  (_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.destroy();
847
876
  } catch (e) {
848
877
  console.log('naver map destroy error', e);
849
878
  }
879
+
880
+ console.log("".concat(this.type, " map destroyed"));
850
881
  };
851
882
 
852
883
  NaverMintMapController.prototype.getCurrBounds = function () {
@@ -855,7 +886,7 @@ var NaverMintMapController = function (_super) {
855
886
  }
856
887
 
857
888
  var bounds = this.map.getBounds();
858
- return Bounds.fromNWSE(new Position(bounds.getMin().y, bounds.getMin().x), new Position(bounds.getMax().y, bounds.getMax().x));
889
+ return Bounds.fromNWSE(new Position(bounds.getMax().y, bounds.getMin().x), new Position(bounds.getMin().y, bounds.getMax().x));
859
890
  };
860
891
 
861
892
  NaverMintMapController.prototype.panningTo = function (targetCenter) {
@@ -897,7 +928,13 @@ var GoogleMintMapController = function (_super) {
897
928
  _this.dragged = false;
898
929
 
899
930
  _this.destroyMap = function () {
900
- console.log("".concat(_this.type, " map destroy feature is not supported"));
931
+ try {
932
+ _this.map && google.maps.event.clearInstanceListeners(_this.map);
933
+ } catch (e) {
934
+ console.log('google map destroy error', e);
935
+ }
936
+
937
+ console.log("".concat(_this.type, " map destroyed"));
901
938
  };
902
939
 
903
940
  console.log("".concat(_this.type, " controller loadded"));
@@ -1011,6 +1048,16 @@ var GoogleMintMapController = function (_super) {
1011
1048
  GoogleMintMapController.prototype.updatePolygon = function (polygon, options) {
1012
1049
  if (polygon && polygon.native && polygon.native instanceof google.maps.Polygon) {
1013
1050
  var polygonOption = this.getValidOptions(options);
1051
+
1052
+ if (this.map && Array.isArray(options.position)) {
1053
+ var outLine = options.position.map(function (elem) {
1054
+ return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
1055
+ });
1056
+ var paths = [outLine];
1057
+ options.innerPositions && paths.push.apply(paths, options.innerPositions);
1058
+ polygonOption.paths = paths;
1059
+ }
1060
+
1014
1061
  polygon.native.setOptions(polygonOption);
1015
1062
  }
1016
1063
  };
@@ -1242,18 +1289,28 @@ var GoogleMintMapController = function (_super) {
1242
1289
  minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
1243
1290
  zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
1244
1291
  disableDefaultUI: true,
1245
- gestureHandling: 'greedy'
1292
+ gestureHandling: 'greedy',
1293
+ clickableIcons: false
1246
1294
  });
1247
1295
  map.addListener('idle', function () {
1248
- _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
1296
+ _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
1249
1297
  });
1250
1298
  map.addListener('zoom_changed', function () {
1251
1299
  _this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
1252
1300
  });
1253
1301
  map.addListener('click', function (e) {
1302
+ if (!_this.mapProps.onClick) return;
1254
1303
  var pos = new Position(e.latLng.lat(), e.latLng.lng());
1255
1304
  pos.offset = new Offset(e.pixel.x, e.pixel.y);
1256
- _this.mapProps.onClick && _this.mapProps.onClick(pos);
1305
+
1306
+ _this.mapProps.onClick(pos);
1307
+ });
1308
+ map.addListener('mousemove', function (e) {
1309
+ if (!_this.mapProps.onMouseMove) return;
1310
+ var pos = new Position(e.latLng.lat(), e.latLng.lng());
1311
+ pos.offset = new Offset(e.pixel.x, e.pixel.y);
1312
+
1313
+ _this.mapProps.onMouseMove(pos);
1257
1314
  });
1258
1315
  this.map = map;
1259
1316
  this.mapInitialized = true;
@@ -1355,7 +1412,11 @@ var Bounds = function () {
1355
1412
  };
1356
1413
 
1357
1414
  Bounds.prototype.getCenter = function () {
1358
- return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
1415
+ return new Position(this.se.lat + (this.nw.lat - this.se.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
1416
+ };
1417
+
1418
+ Bounds.prototype.includesPosition = function (pos) {
1419
+ return this.nw.lng < pos.lng && this.se.lng > pos.lng && this.se.lat < pos.lat && this.nw.lat > pos.lat;
1359
1420
  };
1360
1421
 
1361
1422
  Bounds.prototype.getIncludedPositions = function (positions) {
@@ -1364,7 +1425,7 @@ var Bounds = function () {
1364
1425
  for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
1365
1426
  var pos = positions_1[_i];
1366
1427
 
1367
- if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
1428
+ if (this.includesPosition(pos)) {
1368
1429
  result.push(pos);
1369
1430
  }
1370
1431
  }
@@ -1378,7 +1439,7 @@ var Bounds = function () {
1378
1439
  for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
1379
1440
  var pos = positions_2[_i];
1380
1441
 
1381
- if (this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng) {
1442
+ if (!this.includesPosition(pos)) {
1382
1443
  return false;
1383
1444
  }
1384
1445
  }
@@ -1390,7 +1451,7 @@ var Bounds = function () {
1390
1451
  for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) {
1391
1452
  var pos = positions_3[_i];
1392
1453
 
1393
- if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
1454
+ if (this.includesPosition(pos)) {
1394
1455
  return true;
1395
1456
  }
1396
1457
  }
@@ -1930,7 +1991,7 @@ function MapPolygonWrapper(_a) {
1930
1991
  useEffect(function () {
1931
1992
  return function () {
1932
1993
  if (polygonRef.current) {
1933
- console.log('polygon cleared', controller.clearDrawable(polygonRef.current));
1994
+ controller.clearDrawable(polygonRef.current);
1934
1995
  }
1935
1996
  };
1936
1997
  }, []);
@@ -2183,7 +2244,7 @@ function MapPolylineWrapper(_a) {
2183
2244
  useEffect(function () {
2184
2245
  return function () {
2185
2246
  if (polylineRef.current) {
2186
- console.log('polyline cleared', controller.clearDrawable(polylineRef.current));
2247
+ controller.clearDrawable(polylineRef.current);
2187
2248
  }
2188
2249
  };
2189
2250
  }, []);
package/dist/index.umd.js CHANGED
@@ -324,6 +324,7 @@
324
324
  function MintMapController(props) {
325
325
  this.mapApiLoaded = false;
326
326
  this.mapInitialized = false;
327
+ this.processedTime = 0;
327
328
  this.mapProps = props;
328
329
  }
329
330
 
@@ -368,6 +369,18 @@
368
369
  return "".concat(baseUrl, "?").concat(params);
369
370
  };
370
371
 
372
+ MintMapController.prototype.checkBoundsChangeThrottleTime = function () {
373
+ if (!this.mapProps.boundsChangeThrottlingTime) return true;
374
+ var time = new Date().getTime();
375
+
376
+ if (this.processedTime > 0 && time - this.processedTime < this.mapProps.boundsChangeThrottlingTime) {
377
+ return false;
378
+ } else {
379
+ this.processedTime = time;
380
+ return true;
381
+ }
382
+ };
383
+
371
384
  return MintMapController;
372
385
  }();
373
386
 
@@ -540,8 +553,18 @@
540
553
 
541
554
  NaverMintMapController.prototype.updatePolygon = function (polygon, options) {
542
555
  if (polygon && polygon.native && polygon.native instanceof naver.maps.Polygon) {
556
+ var paths = void 0;
557
+
558
+ if (Array.isArray(options.position)) {
559
+ var outLine = options.position.map(function (elem) {
560
+ return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
561
+ });
562
+ paths = [outLine];
563
+ options.innerPositions && paths.push.apply(paths, options.innerPositions);
564
+ }
565
+
543
566
  polygon.native.setOptions({
544
- paths: polygon.native.getPaths(),
567
+ paths: paths || polygon.native.getPaths(),
545
568
  visible: options.visible === undefined || options.visible,
546
569
  strokeColor: options.lineColor,
547
570
  strokeWeight: options.lineSize,
@@ -805,17 +828,25 @@
805
828
  _this.dragged = true;
806
829
  }
807
830
  });
808
- map.addListener('idle', function () {
809
- _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
831
+ map.addListener('idle', function (e) {
832
+ _this.map && _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
810
833
  });
811
834
  map.addListener('zoom_changed', function () {
812
835
  _this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
813
836
  });
814
837
  map.addListener('click', function (e) {
815
- console.log('map click', e);
838
+ if (!_this.mapProps.onClick) return;
816
839
  var pos = new Position(e.coord.y, e.coord.x);
817
840
  pos.offset = new Offset(e.offset.x, e.offset.y);
818
- _this.mapProps.onClick && _this.mapProps.onClick(pos);
841
+
842
+ _this.mapProps.onClick(pos);
843
+ });
844
+ map.addListener('mousemove', function (e) {
845
+ if (!_this.mapProps.onMouseMove) return;
846
+ var pos = new Position(e.coord.y, e.coord.x);
847
+ pos.offset = new Offset(e.offset.x, e.offset.y);
848
+
849
+ _this.mapProps.onMouseMove(pos);
819
850
  });
820
851
  this.map = map;
821
852
  this.mapInitialized = true;
@@ -844,14 +875,14 @@
844
875
  NaverMintMapController.prototype.destroyMap = function () {
845
876
  var _a;
846
877
 
847
- console.log("".concat(this.type, " map destroyed"));
848
-
849
878
  try {
850
879
  this.map && this.map.destroy();
851
880
  (_a = this.markerPool) === null || _a === void 0 ? void 0 : _a.destroy();
852
881
  } catch (e) {
853
882
  console.log('naver map destroy error', e);
854
883
  }
884
+
885
+ console.log("".concat(this.type, " map destroyed"));
855
886
  };
856
887
 
857
888
  NaverMintMapController.prototype.getCurrBounds = function () {
@@ -860,7 +891,7 @@
860
891
  }
861
892
 
862
893
  var bounds = this.map.getBounds();
863
- return Bounds.fromNWSE(new Position(bounds.getMin().y, bounds.getMin().x), new Position(bounds.getMax().y, bounds.getMax().x));
894
+ return Bounds.fromNWSE(new Position(bounds.getMax().y, bounds.getMin().x), new Position(bounds.getMin().y, bounds.getMax().x));
864
895
  };
865
896
 
866
897
  NaverMintMapController.prototype.panningTo = function (targetCenter) {
@@ -902,7 +933,13 @@
902
933
  _this.dragged = false;
903
934
 
904
935
  _this.destroyMap = function () {
905
- console.log("".concat(_this.type, " map destroy feature is not supported"));
936
+ try {
937
+ _this.map && google.maps.event.clearInstanceListeners(_this.map);
938
+ } catch (e) {
939
+ console.log('google map destroy error', e);
940
+ }
941
+
942
+ console.log("".concat(_this.type, " map destroyed"));
906
943
  };
907
944
 
908
945
  console.log("".concat(_this.type, " controller loadded"));
@@ -1016,6 +1053,16 @@
1016
1053
  GoogleMintMapController.prototype.updatePolygon = function (polygon, options) {
1017
1054
  if (polygon && polygon.native && polygon.native instanceof google.maps.Polygon) {
1018
1055
  var polygonOption = this.getValidOptions(options);
1056
+
1057
+ if (this.map && Array.isArray(options.position)) {
1058
+ var outLine = options.position.map(function (elem) {
1059
+ return Array.isArray(elem) ? new Position(elem[1], elem[0]) : elem;
1060
+ });
1061
+ var paths = [outLine];
1062
+ options.innerPositions && paths.push.apply(paths, options.innerPositions);
1063
+ polygonOption.paths = paths;
1064
+ }
1065
+
1019
1066
  polygon.native.setOptions(polygonOption);
1020
1067
  }
1021
1068
  };
@@ -1247,18 +1294,28 @@
1247
1294
  minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
1248
1295
  zoom: (_d = this.mapProps.base) === null || _d === void 0 ? void 0 : _d.zoomLevel,
1249
1296
  disableDefaultUI: true,
1250
- gestureHandling: 'greedy'
1297
+ gestureHandling: 'greedy',
1298
+ clickableIcons: false
1251
1299
  });
1252
1300
  map.addListener('idle', function () {
1253
- _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
1301
+ _this.checkBoundsChangeThrottleTime() && _this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
1254
1302
  });
1255
1303
  map.addListener('zoom_changed', function () {
1256
1304
  _this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
1257
1305
  });
1258
1306
  map.addListener('click', function (e) {
1307
+ if (!_this.mapProps.onClick) return;
1259
1308
  var pos = new Position(e.latLng.lat(), e.latLng.lng());
1260
1309
  pos.offset = new Offset(e.pixel.x, e.pixel.y);
1261
- _this.mapProps.onClick && _this.mapProps.onClick(pos);
1310
+
1311
+ _this.mapProps.onClick(pos);
1312
+ });
1313
+ map.addListener('mousemove', function (e) {
1314
+ if (!_this.mapProps.onMouseMove) return;
1315
+ var pos = new Position(e.latLng.lat(), e.latLng.lng());
1316
+ pos.offset = new Offset(e.pixel.x, e.pixel.y);
1317
+
1318
+ _this.mapProps.onMouseMove(pos);
1262
1319
  });
1263
1320
  this.map = map;
1264
1321
  this.mapInitialized = true;
@@ -1360,7 +1417,11 @@
1360
1417
  };
1361
1418
 
1362
1419
  Bounds.prototype.getCenter = function () {
1363
- return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
1420
+ return new Position(this.se.lat + (this.nw.lat - this.se.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
1421
+ };
1422
+
1423
+ Bounds.prototype.includesPosition = function (pos) {
1424
+ return this.nw.lng < pos.lng && this.se.lng > pos.lng && this.se.lat < pos.lat && this.nw.lat > pos.lat;
1364
1425
  };
1365
1426
 
1366
1427
  Bounds.prototype.getIncludedPositions = function (positions) {
@@ -1369,7 +1430,7 @@
1369
1430
  for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
1370
1431
  var pos = positions_1[_i];
1371
1432
 
1372
- if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
1433
+ if (this.includesPosition(pos)) {
1373
1434
  result.push(pos);
1374
1435
  }
1375
1436
  }
@@ -1383,7 +1444,7 @@
1383
1444
  for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
1384
1445
  var pos = positions_2[_i];
1385
1446
 
1386
- if (this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng) {
1447
+ if (!this.includesPosition(pos)) {
1387
1448
  return false;
1388
1449
  }
1389
1450
  }
@@ -1395,7 +1456,7 @@
1395
1456
  for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) {
1396
1457
  var pos = positions_3[_i];
1397
1458
 
1398
- if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
1459
+ if (this.includesPosition(pos)) {
1399
1460
  return true;
1400
1461
  }
1401
1462
  }
@@ -1935,7 +1996,7 @@
1935
1996
  React.useEffect(function () {
1936
1997
  return function () {
1937
1998
  if (polygonRef.current) {
1938
- console.log('polygon cleared', controller.clearDrawable(polygonRef.current));
1999
+ controller.clearDrawable(polygonRef.current);
1939
2000
  }
1940
2001
  };
1941
2002
  }, []);
@@ -2188,7 +2249,7 @@
2188
2249
  React.useEffect(function () {
2189
2250
  return function () {
2190
2251
  if (polylineRef.current) {
2191
- console.log('polyline cleared', controller.clearDrawable(polylineRef.current));
2252
+ controller.clearDrawable(polylineRef.current);
2192
2253
  }
2193
2254
  };
2194
2255
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mint-ui/map",
3
- "version": "0.2.1-beta",
3
+ "version": "0.3.0-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "browser": "./dist/index.umd.js",