@antv/l7-component 2.18.0 → 2.18.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 (114) hide show
  1. package/package.json +6 -6
  2. package/es/assets/iconfont/iconfont.js +0 -46
  3. package/es/constants/index.d.ts +0 -60
  4. package/es/constants/index.js +0 -60
  5. package/es/control/baseControl/buttonControl.d.ts +0 -59
  6. package/es/control/baseControl/buttonControl.js +0 -177
  7. package/es/control/baseControl/control.d.ts +0 -112
  8. package/es/control/baseControl/control.js +0 -302
  9. package/es/control/baseControl/index.d.ts +0 -4
  10. package/es/control/baseControl/index.js +0 -4
  11. package/es/control/baseControl/popperControl.d.ts +0 -26
  12. package/es/control/baseControl/popperControl.js +0 -120
  13. package/es/control/baseControl/selectControl.d.ts +0 -46
  14. package/es/control/baseControl/selectControl.js +0 -204
  15. package/es/control/exportImage.d.ts +0 -18
  16. package/es/control/exportImage.js +0 -159
  17. package/es/control/fullscreen.d.ts +0 -19
  18. package/es/control/fullscreen.js +0 -119
  19. package/es/control/geoLocate.d.ts +0 -16
  20. package/es/control/geoLocate.js +0 -107
  21. package/es/control/layerSwitch.d.ts +0 -19
  22. package/es/control/layerSwitch.js +0 -141
  23. package/es/control/logo.d.ts +0 -13
  24. package/es/control/logo.js +0 -75
  25. package/es/control/mapTheme.d.ts +0 -10
  26. package/es/control/mapTheme.js +0 -110
  27. package/es/control/mouseLocation.d.ts +0 -15
  28. package/es/control/mouseLocation.js +0 -83
  29. package/es/control/scale.d.ts +0 -34
  30. package/es/control/scale.js +0 -149
  31. package/es/control/zoom.d.ts +0 -38
  32. package/es/control/zoom.js +0 -132
  33. package/es/css/button.less +0 -70
  34. package/es/css/control.less +0 -71
  35. package/es/css/index.css +0 -594
  36. package/es/css/index.less +0 -12
  37. package/es/css/l7.less +0 -62
  38. package/es/css/layerPopup.less +0 -8
  39. package/es/css/logo.less +0 -18
  40. package/es/css/mouseLocation.less +0 -9
  41. package/es/css/popper.less +0 -64
  42. package/es/css/popup.less +0 -185
  43. package/es/css/scale.less +0 -34
  44. package/es/css/select.less +0 -86
  45. package/es/css/variables.less +0 -30
  46. package/es/css/zoom.less +0 -29
  47. package/es/images/layers.png +0 -0
  48. package/es/images/layers.svg +0 -1
  49. package/es/images/logo.png +0 -0
  50. package/es/images/quanping.svg +0 -12
  51. package/es/index.d.ts +0 -18
  52. package/es/index.js +0 -49
  53. package/es/interface.d.ts +0 -18
  54. package/es/interface.js +0 -1
  55. package/es/marker-layer.d.ts +0 -54
  56. package/es/marker-layer.js +0 -343
  57. package/es/marker.d.ts +0 -55
  58. package/es/marker.js +0 -410
  59. package/es/popup/layerPopup.d.ts +0 -86
  60. package/es/popup/layerPopup.js +0 -312
  61. package/es/popup/popup.d.ts +0 -139
  62. package/es/popup/popup.js +0 -567
  63. package/es/utils/anchor.d.ts +0 -22
  64. package/es/utils/anchor.js +0 -31
  65. package/es/utils/icon.d.ts +0 -1
  66. package/es/utils/icon.js +0 -9
  67. package/es/utils/popper.d.ts +0 -75
  68. package/es/utils/popper.js +0 -259
  69. package/es/utils/screenfull.d.ts +0 -2
  70. package/es/utils/screenfull.js +0 -128
  71. package/lib/assets/iconfont/iconfont.js +0 -48
  72. package/lib/constants/index.js +0 -68
  73. package/lib/control/baseControl/buttonControl.js +0 -183
  74. package/lib/control/baseControl/control.js +0 -314
  75. package/lib/control/baseControl/index.js +0 -39
  76. package/lib/control/baseControl/popperControl.js +0 -126
  77. package/lib/control/baseControl/selectControl.js +0 -210
  78. package/lib/control/exportImage.js +0 -165
  79. package/lib/control/fullscreen.js +0 -125
  80. package/lib/control/geoLocate.js +0 -113
  81. package/lib/control/layerSwitch.js +0 -147
  82. package/lib/control/logo.js +0 -81
  83. package/lib/control/mapTheme.js +0 -116
  84. package/lib/control/mouseLocation.js +0 -89
  85. package/lib/control/scale.js +0 -155
  86. package/lib/control/zoom.js +0 -138
  87. package/lib/css/button.less +0 -70
  88. package/lib/css/control.less +0 -71
  89. package/lib/css/index.css +0 -594
  90. package/lib/css/index.less +0 -12
  91. package/lib/css/l7.less +0 -62
  92. package/lib/css/layerPopup.less +0 -8
  93. package/lib/css/logo.less +0 -18
  94. package/lib/css/mouseLocation.less +0 -9
  95. package/lib/css/popper.less +0 -64
  96. package/lib/css/popup.less +0 -185
  97. package/lib/css/scale.less +0 -34
  98. package/lib/css/select.less +0 -86
  99. package/lib/css/variables.less +0 -30
  100. package/lib/css/zoom.less +0 -29
  101. package/lib/images/layers.png +0 -0
  102. package/lib/images/layers.svg +0 -1
  103. package/lib/images/logo.png +0 -0
  104. package/lib/images/quanping.svg +0 -12
  105. package/lib/index.js +0 -169
  106. package/lib/interface.js +0 -5
  107. package/lib/marker-layer.js +0 -349
  108. package/lib/marker.js +0 -417
  109. package/lib/popup/layerPopup.js +0 -317
  110. package/lib/popup/popup.js +0 -573
  111. package/lib/utils/anchor.js +0 -40
  112. package/lib/utils/icon.js +0 -16
  113. package/lib/utils/popper.js +0 -263
  114. package/lib/utils/screenfull.js +0 -136
package/lib/marker.js DELETED
@@ -1,417 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
- var _l7Core = require("@antv/l7-core");
17
- var _l7Utils = require("@antv/l7-utils");
18
- var _eventemitter = require("eventemitter3");
19
- 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); }; }
20
- 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; } }
21
- // marker 支持 dragger 未完成
22
- var Marker = /*#__PURE__*/function (_EventEmitter) {
23
- (0, _inherits2.default)(Marker, _EventEmitter);
24
- var _super = _createSuper(Marker);
25
- function Marker(option) {
26
- var _this;
27
- (0, _classCallCheck2.default)(this, Marker);
28
- _this = _super.call(this);
29
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "added", false);
30
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "eventHandle", function (e) {
31
- _this.polyfillEvent(e);
32
- _this.emit(e.type, {
33
- target: e,
34
- data: _this.markerOption.extData,
35
- lngLat: _this.lngLat
36
- });
37
- });
38
- _this.markerOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _this.getDefault()), option);
39
- (0, _l7Utils.bindAll)(['update', 'onMove', 'onMapClick'], (0, _assertThisInitialized2.default)(_this));
40
- _this.init();
41
- return _this;
42
- }
43
- (0, _createClass2.default)(Marker, [{
44
- key: "getMarkerLayerContainerSize",
45
- value:
46
- // tslint:disable-next-line: no-empty
47
- function getMarkerLayerContainerSize() {}
48
- }, {
49
- key: "getDefault",
50
- value: function getDefault() {
51
- return {
52
- element: undefined,
53
- // DOM element
54
- anchor: _l7Utils.anchorType.BOTTOM,
55
- offsets: [0, 0],
56
- color: '#5B8FF9',
57
- draggable: false
58
- };
59
- }
60
- }, {
61
- key: "addTo",
62
- value: function addTo(scene) {
63
- // this.remove();
64
- this.scene = scene;
65
- this.mapsService = scene.get(_l7Core.TYPES.IMapService);
66
- this.sceneSerive = scene.get(_l7Core.TYPES.ISceneService);
67
- var element = this.markerOption.element;
68
- // this.sceneSerive.getSceneContainer().appendChild(element as HTMLElement);
69
- this.mapsService.getMarkerContainer().appendChild(element);
70
- this.registerMarkerEvent(element);
71
- this.mapsService.on('camerachange', this.update); // 注册高德1.x 的地图事件监听
72
- this.update();
73
- this.added = true;
74
- this.emit('added');
75
- return this;
76
- }
77
- }, {
78
- key: "remove",
79
- value: function remove() {
80
- if (this.mapsService) {
81
- this.mapsService.off('click', this.onMapClick);
82
- this.mapsService.off('move', this.update);
83
- this.mapsService.off('moveend', this.update);
84
- this.mapsService.off('camerachange', this.update);
85
- }
86
- this.unRegisterMarkerEvent();
87
- this.removeAllListeners();
88
- var element = this.markerOption.element;
89
- if (element) {
90
- _l7Utils.DOM.remove(element);
91
- }
92
- if (this.popup) {
93
- this.popup.remove();
94
- }
95
- return this;
96
- }
97
- }, {
98
- key: "setLnglat",
99
- value: function setLnglat(lngLat) {
100
- this.lngLat = lngLat;
101
- if (Array.isArray(lngLat)) {
102
- this.lngLat = {
103
- lng: lngLat[0],
104
- lat: lngLat[1]
105
- };
106
- }
107
- if (this.popup) {
108
- this.popup.setLnglat(this.lngLat);
109
- }
110
- this.update();
111
- return this;
112
- }
113
- }, {
114
- key: "getLnglat",
115
- value: function getLnglat() {
116
- return this.lngLat;
117
- }
118
- }, {
119
- key: "getElement",
120
- value: function getElement() {
121
- return this.markerOption.element;
122
- }
123
- }, {
124
- key: "setElement",
125
- value: function setElement(el) {
126
- var _this2 = this;
127
- if (!this.added) {
128
- this.once('added', function () {
129
- _this2.setElement(el);
130
- });
131
- return this;
132
- }
133
- var element = this.markerOption.element;
134
- if (element) {
135
- _l7Utils.DOM.remove(element);
136
- }
137
- this.markerOption.element = el;
138
- this.init();
139
- this.mapsService.getMarkerContainer().appendChild(el);
140
- this.registerMarkerEvent(el);
141
- this.update();
142
- return this;
143
- }
144
- }, {
145
- key: "openPopup",
146
- value: function openPopup() {
147
- var _this3 = this;
148
- if (!this.added) {
149
- this.once('added', function () {
150
- _this3.openPopup();
151
- });
152
- return this;
153
- }
154
- var popup = this.popup;
155
- if (!popup) {
156
- return this;
157
- }
158
- if (!popup.isOpen()) {
159
- popup.addTo(this.scene);
160
- }
161
- return this;
162
- }
163
- }, {
164
- key: "closePopup",
165
- value: function closePopup() {
166
- var _this4 = this;
167
- if (!this.added) {
168
- this.once('added', function () {
169
- _this4.closePopup();
170
- });
171
- }
172
- var popup = this.popup;
173
- if (popup) {
174
- popup.remove();
175
- }
176
- return this;
177
- }
178
- }, {
179
- key: "setPopup",
180
- value: function setPopup(popup) {
181
- this.popup = popup;
182
- if (this.lngLat) {
183
- this.popup.setLnglat(this.lngLat);
184
- }
185
- return this;
186
- }
187
- }, {
188
- key: "togglePopup",
189
- value: function togglePopup() {
190
- var popup = this.popup;
191
- if (!popup) {
192
- return this;
193
- } else if (popup.isOpen()) {
194
- popup.remove();
195
- } else {
196
- popup.addTo(this.scene);
197
- }
198
- return this;
199
- }
200
- }, {
201
- key: "getPopup",
202
- value: function getPopup() {
203
- return this.popup;
204
- }
205
- }, {
206
- key: "getOffset",
207
- value: function getOffset() {
208
- return this.markerOption.offsets;
209
- }
210
-
211
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
212
- }, {
213
- key: "setDraggable",
214
- value: function setDraggable(draggable) {
215
- throw new Error('Method not implemented.');
216
- }
217
- }, {
218
- key: "isDraggable",
219
- value: function isDraggable() {
220
- return this.markerOption.draggable;
221
- }
222
- }, {
223
- key: "getExtData",
224
- value: function getExtData() {
225
- return this.markerOption.extData;
226
- }
227
- }, {
228
- key: "setExtData",
229
- value: function setExtData(data) {
230
- this.markerOption.extData = data;
231
- }
232
- }, {
233
- key: "update",
234
- value: function update() {
235
- if (!this.mapsService) {
236
- return;
237
- }
238
- var _this$markerOption = this.markerOption,
239
- element = _this$markerOption.element,
240
- anchor = _this$markerOption.anchor;
241
- this.updatePosition();
242
- _l7Utils.DOM.setTransform(element, "".concat(_l7Utils.anchorTranslate[anchor]));
243
- }
244
-
245
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
246
- }, {
247
- key: "onMapClick",
248
- value: function onMapClick(e) {
249
- var element = this.markerOption.element;
250
- if (this.popup && element) {
251
- this.togglePopup();
252
- }
253
- }
254
- }, {
255
- key: "getCurrentContainerSize",
256
- value: function getCurrentContainerSize() {
257
- var container = this.mapsService.getContainer();
258
- return {
259
- containerHeight: (container === null || container === void 0 ? void 0 : container.scrollHeight) || 0,
260
- containerWidth: (container === null || container === void 0 ? void 0 : container.scrollWidth) || 0,
261
- bounds: this.mapsService.getBounds()
262
- };
263
- }
264
- }, {
265
- key: "updatePosition",
266
- value: function updatePosition() {
267
- if (!this.mapsService) {
268
- return;
269
- }
270
- var _this$markerOption2 = this.markerOption,
271
- element = _this$markerOption2.element,
272
- offsets = _this$markerOption2.offsets;
273
- var _this$lngLat = this.lngLat,
274
- lng = _this$lngLat.lng,
275
- lat = _this$lngLat.lat;
276
- var pos = this.mapsService.lngLatToContainer([lng, lat]);
277
- if (element) {
278
- element.style.display = 'block';
279
- element.style.whiteSpace = 'nowrap';
280
- var _ref = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize(),
281
- containerHeight = _ref.containerHeight,
282
- containerWidth = _ref.containerWidth,
283
- bounds = _ref.bounds;
284
- if (!bounds) {
285
- return;
286
- }
287
- // 当前可视区域包含跨日界线
288
- if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
289
- if (pos.x > containerWidth) {
290
- // 日界线右侧点左移
291
- var newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
292
- pos.x = newPos.x;
293
- }
294
- if (pos.x < 0) {
295
- // 日界线左侧点右移
296
- var _newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
297
- pos.x = _newPos.x;
298
- }
299
- }
300
- // 不在当前可视区域内隐藏点
301
- if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
302
- element.style.display = 'none';
303
- }
304
- element.style.left = pos.x + offsets[0] + 'px';
305
- element.style.top = pos.y - offsets[1] + 'px';
306
- }
307
- }
308
- }, {
309
- key: "init",
310
- value: function init() {
311
- var _this5 = this;
312
- var element = this.markerOption.element;
313
- var _this$markerOption3 = this.markerOption,
314
- color = _this$markerOption3.color,
315
- anchor = _this$markerOption3.anchor;
316
- if (!element) {
317
- this.defaultMarker = true;
318
- element = _l7Utils.DOM.create('div');
319
- this.markerOption.element = element;
320
- var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
321
- svg.setAttributeNS(null, 'display', 'block');
322
- svg.setAttributeNS(null, 'height', '48px');
323
- svg.setAttributeNS(null, 'width', '48px');
324
- svg.setAttributeNS(null, 'viewBox', '0 0 1024 1024');
325
- var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
326
- path.setAttributeNS(null, 'd', 'M512 490.666667C453.12 490.666667 405.333333 442.88 405.333333 384 405.333333 325.12 453.12 277.333333 512 277.333333 570.88 277.333333 618.666667 325.12 618.666667 384 618.666667 442.88 570.88 490.666667 512 490.666667M512 85.333333C346.88 85.333333 213.333333 218.88 213.333333 384 213.333333 608 512 938.666667 512 938.666667 512 938.666667 810.666667 608 810.666667 384 810.666667 218.88 677.12 85.333333 512 85.333333Z');
327
- path.setAttributeNS(null, 'fill', color);
328
- svg.appendChild(path);
329
- element.appendChild(svg);
330
- }
331
- _l7Utils.DOM.addClass(element, 'l7-marker');
332
- Object.keys(this.markerOption.style || {}).forEach(
333
- // @ts-ignore
334
- function (key) {
335
- var _this5$markerOption, _this5$markerOption2;
336
- var value = ((_this5$markerOption = _this5.markerOption) === null || _this5$markerOption === void 0 ? void 0 : _this5$markerOption.style) && ((_this5$markerOption2 = _this5.markerOption) === null || _this5$markerOption2 === void 0 ? void 0 : _this5$markerOption2.style[key]);
337
- if (element) {
338
- // @ts-ignore
339
- element.style[key] = value;
340
- }
341
- });
342
- (0, _l7Utils.applyAnchorClass)(element, anchor, 'marker');
343
- }
344
- }, {
345
- key: "registerMarkerEvent",
346
- value: function registerMarkerEvent(element) {
347
- element.addEventListener('click', this.onMapClick);
348
- element.addEventListener('mousemove', this.eventHandle);
349
- element.addEventListener('click', this.eventHandle);
350
- element.addEventListener('mousedown', this.eventHandle);
351
- element.addEventListener('mouseup', this.eventHandle);
352
- element.addEventListener('dblclick', this.eventHandle);
353
- element.addEventListener('contextmenu', this.eventHandle);
354
- element.addEventListener('mouseover', this.eventHandle);
355
- element.addEventListener('mouseout', this.eventHandle);
356
- element.addEventListener('touchstart', this.eventHandle);
357
- element.addEventListener('touchend', this.eventHandle);
358
- }
359
- }, {
360
- key: "unRegisterMarkerEvent",
361
- value: function unRegisterMarkerEvent() {
362
- var element = this.getElement();
363
- element.removeEventListener('click', this.onMapClick);
364
- element.removeEventListener('mousemove', this.eventHandle);
365
- element.removeEventListener('click', this.eventHandle);
366
- element.removeEventListener('mousedown', this.eventHandle);
367
- element.removeEventListener('mouseup', this.eventHandle);
368
- element.removeEventListener('dblclick', this.eventHandle);
369
- element.removeEventListener('contextmenu', this.eventHandle);
370
- element.removeEventListener('mouseover', this.eventHandle);
371
- element.removeEventListener('mouseout', this.eventHandle);
372
- element.removeEventListener('touchstart', this.eventHandle);
373
- element.removeEventListener('touchend', this.eventHandle);
374
- }
375
- }, {
376
- key: "polyfillEvent",
377
- value:
378
- /**
379
- * 高德 2.x 使用了 fastClick.js 避免延迟,导致 IOS 移动端的 click 事件不会正常触发,需要手动触发
380
- * @param e
381
- */
382
-
383
- function polyfillEvent(e) {
384
- if (!this.mapsService || this.mapsService.version !== 'GAODE2.x') {
385
- return;
386
- }
387
- if (!(0, _l7Utils.isPC)()) {
388
- if (e.type === 'touchstart') {
389
- this.touchStartTime = Date.now();
390
- }
391
- if (e.type === 'touchend' && Date.now() - this.touchStartTime < 300) {
392
- this.emit('click', {
393
- target: e,
394
- data: this.markerOption.extData,
395
- lngLat: this.lngLat
396
- });
397
- }
398
- }
399
- }
400
-
401
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
402
- }, {
403
- key: "addDragHandler",
404
- value: function addDragHandler(e) {
405
- return null;
406
- }
407
-
408
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
409
- }, {
410
- key: "onUp",
411
- value: function onUp(e) {
412
- throw new Error('Method not implemented.');
413
- }
414
- }]);
415
- return Marker;
416
- }(_eventemitter.EventEmitter);
417
- exports.default = Marker;