@antv/l7-component 2.21.1 → 2.21.3

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.
Files changed (80) hide show
  1. package/es/assets/iconfont/iconfont.js +6 -6
  2. package/es/constants/index.js +2 -2
  3. package/es/control/baseControl/buttonControl.js +109 -144
  4. package/es/control/baseControl/control.js +212 -258
  5. package/es/control/baseControl/popperControl.js +67 -95
  6. package/es/control/baseControl/selectControl.js +132 -178
  7. package/es/control/exportImage.js +59 -142
  8. package/es/control/fullscreen.js +69 -100
  9. package/es/control/geoLocate.js +37 -84
  10. package/es/control/layerSwitch.js +111 -154
  11. package/es/control/logo.js +43 -69
  12. package/es/control/mapTheme.js +57 -98
  13. package/es/control/mouseLocation.js +37 -69
  14. package/es/control/scale.js +107 -135
  15. package/es/control/swipe.js +297 -389
  16. package/es/control/zoom.js +80 -112
  17. package/es/css/index.css +10 -7
  18. package/es/index.js +675 -1
  19. package/es/marker-layer.js +275 -326
  20. package/es/marker.js +394 -446
  21. package/es/popup/layerPopup.js +277 -321
  22. package/es/popup/popup.js +422 -482
  23. package/es/utils/anchor.js +6 -6
  24. package/es/utils/icon.js +4 -4
  25. package/es/utils/popper.js +180 -196
  26. package/es/utils/screenfull.js +29 -51
  27. package/lib/assets/iconfont/iconfont.js +6 -6
  28. package/lib/constants/index.d.ts +60 -0
  29. package/lib/constants/index.js +2 -2
  30. package/lib/control/baseControl/buttonControl.d.ts +60 -0
  31. package/lib/control/baseControl/buttonControl.js +110 -143
  32. package/lib/control/baseControl/control.d.ts +112 -0
  33. package/lib/control/baseControl/control.js +213 -257
  34. package/lib/control/baseControl/index.d.ts +4 -0
  35. package/lib/control/baseControl/index.js +5 -5
  36. package/lib/control/baseControl/popperControl.d.ts +28 -0
  37. package/lib/control/baseControl/popperControl.js +68 -94
  38. package/lib/control/baseControl/selectControl.d.ts +53 -0
  39. package/lib/control/baseControl/selectControl.js +133 -177
  40. package/lib/control/exportImage.d.ts +19 -0
  41. package/lib/control/exportImage.js +60 -141
  42. package/lib/control/fullscreen.d.ts +20 -0
  43. package/lib/control/fullscreen.js +70 -99
  44. package/lib/control/geoLocate.d.ts +17 -0
  45. package/lib/control/geoLocate.js +38 -83
  46. package/lib/control/layerSwitch.d.ts +27 -0
  47. package/lib/control/layerSwitch.js +112 -153
  48. package/lib/control/logo.d.ts +14 -0
  49. package/lib/control/logo.js +44 -69
  50. package/lib/control/mapTheme.d.ts +11 -0
  51. package/lib/control/mapTheme.js +58 -97
  52. package/lib/control/mouseLocation.d.ts +16 -0
  53. package/lib/control/mouseLocation.js +38 -68
  54. package/lib/control/scale.d.ts +35 -0
  55. package/lib/control/scale.js +108 -134
  56. package/lib/control/swipe.d.ts +66 -0
  57. package/lib/control/swipe.js +298 -388
  58. package/lib/control/zoom.d.ts +39 -0
  59. package/lib/control/zoom.js +81 -111
  60. package/lib/css/index.css +10 -7
  61. package/lib/index.d.ts +19 -0
  62. package/lib/index.js +691 -17
  63. package/lib/interface.d.ts +18 -0
  64. package/lib/marker-layer.d.ts +55 -0
  65. package/lib/marker-layer.js +277 -324
  66. package/lib/marker.d.ts +58 -0
  67. package/lib/marker.js +395 -445
  68. package/lib/popup/layerPopup.d.ts +99 -0
  69. package/lib/popup/layerPopup.js +278 -320
  70. package/lib/popup/popup.d.ts +142 -0
  71. package/lib/popup/popup.js +423 -481
  72. package/lib/utils/anchor.d.ts +22 -0
  73. package/lib/utils/anchor.js +6 -6
  74. package/lib/utils/icon.d.ts +1 -0
  75. package/lib/utils/icon.js +6 -5
  76. package/lib/utils/popper.d.ts +76 -0
  77. package/lib/utils/popper.js +184 -196
  78. package/lib/utils/screenfull.d.ts +2 -0
  79. package/lib/utils/screenfull.js +29 -52
  80. package/package.json +16 -20
@@ -1,83 +1,51 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/esm/createClass";
5
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
6
- import _get from "@babel/runtime/helpers/esm/get";
7
- import _inherits from "@babel/runtime/helpers/esm/inherits";
8
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
9
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
10
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
3
  import { PositionType } from '@antv/l7-core';
14
4
  import { DOM } from '@antv/l7-utils';
15
5
  import Control from "./baseControl/control";
16
6
  export { MouseLocation };
17
- var MouseLocation = /*#__PURE__*/function (_Control) {
18
- _inherits(MouseLocation, _Control);
19
- var _super = _createSuper(MouseLocation);
20
- function MouseLocation() {
21
- var _this;
22
- _classCallCheck(this, MouseLocation);
23
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24
- args[_key] = arguments[_key];
25
- }
26
- _this = _super.call.apply(_super, [this].concat(args));
27
- _defineProperty(_assertThisInitialized(_this), "location", [0, 0]);
28
- _defineProperty(_assertThisInitialized(_this), "onMouseMove", function (e) {
29
- var position = _this.location;
30
- var lngLat = e.lngLat || e.lnglat;
31
- var transform = _this.controlOption.transform;
7
+ export default class MouseLocation extends Control {
8
+ constructor(...args) {
9
+ super(...args);
10
+ _defineProperty(this, "location", [0, 0]);
11
+ _defineProperty(this, "onMouseMove", e => {
12
+ let position = this.location;
13
+ const lngLat = e.lngLat || e.lnglat;
14
+ const {
15
+ transform
16
+ } = this.controlOption;
32
17
  if (lngLat) {
33
18
  position = [lngLat.lng, lngLat.lat];
34
19
  }
35
- _this.location = position;
20
+ this.location = position;
36
21
  if (transform) {
37
22
  position = transform(position);
38
23
  }
39
- _this.insertLocation2HTML(position);
40
- _this.emit('locationChange', position);
24
+ this.insertLocation2HTML(position);
25
+ this.emit('locationChange', position);
41
26
  });
42
- return _this;
43
27
  }
44
- _createClass(MouseLocation, [{
45
- key: "getLocation",
46
- value: function getLocation() {
47
- return this.location;
48
- }
49
- }, {
50
- key: "getDefault",
51
- value: function getDefault(option) {
52
- return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(MouseLocation.prototype), "getDefault", this).call(this, option)), {}, {
53
- position: PositionType.BOTTOMLEFT,
54
- transform: function transform(_ref) {
55
- var _ref2 = _slicedToArray(_ref, 2),
56
- lng = _ref2[0],
57
- lat = _ref2[1];
58
- return [+(+lng).toFixed(6), +(+lat).toFixed(6)];
59
- }
60
- });
61
- }
62
- }, {
63
- key: "onAdd",
64
- value: function onAdd() {
65
- var container = DOM.create('div', 'l7-control-mouse-location');
66
- container.innerHTML = '&nbsp;';
67
- this.mapsService.on('mousemove', this.onMouseMove);
68
- return container;
69
- }
70
- }, {
71
- key: "onRemove",
72
- value: function onRemove() {
73
- this.mapsService.off('mousemove', this.onMouseMove);
74
- }
75
- }, {
76
- key: "insertLocation2HTML",
77
- value: function insertLocation2HTML(position) {
78
- this.container.innerText = position.join(', ');
79
- }
80
- }]);
81
- return MouseLocation;
82
- }(Control);
83
- export { MouseLocation as default };
28
+ getLocation() {
29
+ return this.location;
30
+ }
31
+ getDefault(option) {
32
+ return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
33
+ position: PositionType.BOTTOMLEFT,
34
+ transform: ([lng, lat]) => {
35
+ return [+(+lng).toFixed(6), +(+lat).toFixed(6)];
36
+ }
37
+ });
38
+ }
39
+ onAdd() {
40
+ const container = DOM.create('div', 'l7-control-mouse-location');
41
+ container.innerHTML = '&nbsp;';
42
+ this.mapsService.on('mousemove', this.onMouseMove);
43
+ return container;
44
+ }
45
+ onRemove() {
46
+ this.mapsService.off('mousemove', this.onMouseMove);
47
+ }
48
+ insertLocation2HTML(position) {
49
+ this.container.innerText = position.join(', ');
50
+ }
51
+ }
@@ -1,149 +1,121 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
- import _get from "@babel/runtime/helpers/esm/get";
6
- import _inherits from "@babel/runtime/helpers/esm/inherits";
7
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
8
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
3
  import { DOM, lnglatDistance } from '@antv/l7-utils';
13
4
  import { Control, PositionType } from "./baseControl";
14
5
  export { Scale };
15
- var Scale = /*#__PURE__*/function (_Control) {
16
- _inherits(Scale, _Control);
17
- var _super = _createSuper(Scale);
18
- function Scale() {
19
- var _this;
20
- _classCallCheck(this, Scale);
21
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
22
- args[_key] = arguments[_key];
23
- }
24
- _this = _super.call.apply(_super, [this].concat(args));
25
- _defineProperty(_assertThisInitialized(_this), "update", function () {
26
- var mapsService = _this.mapsService;
27
- var maxWidth = _this.controlOption.maxWidth;
28
- var y = mapsService.getSize()[1] / 2;
29
- var p1 = mapsService.containerToLngLat([0, y]);
30
- var p2 = mapsService.containerToLngLat([maxWidth, y]);
31
- var maxMeters = lnglatDistance([p1.lng, p1.lat], [p2.lng, p2.lat]);
32
- _this.updateScales(maxMeters);
6
+ export default class Scale extends Control {
7
+ constructor(...args) {
8
+ super(...args);
9
+ _defineProperty(this, "mScale", void 0);
10
+ _defineProperty(this, "iScale", void 0);
11
+ _defineProperty(this, "update", () => {
12
+ const mapsService = this.mapsService;
13
+ const {
14
+ maxWidth
15
+ } = this.controlOption;
16
+ const y = mapsService.getSize()[1] / 2;
17
+ const p1 = mapsService.containerToLngLat([0, y]);
18
+ const p2 = mapsService.containerToLngLat([maxWidth, y]);
19
+ const maxMeters = lnglatDistance([p1.lng, p1.lat], [p2.lng, p2.lat]);
20
+ this.updateScales(maxMeters);
33
21
  });
34
- return _this;
35
22
  }
36
- _createClass(Scale, [{
37
- key: "getDefault",
38
- value: function getDefault(option) {
39
- return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(Scale.prototype), "getDefault", this).call(this, option)), {}, {
40
- name: 'scale',
41
- position: PositionType.BOTTOMLEFT,
42
- maxWidth: 100,
43
- metric: true,
44
- updateWhenIdle: false,
45
- imperial: false,
46
- lockWidth: true
47
- });
48
- }
49
- }, {
50
- key: "onAdd",
51
- value: function onAdd() {
52
- var className = 'l7-control-scale';
53
- var container = DOM.create('div', className);
54
- this.resetScaleLines(container);
55
- var updateWhenIdle = this.controlOption.updateWhenIdle;
56
- this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
57
- this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
58
- return container;
59
- }
60
- }, {
61
- key: "onRemove",
62
- value: function onRemove() {
63
- var updateWhenIdle = this.controlOption.updateWhenIdle;
64
- this.mapsService.off(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
65
- this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
66
- }
67
- }, {
68
- key: "setOptions",
69
- value: function setOptions(newOption) {
70
- _get(_getPrototypeOf(Scale.prototype), "setOptions", this).call(this, newOption);
71
- if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
72
- this.resetScaleLines(this.container);
73
- }
23
+ getDefault(option) {
24
+ return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
25
+ name: 'scale',
26
+ position: PositionType.BOTTOMLEFT,
27
+ maxWidth: 100,
28
+ metric: true,
29
+ updateWhenIdle: false,
30
+ imperial: false,
31
+ lockWidth: true
32
+ });
33
+ }
34
+ onAdd() {
35
+ const className = 'l7-control-scale';
36
+ const container = DOM.create('div', className);
37
+ this.resetScaleLines(container);
38
+ const {
39
+ updateWhenIdle
40
+ } = this.controlOption;
41
+ this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
42
+ this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
43
+ return container;
44
+ }
45
+ onRemove() {
46
+ const {
47
+ updateWhenIdle
48
+ } = this.controlOption;
49
+ this.mapsService.off(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
50
+ this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
51
+ }
52
+ setOptions(newOption) {
53
+ super.setOptions(newOption);
54
+ if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
55
+ this.resetScaleLines(this.container);
74
56
  }
75
- }, {
76
- key: "updateScales",
77
- value: function updateScales(maxMeters) {
78
- var _this$controlOption = this.controlOption,
79
- metric = _this$controlOption.metric,
80
- imperial = _this$controlOption.imperial;
81
- if (metric && maxMeters) {
82
- this.updateMetric(maxMeters);
83
- }
84
- if (imperial && maxMeters) {
85
- this.updateImperial(maxMeters);
86
- }
57
+ }
58
+ updateScales(maxMeters) {
59
+ const {
60
+ metric,
61
+ imperial
62
+ } = this.controlOption;
63
+ if (metric && maxMeters) {
64
+ this.updateMetric(maxMeters);
87
65
  }
88
- }, {
89
- key: "resetScaleLines",
90
- value: function resetScaleLines(container) {
91
- DOM.clearChildren(container);
92
- var _this$controlOption2 = this.controlOption,
93
- metric = _this$controlOption2.metric,
94
- imperial = _this$controlOption2.imperial,
95
- maxWidth = _this$controlOption2.maxWidth,
96
- lockWidth = _this$controlOption2.lockWidth;
97
- if (lockWidth) {
98
- DOM.addStyle(container, "width: ".concat(maxWidth, "px"));
99
- }
100
- if (metric) {
101
- this.mScale = DOM.create('div', 'l7-control-scale-line', container);
102
- }
103
- if (imperial) {
104
- this.iScale = DOM.create('div', 'l7-control-scale-line', container);
105
- }
106
- this.update();
66
+ if (imperial && maxMeters) {
67
+ this.updateImperial(maxMeters);
107
68
  }
108
- }, {
109
- key: "updateScale",
110
- value: function updateScale(scale, text, ratio) {
111
- var maxWidth = this.controlOption.maxWidth;
112
- scale.style.width = Math.round(maxWidth * ratio) + 'px';
113
- scale.innerHTML = text;
69
+ }
70
+ resetScaleLines(container) {
71
+ DOM.clearChildren(container);
72
+ const {
73
+ metric,
74
+ imperial,
75
+ maxWidth,
76
+ lockWidth
77
+ } = this.controlOption;
78
+ if (lockWidth) {
79
+ DOM.addStyle(container, `width: ${maxWidth}px`);
114
80
  }
115
- }, {
116
- key: "getRoundNum",
117
- value: function getRoundNum(num) {
118
- var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
119
- var d = num / pow10;
120
- d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
121
- return pow10 * d;
81
+ if (metric) {
82
+ this.mScale = DOM.create('div', 'l7-control-scale-line', container);
122
83
  }
123
- }, {
124
- key: "updateMetric",
125
- value: function updateMetric(maxMeters) {
126
- var meters = this.getRoundNum(maxMeters);
127
- var label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
128
- this.updateScale(this.mScale, label, meters / maxMeters);
84
+ if (imperial) {
85
+ this.iScale = DOM.create('div', 'l7-control-scale-line', container);
129
86
  }
130
- }, {
131
- key: "updateImperial",
132
- value: function updateImperial(maxMeters) {
133
- var maxFeet = maxMeters * 3.2808399;
134
- var maxMiles;
135
- var miles;
136
- var feet;
137
- if (maxFeet > 5280) {
138
- maxMiles = maxFeet / 5280;
139
- miles = this.getRoundNum(maxMiles);
140
- this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
141
- } else {
142
- feet = this.getRoundNum(maxFeet);
143
- this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
144
- }
87
+ this.update();
88
+ }
89
+ updateScale(scale, text, ratio) {
90
+ const {
91
+ maxWidth
92
+ } = this.controlOption;
93
+ scale.style.width = Math.round(maxWidth * ratio) + 'px';
94
+ scale.innerHTML = text;
95
+ }
96
+ getRoundNum(num) {
97
+ const pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
98
+ let d = num / pow10;
99
+ d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
100
+ return pow10 * d;
101
+ }
102
+ updateMetric(maxMeters) {
103
+ const meters = this.getRoundNum(maxMeters);
104
+ const label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
105
+ this.updateScale(this.mScale, label, meters / maxMeters);
106
+ }
107
+ updateImperial(maxMeters) {
108
+ const maxFeet = maxMeters * 3.2808399;
109
+ let maxMiles;
110
+ let miles;
111
+ let feet;
112
+ if (maxFeet > 5280) {
113
+ maxMiles = maxFeet / 5280;
114
+ miles = this.getRoundNum(maxMiles);
115
+ this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
116
+ } else {
117
+ feet = this.getRoundNum(maxFeet);
118
+ this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
145
119
  }
146
- }]);
147
- return Scale;
148
- }(Control);
149
- export { Scale as default };
120
+ }
121
+ }