@antv/l7-component 2.21.0 → 2.21.2

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 (83) 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 -393
  16. package/es/control/zoom.js +80 -112
  17. package/es/css/index.css +10 -7
  18. package/es/index.js +667 -1
  19. package/es/marker-layer.js +274 -326
  20. package/es/marker.d.ts +0 -2
  21. package/es/marker.js +394 -453
  22. package/es/popup/layerPopup.js +277 -321
  23. package/es/popup/popup.js +422 -482
  24. package/es/utils/anchor.js +6 -6
  25. package/es/utils/icon.js +4 -4
  26. package/es/utils/popper.js +180 -196
  27. package/es/utils/screenfull.js +29 -51
  28. package/lib/assets/iconfont/iconfont.js +6 -6
  29. package/lib/constants/index.d.ts +60 -0
  30. package/lib/constants/index.js +2 -2
  31. package/lib/control/baseControl/buttonControl.d.ts +60 -0
  32. package/lib/control/baseControl/buttonControl.js +110 -143
  33. package/lib/control/baseControl/control.d.ts +112 -0
  34. package/lib/control/baseControl/control.js +213 -257
  35. package/lib/control/baseControl/index.d.ts +4 -0
  36. package/lib/control/baseControl/index.js +5 -5
  37. package/lib/control/baseControl/popperControl.d.ts +28 -0
  38. package/lib/control/baseControl/popperControl.js +68 -94
  39. package/lib/control/baseControl/selectControl.d.ts +53 -0
  40. package/lib/control/baseControl/selectControl.js +133 -177
  41. package/lib/control/exportImage.d.ts +19 -0
  42. package/lib/control/exportImage.js +60 -141
  43. package/lib/control/fullscreen.d.ts +20 -0
  44. package/lib/control/fullscreen.js +70 -99
  45. package/lib/control/geoLocate.d.ts +17 -0
  46. package/lib/control/geoLocate.js +38 -83
  47. package/lib/control/layerSwitch.d.ts +27 -0
  48. package/lib/control/layerSwitch.js +112 -153
  49. package/lib/control/logo.d.ts +14 -0
  50. package/lib/control/logo.js +44 -69
  51. package/lib/control/mapTheme.d.ts +11 -0
  52. package/lib/control/mapTheme.js +58 -97
  53. package/lib/control/mouseLocation.d.ts +16 -0
  54. package/lib/control/mouseLocation.js +38 -68
  55. package/lib/control/scale.d.ts +35 -0
  56. package/lib/control/scale.js +108 -134
  57. package/lib/control/swipe.d.ts +66 -0
  58. package/lib/control/swipe.js +298 -392
  59. package/lib/control/zoom.d.ts +39 -0
  60. package/lib/control/zoom.js +81 -111
  61. package/lib/css/index.css +10 -7
  62. package/lib/index.d.ts +19 -0
  63. package/lib/index.js +683 -17
  64. package/lib/interface.d.ts +18 -0
  65. package/lib/marker-layer.d.ts +55 -0
  66. package/lib/marker-layer.js +276 -324
  67. package/lib/marker.d.ts +58 -0
  68. package/lib/marker.js +395 -452
  69. package/lib/popup/layerPopup.d.ts +99 -0
  70. package/lib/popup/layerPopup.js +278 -320
  71. package/lib/popup/popup.d.ts +142 -0
  72. package/lib/popup/popup.js +423 -481
  73. package/lib/utils/anchor.d.ts +22 -0
  74. package/lib/utils/anchor.js +6 -6
  75. package/lib/utils/icon.d.ts +1 -0
  76. package/lib/utils/icon.js +6 -5
  77. package/lib/utils/popper.d.ts +76 -0
  78. package/lib/utils/popper.js +184 -196
  79. package/lib/utils/screenfull.d.ts +2 -0
  80. package/lib/utils/screenfull.js +29 -52
  81. package/package.json +16 -20
  82. package/CHANGELOG.md +0 -325
  83. package/LICENSE.md +0 -21
@@ -1,302 +1,256 @@
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 _inherits from "@babel/runtime/helpers/esm/inherits";
6
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
7
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
- 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); }; }
10
- 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; } }
11
3
  import { PositionType } from '@antv/l7-core';
12
4
  import { DOM } from '@antv/l7-utils';
13
5
  import EventEmitter from 'eventemitter3';
14
6
  export { PositionType } from '@antv/l7-core';
15
7
  export { Control };
16
- var Control = /*#__PURE__*/function (_ref) {
17
- _inherits(Control, _ref);
18
- var _super = _createSuper(Control);
19
- /**
20
- * 当前控件实例配置
21
- */
8
+ export default class Control extends EventEmitter {
9
+ constructor(option) {
10
+ super();
11
+ /**
12
+ * 当前控件实例配置
13
+ */
14
+ _defineProperty(this, "controlOption", void 0);
15
+ /**
16
+ * 控件的 DOM 容器
17
+ * @protected
18
+ */
19
+ _defineProperty(this, "container", void 0);
20
+ /**
21
+ * 当前控件是否显示
22
+ * @protected
23
+ */
24
+ _defineProperty(this, "isShow", void 0);
25
+ _defineProperty(this, "sceneContainer", void 0);
26
+ _defineProperty(this, "scene", void 0);
27
+ _defineProperty(this, "mapsService", void 0);
28
+ _defineProperty(this, "renderService", void 0);
29
+ _defineProperty(this, "layerService", void 0);
30
+ _defineProperty(this, "controlService", void 0);
31
+ _defineProperty(this, "configService", void 0);
32
+ Control.controlCount++;
33
+ this.controlOption = _objectSpread(_objectSpread({}, this.getDefault(option)), option || {});
34
+ }
35
+ getOptions() {
36
+ return this.controlOption;
37
+ }
22
38
 
23
39
  /**
24
- * 控件的 DOM 容器
25
- * @protected
40
+ * 更新配置的方法,子类如果有自己的配置,也需要重写该方法
41
+ * @param newOptions
26
42
  */
43
+ setOptions(newOptions) {
44
+ const defaultOptions = this.getDefault(newOptions);
45
+ Object.entries(newOptions).forEach(([key, value]) => {
46
+ if (value === undefined) {
47
+ newOptions[key] = defaultOptions[key];
48
+ }
49
+ });
50
+ if ('position' in newOptions) {
51
+ this.setPosition(newOptions.position);
52
+ }
53
+ if ('className' in newOptions) {
54
+ this.setClassName(newOptions.className);
55
+ }
56
+ if ('style' in newOptions) {
57
+ this.setStyle(newOptions.style);
58
+ }
59
+ this.controlOption = _objectSpread(_objectSpread({}, this.controlOption), newOptions);
60
+ }
27
61
 
28
62
  /**
29
- * 当前控件是否显示
30
- * @protected
63
+ * 当 Control 被添加至 Scene 中,被 controlService 调用的方法
64
+ * @param sceneContainer
31
65
  */
66
+ addTo(sceneContainer) {
67
+ // 初始化各个 Service 实例
68
+ this.mapsService = sceneContainer.mapService;
69
+ this.renderService = sceneContainer.rendererService;
70
+ this.layerService = sceneContainer.layerService;
71
+ this.controlService = sceneContainer.controlService;
72
+ this.configService = sceneContainer.globalConfigService;
73
+ this.scene = sceneContainer.sceneService;
74
+ this.sceneContainer = sceneContainer;
75
+ this.isShow = true;
32
76
 
33
- function Control(option) {
34
- var _this;
35
- _classCallCheck(this, Control);
36
- _this = _super.call(this);
37
- Control.controlCount++;
38
- _this.controlOption = _objectSpread(_objectSpread({}, _this.getDefault(option)), option || {});
39
- return _this;
40
- }
41
- _createClass(Control, [{
42
- key: "getOptions",
43
- value: function getOptions() {
44
- return this.controlOption;
77
+ // 初始化 container
78
+ this.container = this.onAdd();
79
+ DOM.addClass(this.container, 'l7-control');
80
+ const {
81
+ className,
82
+ style
83
+ } = this.controlOption;
84
+ if (className) {
85
+ this.setClassName(className);
45
86
  }
46
-
47
- /**
48
- * 更新配置的方法,子类如果有自己的配置,也需要重写该方法
49
- * @param newOptions
50
- */
51
- }, {
52
- key: "setOptions",
53
- value: function setOptions(newOptions) {
54
- var defaultOptions = this.getDefault(newOptions);
55
- Object.entries(newOptions).forEach(function (_ref2) {
56
- var _ref3 = _slicedToArray(_ref2, 2),
57
- key = _ref3[0],
58
- value = _ref3[1];
59
- if (value === undefined) {
60
- newOptions[key] = defaultOptions[key];
61
- }
62
- });
63
- if ('position' in newOptions) {
64
- this.setPosition(newOptions.position);
65
- }
66
- if ('className' in newOptions) {
67
- this.setClassName(newOptions.className);
68
- }
69
- if ('style' in newOptions) {
70
- this.setStyle(newOptions.style);
71
- }
72
- this.controlOption = _objectSpread(_objectSpread({}, this.controlOption), newOptions);
87
+ if (style) {
88
+ this.setStyle(style);
73
89
  }
90
+ // 将 container 插入容器中
91
+ this.insertContainer();
92
+ this.emit('add', this);
93
+ return this;
94
+ }
74
95
 
75
- /**
76
- * 当 Control 被添加至 Scene 中,被 controlService 调用的方法
77
- * @param sceneContainer
78
- */
79
- }, {
80
- key: "addTo",
81
- value: function addTo(sceneContainer) {
82
- // 初始化各个 Service 实例
83
- this.mapsService = sceneContainer.mapService;
84
- this.renderService = sceneContainer.rendererService;
85
- this.layerService = sceneContainer.layerService;
86
- this.controlService = sceneContainer.controlService;
87
- this.configService = sceneContainer.globalConfigService;
88
- this.scene = sceneContainer.sceneService;
89
- this.sceneContainer = sceneContainer;
90
- this.isShow = true;
91
-
92
- // 初始化 container
93
- this.container = this.onAdd();
94
- DOM.addClass(this.container, 'l7-control');
95
- var _this$controlOption = this.controlOption,
96
- className = _this$controlOption.className,
97
- style = _this$controlOption.style;
98
- if (className) {
99
- this.setClassName(className);
100
- }
101
- if (style) {
102
- this.setStyle(style);
103
- }
104
- // 将 container 插入容器中
105
- this.insertContainer();
106
- this.emit('add', this);
96
+ /**
97
+ * 将控件移除时触发
98
+ */
99
+ remove() {
100
+ if (!this.mapsService) {
107
101
  return this;
108
102
  }
103
+ DOM.remove(this.container);
104
+ this.onRemove();
105
+ this.emit('remove', this);
106
+ }
109
107
 
110
- /**
111
- * 将控件移除时触发
112
- */
113
- }, {
114
- key: "remove",
115
- value: function remove() {
116
- if (!this.mapsService) {
117
- return this;
118
- }
119
- DOM.remove(this.container);
120
- this.onRemove();
121
- this.emit('remove', this);
122
- }
108
+ /**
109
+ * Control 被添加的时候被调用,返回 Control 对应的 DOM 容器
110
+ */
111
+ onAdd() {
112
+ return DOM.create('div');
113
+ }
123
114
 
124
- /**
125
- * Control 被添加的时候被调用,返回 Control 对应的 DOM 容器
126
- */
127
- }, {
128
- key: "onAdd",
129
- value: function onAdd() {
130
- return DOM.create('div');
131
- }
115
+ /**
116
+ * Control 被移除时调用
117
+ */
118
+ // tslint:disable-next-line:no-empty
119
+ onRemove() {}
132
120
 
133
- /**
134
- * Control 被移除时调用
135
- */
136
- // tslint:disable-next-line:no-empty
137
- }, {
138
- key: "onRemove",
139
- value: function onRemove() {}
121
+ /**
122
+ * 显示控件时触发
123
+ */
124
+ show() {
125
+ const container = this.container;
126
+ DOM.removeClass(container, 'l7-control--hide');
127
+ this.isShow = true;
128
+ this.emit('show', this);
129
+ }
140
130
 
141
- /**
142
- * 显示控件时触发
143
- */
144
- }, {
145
- key: "show",
146
- value: function show() {
147
- var container = this.container;
148
- DOM.removeClass(container, 'l7-control--hide');
149
- this.isShow = true;
150
- this.emit('show', this);
151
- }
131
+ /**
132
+ * 隐藏控件时触发
133
+ */
134
+ hide() {
135
+ const container = this.container;
136
+ DOM.addClass(container, 'l7-control--hide');
137
+ this.isShow = false;
138
+ this.emit('hide', this);
139
+ }
152
140
 
153
- /**
154
- * 隐藏控件时触发
155
- */
156
- }, {
157
- key: "hide",
158
- value: function hide() {
159
- var container = this.container;
160
- DOM.addClass(container, 'l7-control--hide');
161
- this.isShow = false;
162
- this.emit('hide', this);
163
- }
141
+ /**
142
+ * 获取默认构造器参数
143
+ */
144
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
145
+ getDefault(option) {
146
+ // tslint:disable-next-line:no-object-literal-type-assertion
147
+ return {
148
+ position: PositionType.TOPRIGHT,
149
+ name: `${Control.controlCount}`
150
+ };
151
+ }
164
152
 
165
- /**
166
- * 获取默认构造器参数
167
- */
168
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
169
- }, {
170
- key: "getDefault",
171
- value: function getDefault(option) {
172
- // tslint:disable-next-line:no-object-literal-type-assertion
173
- return {
174
- position: PositionType.TOPRIGHT,
175
- name: "".concat(Control.controlCount)
176
- };
177
- }
153
+ /**
154
+ * 获取当前控件对应的 DOM 容器
155
+ */
156
+ getContainer() {
157
+ return this.container;
158
+ }
178
159
 
179
- /**
180
- * 获取当前控件对应的 DOM 容器
181
- */
182
- }, {
183
- key: "getContainer",
184
- value: function getContainer() {
185
- return this.container;
160
+ /**
161
+ * 获取当前 Control 是否展示
162
+ */
163
+ getIsShow() {
164
+ return this.isShow;
165
+ }
166
+ _refocusOnMap(e) {
167
+ // if map exists and event is not a keyboard event
168
+ if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
169
+ const container = this.mapsService.getContainer();
170
+ if (container !== null) {
171
+ container.focus();
172
+ }
186
173
  }
174
+ }
187
175
 
188
- /**
189
- * 获取当前 Control 是否展示
190
- */
191
- }, {
192
- key: "getIsShow",
193
- value: function getIsShow() {
194
- return this.isShow;
176
+ /**
177
+ * 设置当前控件位置
178
+ * @param position
179
+ */
180
+ setPosition(position = PositionType.TOPLEFT) {
181
+ // 考虑组件的自动布局,需要销毁重建
182
+ const controlService = this.controlService;
183
+ if (controlService) {
184
+ controlService.removeControl(this);
195
185
  }
196
- }, {
197
- key: "_refocusOnMap",
198
- value: function _refocusOnMap(e) {
199
- // if map exists and event is not a keyboard event
200
- if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
201
- var container = this.mapsService.getContainer();
202
- if (container !== null) {
203
- container.focus();
204
- }
205
- }
186
+ this.controlOption.position = position;
187
+ if (controlService) {
188
+ controlService.addControl(this, this.sceneContainer);
206
189
  }
190
+ return this;
191
+ }
207
192
 
208
- /**
209
- * 设置当前控件位置
210
- * @param position
211
- */
212
- }, {
213
- key: "setPosition",
214
- value: function setPosition() {
215
- var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PositionType.TOPLEFT;
216
- // 考虑组件的自动布局,需要销毁重建
217
- var controlService = this.controlService;
218
- if (controlService) {
219
- controlService.removeControl(this);
220
- }
221
- this.controlOption.position = position;
222
- if (controlService) {
223
- controlService.addControl(this, this.sceneContainer);
224
- }
225
- return this;
193
+ /**
194
+ * 设置容器 container 的样式相关位置,包含 className
195
+ * @param className
196
+ */
197
+ setClassName(className) {
198
+ const container = this.container;
199
+ const {
200
+ className: oldClassName
201
+ } = this.controlOption;
202
+ if (oldClassName) {
203
+ DOM.removeClass(container, oldClassName);
226
204
  }
227
-
228
- /**
229
- * 设置容器 container 的样式相关位置,包含 className
230
- * @param className
231
- */
232
- }, {
233
- key: "setClassName",
234
- value: function setClassName(className) {
235
- var container = this.container;
236
- var oldClassName = this.controlOption.className;
237
- if (oldClassName) {
238
- DOM.removeClass(container, oldClassName);
239
- }
240
- if (className) {
241
- DOM.addClass(container, className);
242
- }
205
+ if (className) {
206
+ DOM.addClass(container, className);
243
207
  }
208
+ }
244
209
 
245
- /**
246
- * 设置容器 container 的样式相关位置,包含 style
247
- * @param style
248
- */
249
- }, {
250
- key: "setStyle",
251
- value: function setStyle(style) {
252
- var container = this.container;
253
- if (style) {
254
- container.setAttribute('style', style);
255
- } else {
256
- container.removeAttribute('style');
257
- }
210
+ /**
211
+ * 设置容器 container 的样式相关位置,包含 style
212
+ * @param style
213
+ */
214
+ setStyle(style) {
215
+ const container = this.container;
216
+ if (style) {
217
+ container.setAttribute('style', style);
218
+ } else {
219
+ container.removeAttribute('style');
258
220
  }
221
+ }
259
222
 
260
- /**
261
- * 将控件 DOM 插入到对应 position 的容器中
262
- * @protected
263
- */
264
- }, {
265
- key: "insertContainer",
266
- value: function insertContainer() {
267
- var position = this.controlOption.position;
268
- var container = this.container;
269
- if (position instanceof Element) {
270
- position.appendChild(container);
223
+ /**
224
+ * 将控件 DOM 插入到对应 position 的容器中
225
+ * @protected
226
+ */
227
+ insertContainer() {
228
+ const position = this.controlOption.position;
229
+ const container = this.container;
230
+ if (position instanceof Element) {
231
+ position.appendChild(container);
232
+ } else {
233
+ const corner = this.controlService.controlCorners[position];
234
+ if (['bottomleft', 'bottomright', 'righttop', 'rightbottom'].includes(position)) {
235
+ corner.insertBefore(container, corner.firstChild);
271
236
  } else {
272
- var corner = this.controlService.controlCorners[position];
273
- if (['bottomleft', 'bottomright', 'righttop', 'rightbottom'].includes(position)) {
274
- corner.insertBefore(container, corner.firstChild);
275
- } else {
276
- corner.appendChild(container);
277
- }
237
+ corner.appendChild(container);
278
238
  }
279
239
  }
240
+ }
280
241
 
281
- /**
282
- * 检查当前传入 option 是否包含 keys 字段
283
- * @param option
284
- * @param keys
285
- * @protected
286
- */
287
- }, {
288
- key: "checkUpdateOption",
289
- value: function checkUpdateOption(option, keys) {
290
- return keys.some(function (key) {
291
- return key in option;
292
- });
293
- }
294
- }]);
295
- return Control;
296
- }(EventEmitter);
242
+ /**
243
+ * 检查当前传入 option 是否包含 keys 字段
244
+ * @param option
245
+ * @param keys
246
+ * @protected
247
+ */
248
+ checkUpdateOption(option, keys) {
249
+ return keys.some(key => key in option);
250
+ }
251
+ }
297
252
  /**
298
253
  * 当前类型控件实例个数
299
254
  * @protected
300
255
  */
301
- _defineProperty(Control, "controlCount", 0);
302
- export { Control as default };
256
+ _defineProperty(Control, "controlCount", 0);