@antv/l7-component 2.9.32-alpha.4 → 2.9.32-alpha.5

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 (34) hide show
  1. package/es/control/baseControl/buttonControl.d.ts +1 -1
  2. package/es/control/baseControl/control.d.ts +4 -5
  3. package/es/control/baseControl/control.js +18 -5
  4. package/es/control/baseControl/popperControl.d.ts +1 -1
  5. package/es/control/baseControl/selectControl.d.ts +2 -2
  6. package/es/control/baseControl/selectControl.js +5 -0
  7. package/es/control/zoom.d.ts +3 -2
  8. package/lib/assets/iconfont/iconfont.js +46 -30
  9. package/lib/constants/index.js +34 -56
  10. package/lib/control/baseControl/buttonControl.js +194 -105
  11. package/lib/control/baseControl/control.js +317 -156
  12. package/lib/control/baseControl/index.js +57 -22
  13. package/lib/control/baseControl/popperControl.js +136 -102
  14. package/lib/control/baseControl/selectControl.js +230 -130
  15. package/lib/control/exportImage.js +175 -81
  16. package/lib/control/fullscreen.js +157 -102
  17. package/lib/control/geoLocate.js +143 -67
  18. package/lib/control/layerControl.js +162 -116
  19. package/lib/control/logo.js +101 -70
  20. package/lib/control/mapTheme.js +144 -85
  21. package/lib/control/mouseLocation.js +112 -71
  22. package/lib/control/scale.js +180 -127
  23. package/lib/control/zoom.js +154 -111
  24. package/lib/index.js +251 -48
  25. package/lib/interface.js +4 -16
  26. package/lib/marker-layer.js +367 -249
  27. package/lib/marker.js +419 -277
  28. package/lib/popup/layerPopup.js +305 -188
  29. package/lib/popup/popup.js +602 -339
  30. package/lib/utils/anchor.js +37 -55
  31. package/lib/utils/icon.js +13 -32
  32. package/lib/utils/popper.js +268 -180
  33. package/lib/utils/screenfull.js +110 -103
  34. package/package.json +5 -5
@@ -1,172 +1,333 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.Control = void 0;
9
+ Object.defineProperty(exports, "IControlOption", {
10
+ enumerable: true,
11
+ get: function get() {
12
+ return _l7Core.IControlOption;
16
13
  }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/control/baseControl/control.ts
23
- var control_exports = {};
24
- __export(control_exports, {
25
- Control: () => Control,
26
- PositionType: () => import_l7_core2.PositionType,
27
- default: () => Control
28
14
  });
29
- module.exports = __toCommonJS(control_exports);
30
- var import_l7_core = require("@antv/l7-core");
31
- var import_l7_utils = require("@antv/l7-utils");
32
- var import_eventemitter3 = __toESM(require("eventemitter3"));
33
- var import_l7_core2 = require("@antv/l7-core");
34
- var _Control = class extends import_eventemitter3.default {
35
- constructor(option) {
36
- super();
37
- _Control.controlCount++;
38
- this.controlOption = {
39
- ...this.getDefault(option),
40
- ...option || {}
41
- };
15
+ Object.defineProperty(exports, "PositionType", {
16
+ enumerable: true,
17
+ get: function get() {
18
+ return _l7Core.PositionType;
42
19
  }
43
- getOptions() {
44
- return this.controlOption;
20
+ });
21
+ exports.default = void 0;
22
+
23
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
24
+
25
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
26
+
27
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
28
+
29
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
30
+
31
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
32
+
33
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
34
+
35
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
36
+
37
+ var _l7Core = require("@antv/l7-core");
38
+
39
+ var _l7Utils = require("@antv/l7-utils");
40
+
41
+ var _eventemitter = _interopRequireDefault(require("eventemitter3"));
42
+
43
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
44
+
45
+ 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; } }
46
+
47
+ var Control = /*#__PURE__*/function (_ref) {
48
+ (0, _inherits2.default)(Control, _ref);
49
+
50
+ var _super = _createSuper(Control);
51
+
52
+ /**
53
+ * 当前类型控件实例个数
54
+ * @protected
55
+ */
56
+ function Control(option) {
57
+ var _this;
58
+
59
+ (0, _classCallCheck2.default)(this, Control);
60
+ _this = _super.call(this);
61
+ Control.controlCount++;
62
+ _this.controlOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _this.getDefault(option)), option || {});
63
+ return _this;
45
64
  }
46
- setOptions(newOptions) {
47
- if ("position" in newOptions) {
48
- this.setPosition(newOptions.position);
49
- }
50
- if ("className" in newOptions) {
51
- this.setClassName(newOptions.className);
65
+
66
+ (0, _createClass2.default)(Control, [{
67
+ key: "getOptions",
68
+ value: function getOptions() {
69
+ return this.controlOption;
52
70
  }
53
- if ("style" in newOptions) {
54
- this.setStyle(newOptions.style);
71
+ /**
72
+ * 更新配置的方法,子类如果有自己的配置,也需要重写该方法
73
+ * @param newOptions
74
+ */
75
+
76
+ }, {
77
+ key: "setOptions",
78
+ value: function setOptions(newOptions) {
79
+ if ('position' in newOptions) {
80
+ this.setPosition(newOptions.position);
81
+ }
82
+
83
+ if ('className' in newOptions) {
84
+ this.setClassName(newOptions.className);
85
+ }
86
+
87
+ if ('style' in newOptions) {
88
+ this.setStyle(newOptions.style);
89
+ }
90
+
91
+ this.controlOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.controlOption), newOptions);
55
92
  }
56
- this.controlOption = {
57
- ...this.controlOption,
58
- ...newOptions
59
- };
60
- }
61
- addTo(sceneContainer) {
62
- this.mapsService = sceneContainer.get(import_l7_core.TYPES.IMapService);
63
- this.renderService = sceneContainer.get(import_l7_core.TYPES.IRendererService);
64
- this.layerService = sceneContainer.get(import_l7_core.TYPES.ILayerService);
65
- this.controlService = sceneContainer.get(import_l7_core.TYPES.IControlService);
66
- this.configService = sceneContainer.get(import_l7_core.TYPES.IGlobalConfigService);
67
- this.scene = sceneContainer.get(import_l7_core.TYPES.ISceneService);
68
- this.sceneContainer = sceneContainer;
69
- this.isShow = true;
70
- this.container = this.onAdd();
71
- import_l7_utils.DOM.addClass(this.container, "l7-control");
72
- const { className, style } = this.controlOption;
73
- if (className) {
74
- this.setClassName(className);
75
- }
76
- if (style) {
77
- this.setStyle(style);
78
- }
79
- this.insertContainer();
80
- this.emit("add", this);
81
- return this;
82
- }
83
- remove() {
84
- if (!this.mapsService) {
93
+ /**
94
+ * 当 Control 被添加至 Scene 中,被 controlService 调用的方法
95
+ * @param sceneContainer
96
+ */
97
+
98
+ }, {
99
+ key: "addTo",
100
+ value: function addTo(sceneContainer) {
101
+ // 初始化各个 Service 实例
102
+ this.mapsService = sceneContainer.get(_l7Core.TYPES.IMapService);
103
+ this.renderService = sceneContainer.get(_l7Core.TYPES.IRendererService);
104
+ this.layerService = sceneContainer.get(_l7Core.TYPES.ILayerService);
105
+ this.controlService = sceneContainer.get(_l7Core.TYPES.IControlService);
106
+ this.configService = sceneContainer.get(_l7Core.TYPES.IGlobalConfigService);
107
+ this.scene = sceneContainer.get(_l7Core.TYPES.ISceneService);
108
+ this.sceneContainer = sceneContainer;
109
+ this.isShow = true; // 初始化 container
110
+
111
+ this.container = this.onAdd();
112
+
113
+ _l7Utils.DOM.addClass(this.container, 'l7-control');
114
+
115
+ var _this$controlOption = this.controlOption,
116
+ className = _this$controlOption.className,
117
+ style = _this$controlOption.style;
118
+
119
+ if (className) {
120
+ this.setClassName(className);
121
+ }
122
+
123
+ if (style) {
124
+ this.setStyle(style);
125
+ } // 将 container 插入容器中
126
+
127
+
128
+ this.insertContainer();
129
+ this.emit('add', this);
85
130
  return this;
86
131
  }
87
- import_l7_utils.DOM.remove(this.container);
88
- this.onRemove();
89
- this.emit("remove", this);
90
- }
91
- show() {
92
- const container = this.container;
93
- import_l7_utils.DOM.removeClass(container, "l7-control--hide");
94
- this.isShow = true;
95
- this.emit("show", this);
96
- }
97
- hide() {
98
- const container = this.container;
99
- import_l7_utils.DOM.addClass(container, "l7-control--hide");
100
- this.isShow = false;
101
- this.emit("hide", this);
102
- }
103
- getDefault(option) {
104
- return {
105
- position: import_l7_core.PositionType.TOPRIGHT,
106
- name: `${_Control.controlCount}`
107
- };
108
- }
109
- getContainer() {
110
- return this.container;
111
- }
112
- getIsShow() {
113
- return this.isShow;
114
- }
115
- _refocusOnMap(e) {
116
- if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
117
- const container = this.mapsService.getContainer();
118
- if (container !== null) {
119
- container.focus();
132
+ /**
133
+ * 将控件移除时触发
134
+ */
135
+
136
+ }, {
137
+ key: "remove",
138
+ value: function remove() {
139
+ if (!this.mapsService) {
140
+ return this;
120
141
  }
142
+
143
+ _l7Utils.DOM.remove(this.container);
144
+
145
+ this.onRemove();
146
+ this.emit('remove', this);
121
147
  }
122
- }
123
- setPosition(position = import_l7_core.PositionType.TOPLEFT) {
124
- const controlService = this.controlService;
125
- if (controlService) {
126
- controlService.removeControl(this);
148
+ /**
149
+ * Control 被添加的时候被调用,返回 Control 对应的 DOM 容器
150
+ */
151
+
152
+ }, {
153
+ key: "onAdd",
154
+ value: function onAdd() {
155
+ return _l7Utils.DOM.create('div');
156
+ }
157
+ /**
158
+ * Control 被移除时调用
159
+ */
160
+ // tslint:disable-next-line:no-empty
161
+
162
+ }, {
163
+ key: "onRemove",
164
+ value: function onRemove() {}
165
+ /**
166
+ * 显示控件时触发
167
+ */
168
+
169
+ }, {
170
+ key: "show",
171
+ value: function show() {
172
+ var container = this.container;
173
+
174
+ _l7Utils.DOM.removeClass(container, 'l7-control--hide');
175
+
176
+ this.isShow = true;
177
+ this.emit('show', this);
127
178
  }
128
- this.controlOption.position = position;
129
- if (controlService) {
130
- controlService.addControl(this, this.sceneContainer);
179
+ /**
180
+ * 隐藏控件时触发
181
+ */
182
+
183
+ }, {
184
+ key: "hide",
185
+ value: function hide() {
186
+ var container = this.container;
187
+
188
+ _l7Utils.DOM.addClass(container, 'l7-control--hide');
189
+
190
+ this.isShow = false;
191
+ this.emit('hide', this);
131
192
  }
132
- return this;
133
- }
134
- setClassName(className) {
135
- const container = this.container;
136
- const { className: oldClassName } = this.controlOption;
137
- if (oldClassName) {
138
- import_l7_utils.DOM.removeClass(container, oldClassName);
193
+ /**
194
+ * 获取默认构造器参数
195
+ */
196
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
197
+
198
+ }, {
199
+ key: "getDefault",
200
+ value: function getDefault(option) {
201
+ // tslint:disable-next-line:no-object-literal-type-assertion
202
+ return {
203
+ position: _l7Core.PositionType.TOPRIGHT,
204
+ name: "".concat(Control.controlCount)
205
+ };
139
206
  }
140
- if (className) {
141
- import_l7_utils.DOM.addClass(container, className);
207
+ /**
208
+ * 获取当前控件对应的 DOM 容器
209
+ */
210
+
211
+ }, {
212
+ key: "getContainer",
213
+ value: function getContainer() {
214
+ return this.container;
142
215
  }
143
- }
144
- setStyle(style) {
145
- const container = this.container;
146
- if (style) {
147
- container.setAttribute("style", style);
148
- } else {
149
- container.removeAttribute("style");
216
+ /**
217
+ * 获取当前 Control 是否展示
218
+ */
219
+
220
+ }, {
221
+ key: "getIsShow",
222
+ value: function getIsShow() {
223
+ return this.isShow;
150
224
  }
151
- }
152
- insertContainer() {
153
- const container = this.container;
154
- const position = this.controlOption.position;
155
- const corner = this.controlService.controlCorners[position];
156
- if (position.indexOf("bottom") !== -1) {
157
- corner.insertBefore(container, corner.firstChild);
158
- } else {
159
- corner.appendChild(container);
225
+ }, {
226
+ key: "_refocusOnMap",
227
+ value: function _refocusOnMap(e) {
228
+ // if map exists and event is not a keyboard event
229
+ if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
230
+ var container = this.mapsService.getContainer();
231
+
232
+ if (container !== null) {
233
+ container.focus();
234
+ }
235
+ }
160
236
  }
161
- }
162
- checkUpdateOption(option, keys) {
163
- return keys.some((key) => key in option);
164
- }
165
- };
166
- var Control = _Control;
167
- Control.controlCount = 0;
168
- // Annotate the CommonJS export names for ESM import in node:
169
- 0 && (module.exports = {
170
- Control,
171
- PositionType
172
- });
237
+ /**
238
+ * 设置当前控件位置
239
+ * @param position
240
+ */
241
+
242
+ }, {
243
+ key: "setPosition",
244
+ value: function setPosition() {
245
+ var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _l7Core.PositionType.TOPLEFT;
246
+ // 考虑组件的自动布局,需要销毁重建
247
+ var controlService = this.controlService;
248
+
249
+ if (controlService) {
250
+ controlService.removeControl(this);
251
+ }
252
+
253
+ this.controlOption.position = position;
254
+
255
+ if (controlService) {
256
+ controlService.addControl(this, this.sceneContainer);
257
+ }
258
+
259
+ return this;
260
+ }
261
+ /**
262
+ * 设置容器 container 的样式相关位置,包含 className
263
+ * @param className
264
+ */
265
+
266
+ }, {
267
+ key: "setClassName",
268
+ value: function setClassName(className) {
269
+ var container = this.container;
270
+ var oldClassName = this.controlOption.className;
271
+
272
+ if (oldClassName) {
273
+ _l7Utils.DOM.removeClass(container, oldClassName);
274
+ }
275
+
276
+ if (className) {
277
+ _l7Utils.DOM.addClass(container, className);
278
+ }
279
+ }
280
+ /**
281
+ * 设置容器 container 的样式相关位置,包含 style
282
+ * @param style
283
+ */
284
+
285
+ }, {
286
+ key: "setStyle",
287
+ value: function setStyle(style) {
288
+ var container = this.container;
289
+
290
+ if (style) {
291
+ container.setAttribute('style', style);
292
+ } else {
293
+ container.removeAttribute('style');
294
+ }
295
+ }
296
+ /**
297
+ * 将控件 DOM 插入到对应 position 的容器中
298
+ * @protected
299
+ */
300
+
301
+ }, {
302
+ key: "insertContainer",
303
+ value: function insertContainer() {
304
+ var container = this.container;
305
+ var position = this.controlOption.position;
306
+ var corner = this.controlService.controlCorners[position];
307
+
308
+ if (position.indexOf('bottom') !== -1) {
309
+ corner.insertBefore(container, corner.firstChild);
310
+ } else {
311
+ corner.appendChild(container);
312
+ }
313
+ }
314
+ /**
315
+ * 检查当前传入 option 是否包含 keys 字段
316
+ * @param option
317
+ * @param keys
318
+ * @protected
319
+ */
320
+
321
+ }, {
322
+ key: "checkUpdateOption",
323
+ value: function checkUpdateOption(option, keys) {
324
+ return keys.some(function (key) {
325
+ return key in option;
326
+ });
327
+ }
328
+ }]);
329
+ return Control;
330
+ }(_eventemitter.default);
331
+
332
+ exports.default = exports.Control = Control;
333
+ (0, _defineProperty2.default)(Control, "controlCount", 0);
@@ -1,22 +1,57 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/control/baseControl/index.ts
17
- var baseControl_exports = {};
18
- module.exports = __toCommonJS(baseControl_exports);
19
- __reExport(baseControl_exports, require("./control"), module.exports);
20
- __reExport(baseControl_exports, require("./buttonControl"), module.exports);
21
- __reExport(baseControl_exports, require("./popperControl"), module.exports);
22
- __reExport(baseControl_exports, require("./selectControl"), module.exports);
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _control = require("./control");
8
+
9
+ Object.keys(_control).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _control[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _control[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _buttonControl = require("./buttonControl");
21
+
22
+ Object.keys(_buttonControl).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _buttonControl[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _buttonControl[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _popperControl = require("./popperControl");
34
+
35
+ Object.keys(_popperControl).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _popperControl[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function get() {
41
+ return _popperControl[key];
42
+ }
43
+ });
44
+ });
45
+
46
+ var _selectControl = require("./selectControl");
47
+
48
+ Object.keys(_selectControl).forEach(function (key) {
49
+ if (key === "default" || key === "__esModule") return;
50
+ if (key in exports && exports[key] === _selectControl[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function get() {
54
+ return _selectControl[key];
55
+ }
56
+ });
57
+ });