@antv/l7-component 2.10.15 → 2.11.1

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.
@@ -1,16 +1,16 @@
1
1
  import { IPopperControlOption, PopperControl } from './popperControl';
2
- declare type BaseOptionItem = {
2
+ type BaseOptionItem = {
3
3
  value: string;
4
4
  text: string;
5
5
  [key: string]: string;
6
6
  };
7
- declare type NormalOptionItem = BaseOptionItem & {
7
+ type NormalOptionItem = BaseOptionItem & {
8
8
  icon?: HTMLElement;
9
9
  };
10
- declare type ImageOptionItem = BaseOptionItem & {
10
+ type ImageOptionItem = BaseOptionItem & {
11
11
  img: string;
12
12
  };
13
- export declare type ControlOptionItem = ImageOptionItem | NormalOptionItem;
13
+ export type ControlOptionItem = ImageOptionItem | NormalOptionItem;
14
14
  export interface ISelectControlOption extends IPopperControlOption {
15
15
  options: ControlOptionItem[];
16
16
  defaultValue?: string | string[];
package/es/interface.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare type ControlEvent = 'show' | 'hide' | 'add' | 'remove' | string;
1
+ export type ControlEvent = 'show' | 'hide' | 'add' | 'remove' | string;
2
2
  export interface IMarkerStyleOption {
3
3
  element?: (...args: any[]) => any;
4
4
  style: {
package/es/marker.js CHANGED
@@ -39,7 +39,7 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
39
39
  });
40
40
 
41
41
  _this.markerOption = _objectSpread(_objectSpread({}, _this.getDefault()), option);
42
- bindAll(['update', 'onMove', 'onUp', 'addDragHandler', 'onMapClick'], _assertThisInitialized(_this));
42
+ bindAll(['update', 'onMove', 'onMapClick'], _assertThisInitialized(_this));
43
43
 
44
44
  _this.init();
45
45
 
@@ -87,11 +87,10 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
87
87
  if (this.mapsService) {
88
88
  this.mapsService.off('click', this.onMapClick);
89
89
  this.mapsService.off('move', this.update);
90
- this.mapsService.off('moveend', this.update);
91
- this.mapsService.off('mousedown', this.addDragHandler);
92
- this.mapsService.off('touchstart', this.addDragHandler);
93
- this.mapsService.off('mouseup', this.onUp);
94
- this.mapsService.off('touchend', this.onUp);
90
+ this.mapsService.off('moveend', this.update); // this.mapsService.off('mousedown', this.addDragHandler);
91
+ // this.mapsService.off('touchstart', this.addDragHandler);
92
+ // this.mapsService.off('mouseup', this.onUp);
93
+ // this.mapsService.off('touchend', this.onUp);
95
94
  }
96
95
 
97
96
  this.unRegisterMarkerEvent();
@@ -418,7 +417,7 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
418
417
  key: "addDragHandler",
419
418
  value: // eslint-disable-next-line @typescript-eslint/no-unused-vars
420
419
  function addDragHandler(e) {
421
- throw new Error('Method not implemented.');
420
+ return null;
422
421
  } // eslint-disable-next-line @typescript-eslint/no-unused-vars
423
422
 
424
423
  }, {
@@ -1,13 +1,13 @@
1
1
  import { ILayer, IPopupOption } from '@antv/l7-core';
2
2
  import { Container } from 'inversify';
3
3
  import Popup from './popup';
4
- export declare type LayerField = {
4
+ export type LayerField = {
5
5
  field: string;
6
6
  formatField?: ((field: string) => string) | string;
7
7
  formatValue?: ((value: any) => any) | string;
8
8
  getValue?: (feature: any) => any;
9
9
  };
10
- export declare type LayerPopupConfigItem = {
10
+ export type LayerPopupConfigItem = {
11
11
  layer: ILayer | string;
12
12
  fields: Array<LayerField | string>;
13
13
  };
@@ -16,7 +16,7 @@ export interface ILayerPopupOption extends IPopupOption {
16
16
  items?: LayerPopupConfigItem[];
17
17
  trigger: 'hover' | 'click';
18
18
  }
19
- declare type LayerMapInfo = {
19
+ type LayerMapInfo = {
20
20
  onMouseMove?: (layer: ILayer, e: any) => void;
21
21
  onMouseOut?: (layer: ILayer, e: any) => void;
22
22
  onClick?: (layer: ILayer, e: any) => void;
@@ -89,7 +89,6 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
89
89
  },
90
90
  offsets: [0, 10],
91
91
  closeButton: false,
92
- closeOnClick: false,
93
92
  autoClose: false,
94
93
  closeOnEsc: false
95
94
  });
package/es/popup/popup.js CHANGED
@@ -73,7 +73,7 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
73
73
  e.stopPropagation();
74
74
  }
75
75
 
76
- _this.remove();
76
+ _this.hide();
77
77
  });
78
78
 
79
79
  _defineProperty(_assertThisInitialized(_this), "update", function () {
@@ -208,7 +208,8 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
208
208
  this.mapsService.on('camerachange', this.update);
209
209
  this.mapsService.on('viewchange', this.update);
210
210
  this.scene = scene;
211
- this.update();
211
+ this.update(); // 临时关闭
212
+
212
213
  this.updateCloseOnClick();
213
214
  this.updateCloseOnEsc();
214
215
  this.updateFollowCursor();
@@ -305,6 +306,7 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
305
306
 
306
307
  if (this.checkUpdateOption(option, ['lngLat']) && option.lngLat) {
307
308
  this.setLnglat(option.lngLat);
309
+ this.show();
308
310
  }
309
311
 
310
312
  return this;
@@ -465,7 +467,7 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
465
467
  // tslint:disable-next-line:no-object-literal-type-assertion
466
468
  return {
467
469
  closeButton: true,
468
- closeOnClick: true,
470
+ closeOnClick: false,
469
471
  maxWidth: '240px',
470
472
  offsets: [0, 0],
471
473
  anchor: anchorType.BOTTOM,
@@ -502,11 +504,11 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
502
504
  var mapsService = this.mapsService;
503
505
 
504
506
  if (mapsService) {
505
- this.mapsService.off('click', this.onCloseButtonClick);
507
+ mapsService === null || mapsService === void 0 ? void 0 : mapsService.off('click', this.onCloseButtonClick);
506
508
 
507
509
  if (this.popupOption.closeOnClick && !onlyClear) {
508
510
  requestAnimationFrame(function () {
509
- _this3.mapsService.on('click', _this3.onCloseButtonClick);
511
+ mapsService === null || mapsService === void 0 ? void 0 : mapsService.on('click', _this3.onCloseButtonClick);
510
512
  });
511
513
  }
512
514
  }
@@ -514,31 +516,24 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
514
516
  }, {
515
517
  key: "updateCloseOnEsc",
516
518
  value: function updateCloseOnEsc(onlyClear) {
517
- var _this4 = this;
518
-
519
519
  window.removeEventListener('keydown', this.onKeyDown);
520
520
 
521
521
  if (this.popupOption.closeOnEsc && !onlyClear) {
522
- requestAnimationFrame(function () {
523
- window.addEventListener('keydown', _this4.onKeyDown);
524
- });
522
+ window.addEventListener('keydown', this.onKeyDown);
525
523
  }
526
524
  }
527
525
  }, {
528
526
  key: "updateFollowCursor",
529
527
  value: function updateFollowCursor(onlyClear) {
530
- var _this$mapsService,
531
- _this5 = this;
528
+ var _this$mapsService;
532
529
 
533
530
  var container = (_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 ? void 0 : _this$mapsService.getContainer();
534
531
 
535
532
  if (container) {
536
- container.removeEventListener('mousemove', this.onMouseMove);
533
+ container === null || container === void 0 ? void 0 : container.removeEventListener('mousemove', this.onMouseMove);
537
534
 
538
535
  if (this.popupOption.followCursor && !onlyClear) {
539
- requestAnimationFrame(function () {
540
- container.addEventListener('mousemove', _this5.onMouseMove);
541
- });
536
+ container === null || container === void 0 ? void 0 : container.addEventListener('mousemove', this.onMouseMove);
542
537
  }
543
538
  }
544
539
  }
@@ -550,6 +545,8 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
550
545
  * @protected
551
546
  */
552
547
  function createContent() {
548
+ var _this4 = this;
549
+
553
550
  if (this.content) {
554
551
  DOM.remove(this.content);
555
552
  }
@@ -578,7 +575,9 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
578
575
 
579
576
 
580
577
  closeButton.setAttribute('aria-label', 'Close popup');
581
- closeButton.addEventListener('click', this.onCloseButtonClick);
578
+ closeButton.addEventListener('click', function () {
579
+ _this4.hide();
580
+ });
582
581
  this.closeButton = closeButton;
583
582
  } else {
584
583
  this.closeButton = undefined;
@@ -2,15 +2,15 @@ import { EventEmitter } from 'eventemitter3';
2
2
  /**
3
3
  * 气泡位置枚举
4
4
  */
5
- export declare type PopperPlacement = 'top-start' | 'top' | 'top-end' | 'left-start' | 'left' | 'left-end' | 'bottom-start' | 'bottom' | 'bottom-end' | 'right-start' | 'right' | 'right-end';
5
+ export type PopperPlacement = 'top-start' | 'top' | 'top-end' | 'left-start' | 'left' | 'left-end' | 'bottom-start' | 'bottom' | 'bottom-end' | 'right-start' | 'right' | 'right-end';
6
6
  /**
7
7
  * 气泡触发类型,当前支持 click 和 hover 两种类型
8
8
  */
9
- export declare type PopperTrigger = 'click' | 'hover';
9
+ export type PopperTrigger = 'click' | 'hover';
10
10
  /**
11
11
  * 气泡内容类型
12
12
  */
13
- export declare type PopperContent = string | HTMLElement | null;
13
+ export type PopperContent = string | HTMLElement | null;
14
14
  export interface IPopperOption {
15
15
  placement: PopperPlacement;
16
16
  trigger: PopperTrigger;
package/lib/marker.js CHANGED
@@ -53,7 +53,7 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
53
53
  });
54
54
  });
55
55
  _this.markerOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _this.getDefault()), option);
56
- (0, _l7Utils.bindAll)(['update', 'onMove', 'onUp', 'addDragHandler', 'onMapClick'], (0, _assertThisInitialized2.default)(_this));
56
+ (0, _l7Utils.bindAll)(['update', 'onMove', 'onMapClick'], (0, _assertThisInitialized2.default)(_this));
57
57
 
58
58
  _this.init();
59
59
 
@@ -101,11 +101,10 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
101
101
  if (this.mapsService) {
102
102
  this.mapsService.off('click', this.onMapClick);
103
103
  this.mapsService.off('move', this.update);
104
- this.mapsService.off('moveend', this.update);
105
- this.mapsService.off('mousedown', this.addDragHandler);
106
- this.mapsService.off('touchstart', this.addDragHandler);
107
- this.mapsService.off('mouseup', this.onUp);
108
- this.mapsService.off('touchend', this.onUp);
104
+ this.mapsService.off('moveend', this.update); // this.mapsService.off('mousedown', this.addDragHandler);
105
+ // this.mapsService.off('touchstart', this.addDragHandler);
106
+ // this.mapsService.off('mouseup', this.onUp);
107
+ // this.mapsService.off('touchend', this.onUp);
109
108
  }
110
109
 
111
110
  this.unRegisterMarkerEvent();
@@ -434,7 +433,7 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
434
433
  key: "addDragHandler",
435
434
  value: // eslint-disable-next-line @typescript-eslint/no-unused-vars
436
435
  function addDragHandler(e) {
437
- throw new Error('Method not implemented.');
436
+ return null;
438
437
  } // eslint-disable-next-line @typescript-eslint/no-unused-vars
439
438
 
440
439
  }, {
@@ -100,7 +100,6 @@ var LayerPopup = /*#__PURE__*/function (_Popup) {
100
100
  },
101
101
  offsets: [0, 10],
102
102
  closeButton: false,
103
- closeOnClick: false,
104
103
  autoClose: false,
105
104
  closeOnEsc: false
106
105
  });
@@ -86,7 +86,7 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
86
86
  e.stopPropagation();
87
87
  }
88
88
 
89
- _this.remove();
89
+ _this.hide();
90
90
  });
91
91
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "update", function () {
92
92
  var hasPosition = !!_this.lngLat;
@@ -220,7 +220,8 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
220
220
  this.mapsService.on('camerachange', this.update);
221
221
  this.mapsService.on('viewchange', this.update);
222
222
  this.scene = scene;
223
- this.update();
223
+ this.update(); // 临时关闭
224
+
224
225
  this.updateCloseOnClick();
225
226
  this.updateCloseOnEsc();
226
227
  this.updateFollowCursor();
@@ -319,6 +320,7 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
319
320
 
320
321
  if (this.checkUpdateOption(option, ['lngLat']) && option.lngLat) {
321
322
  this.setLnglat(option.lngLat);
323
+ this.show();
322
324
  }
323
325
 
324
326
  return this;
@@ -479,7 +481,7 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
479
481
  // tslint:disable-next-line:no-object-literal-type-assertion
480
482
  return {
481
483
  closeButton: true,
482
- closeOnClick: true,
484
+ closeOnClick: false,
483
485
  maxWidth: '240px',
484
486
  offsets: [0, 0],
485
487
  anchor: _l7Utils.anchorType.BOTTOM,
@@ -516,11 +518,11 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
516
518
  var mapsService = this.mapsService;
517
519
 
518
520
  if (mapsService) {
519
- this.mapsService.off('click', this.onCloseButtonClick);
521
+ mapsService === null || mapsService === void 0 ? void 0 : mapsService.off('click', this.onCloseButtonClick);
520
522
 
521
523
  if (this.popupOption.closeOnClick && !onlyClear) {
522
524
  requestAnimationFrame(function () {
523
- _this3.mapsService.on('click', _this3.onCloseButtonClick);
525
+ mapsService === null || mapsService === void 0 ? void 0 : mapsService.on('click', _this3.onCloseButtonClick);
524
526
  });
525
527
  }
526
528
  }
@@ -528,31 +530,24 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
528
530
  }, {
529
531
  key: "updateCloseOnEsc",
530
532
  value: function updateCloseOnEsc(onlyClear) {
531
- var _this4 = this;
532
-
533
533
  window.removeEventListener('keydown', this.onKeyDown);
534
534
 
535
535
  if (this.popupOption.closeOnEsc && !onlyClear) {
536
- requestAnimationFrame(function () {
537
- window.addEventListener('keydown', _this4.onKeyDown);
538
- });
536
+ window.addEventListener('keydown', this.onKeyDown);
539
537
  }
540
538
  }
541
539
  }, {
542
540
  key: "updateFollowCursor",
543
541
  value: function updateFollowCursor(onlyClear) {
544
- var _this$mapsService,
545
- _this5 = this;
542
+ var _this$mapsService;
546
543
 
547
544
  var container = (_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 ? void 0 : _this$mapsService.getContainer();
548
545
 
549
546
  if (container) {
550
- container.removeEventListener('mousemove', this.onMouseMove);
547
+ container === null || container === void 0 ? void 0 : container.removeEventListener('mousemove', this.onMouseMove);
551
548
 
552
549
  if (this.popupOption.followCursor && !onlyClear) {
553
- requestAnimationFrame(function () {
554
- container.addEventListener('mousemove', _this5.onMouseMove);
555
- });
550
+ container === null || container === void 0 ? void 0 : container.addEventListener('mousemove', this.onMouseMove);
556
551
  }
557
552
  }
558
553
  }
@@ -564,6 +559,8 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
564
559
  * @protected
565
560
  */
566
561
  function createContent() {
562
+ var _this4 = this;
563
+
567
564
  if (this.content) {
568
565
  _l7Utils.DOM.remove(this.content);
569
566
  }
@@ -594,7 +591,9 @@ var Popup = /*#__PURE__*/function (_EventEmitter) {
594
591
 
595
592
 
596
593
  closeButton.setAttribute('aria-label', 'Close popup');
597
- closeButton.addEventListener('click', this.onCloseButtonClick);
594
+ closeButton.addEventListener('click', function () {
595
+ _this4.hide();
596
+ });
598
597
  this.closeButton = closeButton;
599
598
  } else {
600
599
  this.closeButton = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-component",
3
- "version": "2.10.15",
3
+ "version": "2.11.1",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -26,8 +26,8 @@
26
26
  "author": "lzxue",
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
- "@antv/l7-core": "2.10.15",
30
- "@antv/l7-utils": "2.10.15",
29
+ "@antv/l7-core": "2.11.1",
30
+ "@antv/l7-utils": "2.11.1",
31
31
  "@babel/runtime": "^7.7.7",
32
32
  "eventemitter3": "^4.0.0",
33
33
  "inversify": "^5.0.1",
@@ -36,11 +36,11 @@
36
36
  "supercluster": "^7.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@antv/l7-test-utils": "2.10.15",
39
+ "@antv/l7-test-utils": "2.11.1",
40
40
  "gcoord": "^0.3.2",
41
41
  "less": "^4.1.3"
42
42
  },
43
- "gitHead": "b567d8c716b042eeb7ab8e05d7e5e0f666469f98",
43
+ "gitHead": "e86da32e1999fdc36668de531d16ab14bce56279",
44
44
  "publishConfig": {
45
45
  "access": "public"
46
46
  }