@antv/l7-component 2.9.35 → 2.9.36-alpha.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.
Files changed (110) hide show
  1. package/es/assets/iconfont/iconfont.js +53 -0
  2. package/es/constants/index.d.ts +60 -0
  3. package/es/constants/index.js +60 -0
  4. package/es/control/baseControl/buttonControl.d.ts +59 -0
  5. package/es/control/baseControl/buttonControl.js +191 -0
  6. package/es/control/baseControl/control.d.ts +106 -0
  7. package/es/control/baseControl/control.js +301 -0
  8. package/es/control/baseControl/index.d.ts +4 -0
  9. package/es/control/baseControl/index.js +4 -0
  10. package/es/control/baseControl/popperControl.d.ts +26 -0
  11. package/es/control/baseControl/popperControl.js +131 -0
  12. package/es/control/baseControl/selectControl.d.ts +46 -0
  13. package/es/control/baseControl/selectControl.js +232 -0
  14. package/es/control/exportImage.d.ts +18 -0
  15. package/es/control/exportImage.js +163 -0
  16. package/es/control/fullscreen.d.ts +19 -0
  17. package/es/control/fullscreen.js +151 -0
  18. package/es/control/geoLocate.d.ts +16 -0
  19. package/es/control/geoLocate.js +139 -0
  20. package/es/control/layerControl.d.ts +21 -0
  21. package/es/control/layerControl.js +172 -0
  22. package/es/control/logo.d.ts +10 -6
  23. package/es/control/logo.js +41 -11
  24. package/es/control/mapTheme.d.ts +10 -0
  25. package/es/control/mapTheme.js +135 -0
  26. package/es/control/mouseLocation.d.ts +15 -0
  27. package/es/control/mouseLocation.js +104 -0
  28. package/es/control/scale.d.ts +20 -10
  29. package/es/control/scale.js +77 -53
  30. package/es/control/zoom.d.ts +21 -10
  31. package/es/control/zoom.js +76 -49
  32. package/es/css/button.less +70 -0
  33. package/es/css/control.less +71 -0
  34. package/es/css/index.css +567 -0
  35. package/es/css/index.less +12 -0
  36. package/es/css/l7.less +60 -0
  37. package/es/css/layerPopup.less +8 -0
  38. package/es/css/logo.less +18 -0
  39. package/es/css/mouseLocation.less +9 -0
  40. package/es/css/popper.less +64 -0
  41. package/es/css/popup.less +169 -0
  42. package/es/css/scale.less +34 -0
  43. package/es/css/select.less +86 -0
  44. package/es/css/variables.less +28 -0
  45. package/es/css/zoom.less +21 -0
  46. package/es/images/logo.png +0 -0
  47. package/es/images/quanping.svg +12 -0
  48. package/es/index.d.ts +15 -8
  49. package/es/index.js +15 -9
  50. package/es/interface.d.ts +1 -20
  51. package/es/popup/layerPopup.d.ts +78 -0
  52. package/es/popup/layerPopup.js +308 -0
  53. package/es/popup/popup.d.ts +147 -0
  54. package/es/popup/popup.js +636 -0
  55. package/es/utils/icon.d.ts +1 -0
  56. package/es/utils/icon.js +9 -0
  57. package/es/utils/popper.d.ts +75 -0
  58. package/es/utils/popper.js +286 -0
  59. package/es/utils/screenfull.d.ts +2 -0
  60. package/es/utils/screenfull.js +157 -0
  61. package/lib/assets/iconfont/iconfont.js +55 -0
  62. package/lib/constants/index.js +68 -0
  63. package/lib/control/baseControl/buttonControl.js +207 -0
  64. package/lib/control/baseControl/control.js +333 -0
  65. package/lib/control/baseControl/index.js +57 -0
  66. package/lib/control/baseControl/popperControl.js +142 -0
  67. package/lib/control/baseControl/selectControl.js +253 -0
  68. package/lib/control/exportImage.js +177 -0
  69. package/lib/control/fullscreen.js +164 -0
  70. package/lib/control/geoLocate.js +154 -0
  71. package/lib/control/layerControl.js +182 -0
  72. package/lib/control/logo.js +50 -23
  73. package/lib/control/mapTheme.js +151 -0
  74. package/lib/control/mouseLocation.js +120 -0
  75. package/lib/control/scale.js +82 -62
  76. package/lib/control/zoom.js +78 -59
  77. package/lib/css/button.less +70 -0
  78. package/lib/css/control.less +71 -0
  79. package/lib/css/index.css +567 -0
  80. package/lib/css/index.less +12 -0
  81. package/lib/css/l7.less +60 -0
  82. package/lib/css/layerPopup.less +8 -0
  83. package/lib/css/logo.less +18 -0
  84. package/lib/css/mouseLocation.less +9 -0
  85. package/lib/css/popper.less +64 -0
  86. package/lib/css/popup.less +169 -0
  87. package/lib/css/scale.less +34 -0
  88. package/lib/css/select.less +86 -0
  89. package/lib/css/variables.less +28 -0
  90. package/lib/css/zoom.less +21 -0
  91. package/lib/images/logo.png +0 -0
  92. package/lib/images/quanping.svg +12 -0
  93. package/lib/index.js +165 -50
  94. package/lib/popup/layerPopup.js +317 -0
  95. package/lib/popup/popup.js +651 -0
  96. package/lib/utils/icon.js +18 -0
  97. package/lib/utils/popper.js +297 -0
  98. package/lib/utils/screenfull.js +167 -0
  99. package/package.json +8 -5
  100. package/es/control/BaseControl.d.ts +0 -27
  101. package/es/control/BaseControl.js +0 -134
  102. package/es/control/layer.d.ts +0 -38
  103. package/es/control/layer.js +0 -340
  104. package/es/css/l7.css +0 -502
  105. package/es/popup.d.ts +0 -35
  106. package/es/popup.js +0 -300
  107. package/lib/control/BaseControl.js +0 -160
  108. package/lib/control/layer.js +0 -362
  109. package/lib/css/l7.css +0 -502
  110. package/lib/popup.js +0 -317
package/es/popup.js DELETED
@@ -1,300 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
-
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
-
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
-
13
- import { TYPES } from '@antv/l7-core';
14
- import { anchorTranslate, anchorType, applyAnchorClass, bindAll, DOM } from '@antv/l7-utils';
15
- import { EventEmitter } from 'eventemitter3';
16
-
17
- /** colse event */
18
- var Popup = /*#__PURE__*/function (_EventEmitter) {
19
- _inherits(Popup, _EventEmitter);
20
-
21
- var _super = _createSuper(Popup);
22
-
23
- function Popup(cfg) {
24
- var _this;
25
-
26
- _classCallCheck(this, Popup);
27
-
28
- _this = _super.call(this);
29
- _this.popupOption = _objectSpread(_objectSpread({}, _this.getdefault()), cfg);
30
- bindAll(['update', 'onClickClose', 'remove'], _assertThisInitialized(_this));
31
- return _this;
32
- }
33
-
34
- _createClass(Popup, [{
35
- key: "addTo",
36
- value: function addTo(scene) {
37
- var _this2 = this;
38
-
39
- this.mapsService = scene.get(TYPES.IMapService);
40
- this.sceneSerive = scene.get(TYPES.ISceneService);
41
- this.mapsService.on('camerachange', this.update);
42
- this.mapsService.on('viewchange', this.update);
43
- this.scene = scene;
44
- this.update();
45
-
46
- if (this.popupOption.closeOnClick) {
47
- this.timeoutInstance = setTimeout(function () {
48
- _this2.mapsService.on('click', _this2.onClickClose);
49
- }, 30);
50
- }
51
-
52
- this.emit('open');
53
- return this;
54
- }
55
- }, {
56
- key: "close",
57
- value: function close() {
58
- this.remove();
59
- }
60
- }, {
61
- key: "open",
62
- value: function open() {
63
- this.addTo(this.scene);
64
- }
65
- }, {
66
- key: "setHTML",
67
- value: function setHTML(html) {
68
- var frag = window.document.createDocumentFragment();
69
- var temp = window.document.createElement('body');
70
- var child;
71
- temp.innerHTML = html;
72
-
73
- while (true) {
74
- child = temp.firstChild;
75
-
76
- if (!child) {
77
- break;
78
- }
79
-
80
- frag.appendChild(child);
81
- }
82
-
83
- return this.setDOMContent(frag);
84
- }
85
- }, {
86
- key: "setLnglat",
87
- value: function setLnglat(lngLat) {
88
- this.lngLat = lngLat;
89
-
90
- if (Array.isArray(lngLat)) {
91
- this.lngLat = {
92
- lng: lngLat[0],
93
- lat: lngLat[1]
94
- };
95
- }
96
-
97
- if (this.mapsService) {
98
- this.mapsService.on('camerachange', this.update);
99
- this.mapsService.on('viewchange', this.update);
100
- }
101
-
102
- this.update();
103
- return this;
104
- }
105
- }, {
106
- key: "getLnglat",
107
- value: function getLnglat() {
108
- return this.lngLat;
109
- }
110
- }, {
111
- key: "setText",
112
- value: function setText(text) {
113
- return this.setDOMContent(window.document.createTextNode(text));
114
- }
115
- }, {
116
- key: "setMaxWidth",
117
- value: function setMaxWidth(maxWidth) {
118
- this.popupOption.maxWidth = maxWidth;
119
- this.update();
120
- return this;
121
- }
122
- }, {
123
- key: "setDOMContent",
124
- value: function setDOMContent(htmlNode) {
125
- this.createContent();
126
- this.content.appendChild(htmlNode);
127
- this.update();
128
- return this;
129
- } // 移除popup
130
-
131
- }, {
132
- key: "remove",
133
- value: function remove() {
134
- if (this.content) {
135
- this.removeDom(this.content);
136
- }
137
-
138
- if (this.container) {
139
- this.removeDom(this.container); // @ts-ignore
140
-
141
- delete this.container;
142
- }
143
-
144
- if (this.mapsService) {
145
- // TODO: mapbox AMap 事件同步
146
- this.mapsService.off('camerachange', this.update);
147
- this.mapsService.off('viewchange', this.update);
148
- this.mapsService.off('click', this.onClickClose); // @ts-ignore
149
-
150
- delete this.mapsService;
151
- }
152
-
153
- clearTimeout(this.timeoutInstance);
154
- this.emit('close');
155
- return this;
156
- }
157
- }, {
158
- key: "isOpen",
159
- value: function isOpen() {
160
- return !!this.mapsService;
161
- }
162
- }, {
163
- key: "createContent",
164
- value: function createContent() {
165
- if (this.content) {
166
- DOM.remove(this.content);
167
- }
168
-
169
- this.content = DOM.create('div', 'l7-popup-content', this.container);
170
-
171
- if (this.popupOption.closeButton) {
172
- this.closeButton = DOM.create('button', 'l7-popup-close-button', this.content);
173
-
174
- if (this.popupOption.closeButtonOffsets) {
175
- // 关闭按钮的偏移
176
- this.closeButton.style.right = this.popupOption.closeButtonOffsets[0] + 'px';
177
- this.closeButton.style.top = this.popupOption.closeButtonOffsets[1] + 'px';
178
- } // this.closeButton.type = 'button';
179
-
180
-
181
- this.closeButton.setAttribute('aria-label', 'Close popup');
182
- this.closeButton.innerHTML = '×';
183
- this.closeButton.addEventListener('click', this.onClickClose);
184
- }
185
- }
186
- }, {
187
- key: "creatDom",
188
- value: function creatDom(tagName, className, container) {
189
- var el = window.document.createElement(tagName);
190
-
191
- if (className !== undefined) {
192
- el.className = className;
193
- }
194
-
195
- if (container) {
196
- container.appendChild(el);
197
- }
198
-
199
- return el;
200
- }
201
- }, {
202
- key: "removeDom",
203
- value: function removeDom(node) {
204
- if (node.parentNode) {
205
- node.parentNode.removeChild(node);
206
- }
207
- }
208
- }, {
209
- key: "getdefault",
210
- value: function getdefault() {
211
- return {
212
- closeButton: true,
213
- closeOnClick: true,
214
- maxWidth: '240px',
215
- offsets: [0, 0],
216
- anchor: anchorType.BOTTOM,
217
- className: '',
218
- stopPropagation: true
219
- };
220
- }
221
- }, {
222
- key: "onClickClose",
223
- value: function onClickClose(e) {
224
- if (e.stopPropagation) {
225
- e.stopPropagation();
226
- }
227
-
228
- this.remove();
229
- }
230
- }, {
231
- key: "update",
232
- value: function update() {
233
- var _this3 = this;
234
-
235
- var hasPosition = this.lngLat;
236
- var _this$popupOption = this.popupOption,
237
- className = _this$popupOption.className,
238
- maxWidth = _this$popupOption.maxWidth,
239
- anchor = _this$popupOption.anchor;
240
-
241
- if (!this.mapsService || !hasPosition || !this.content) {
242
- return;
243
- }
244
-
245
- var popupContainer = this.mapsService.getMarkerContainer();
246
-
247
- if (!this.container && popupContainer) {
248
- this.container = this.creatDom('div', 'l7-popup', popupContainer);
249
- this.tip = this.creatDom('div', 'l7-popup-tip', this.container);
250
- this.container.appendChild(this.content);
251
-
252
- if (className) {
253
- className.split(' ').forEach(function (name) {
254
- return _this3.container.classList.add(name);
255
- });
256
- } // 高德地图需要阻止事件冒泡 // 测试mapbox 地图不需要添加
257
-
258
-
259
- var stopPropagation = this.popupOption.stopPropagation;
260
-
261
- if (stopPropagation) {
262
- ['mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'].forEach(function (type) {
263
- _this3.container.addEventListener(type, function (e) {
264
- e.stopPropagation();
265
- });
266
- });
267
- }
268
-
269
- this.container.style.whiteSpace = 'nowrap';
270
- }
271
-
272
- if (maxWidth && this.container.style.maxWidth !== maxWidth) {
273
- this.container.style.maxWidth = maxWidth;
274
- }
275
-
276
- this.updatePosition();
277
- DOM.setTransform(this.container, "".concat(anchorTranslate[anchor]));
278
- applyAnchorClass(this.container, anchor, 'popup');
279
- }
280
- }, {
281
- key: "updatePosition",
282
- value: function updatePosition() {
283
- if (!this.mapsService) {
284
- return;
285
- }
286
-
287
- var _this$lngLat = this.lngLat,
288
- lng = _this$lngLat.lng,
289
- lat = _this$lngLat.lat;
290
- var offsets = this.popupOption.offsets;
291
- var pos = this.mapsService.lngLatToContainer([lng, lat]);
292
- this.container.style.left = pos.x + offsets[0] + 'px';
293
- this.container.style.top = pos.y - offsets[1] + 'px';
294
- }
295
- }]);
296
-
297
- return Popup;
298
- }(EventEmitter);
299
-
300
- export { Popup as default };
@@ -1,160 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- Object.defineProperty(exports, "PositionType", {
9
- enumerable: true,
10
- get: function get() {
11
- return _l7Core.PositionType;
12
- }
13
- });
14
- exports.default = void 0;
15
-
16
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
17
-
18
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
-
20
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
-
22
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
-
24
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
25
-
26
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
27
-
28
- var _l7Core = require("@antv/l7-core");
29
-
30
- var _l7Utils = require("@antv/l7-utils");
31
-
32
- var _eventemitter = require("eventemitter3");
33
-
34
- 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); }; }
35
-
36
- 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; } }
37
-
38
- var controlId = 0;
39
-
40
- var Control = /*#__PURE__*/function (_EventEmitter) {
41
- (0, _inherits2.default)(Control, _EventEmitter);
42
-
43
- var _super = _createSuper(Control);
44
-
45
- function Control(cfg) {
46
- var _this;
47
-
48
- (0, _classCallCheck2.default)(this, Control);
49
- _this = _super.call(this);
50
- _this.controlOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _this.getDefault()), cfg || {});
51
- return _this;
52
- }
53
-
54
- (0, _createClass2.default)(Control, [{
55
- key: "getDefault",
56
- value: function getDefault() {
57
- return {
58
- position: _l7Core.PositionType.TOPRIGHT,
59
- name: "".concat(controlId++)
60
- };
61
- }
62
- }, {
63
- key: "setPosition",
64
- value: function setPosition() {
65
- var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _l7Core.PositionType.BOTTOMRIGHT;
66
- // 考虑组件的自动布局,需要销毁重建
67
- var controlService = this.controlService;
68
-
69
- if (controlService) {
70
- controlService.removeControl(this);
71
- }
72
-
73
- this.controlOption.position = position;
74
-
75
- if (controlService) {
76
- controlService.addControl(this, this.sceneContainer);
77
- }
78
-
79
- return this;
80
- }
81
- }, {
82
- key: "addTo",
83
- value: function addTo(sceneContainer) {
84
- this.mapsService = sceneContainer.get(_l7Core.TYPES.IMapService);
85
- this.renderService = sceneContainer.get(_l7Core.TYPES.IRendererService);
86
- this.layerService = sceneContainer.get(_l7Core.TYPES.ILayerService);
87
- this.controlService = sceneContainer.get(_l7Core.TYPES.IControlService);
88
- this.sceneContainer = sceneContainer;
89
- this.isShow = true;
90
- this.container = this.onAdd();
91
- var container = this.container;
92
- var pos = this.controlOption.position;
93
- var corner = this.controlService.controlCorners[pos];
94
-
95
- _l7Utils.DOM.addClass(container, 'l7-control');
96
-
97
- if (pos.indexOf('bottom') !== -1) {
98
- corner.insertBefore(container, corner.firstChild);
99
- } else {
100
- corner.appendChild(container);
101
- }
102
-
103
- return this;
104
- }
105
- }, {
106
- key: "onAdd",
107
- value: function onAdd() {
108
- throw new Error('Method not implemented.');
109
- }
110
- }, {
111
- key: "onRemove",
112
- value: function onRemove() {
113
- throw new Error('Method not implemented.');
114
- }
115
- }, {
116
- key: "hide",
117
- value: function hide() {
118
- var container = this.container;
119
-
120
- _l7Utils.DOM.addClass(container, 'l7-control-hide');
121
-
122
- this.isShow = false;
123
- }
124
- }, {
125
- key: "show",
126
- value: function show() {
127
- var container = this.container;
128
-
129
- _l7Utils.DOM.removeClass(container, 'l7-control-hide');
130
-
131
- this.isShow = true;
132
- }
133
- }, {
134
- key: "remove",
135
- value: function remove() {
136
- if (!this.mapsService) {
137
- return this;
138
- }
139
-
140
- _l7Utils.DOM.remove(this.container);
141
-
142
- this.onRemove();
143
- }
144
- }, {
145
- key: "_refocusOnMap",
146
- value: function _refocusOnMap(e) {
147
- // if map exists and event is not a keyboard event
148
- if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
149
- var container = this.mapsService.getContainer();
150
-
151
- if (container !== null) {
152
- container.focus();
153
- }
154
- }
155
- }
156
- }]);
157
- return Control;
158
- }(_eventemitter.EventEmitter);
159
-
160
- exports.default = Control;