@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
@@ -1,38 +0,0 @@
1
- import { PositionType } from '@antv/l7-core';
2
- import { ILayerControlOption } from '../interface';
3
- import Control from './BaseControl';
4
- export default class Layers extends Control {
5
- private layerControlInputs;
6
- private layers;
7
- private lastZIndex;
8
- private handlingClick;
9
- private layersLink;
10
- private baseLayersList;
11
- private separator;
12
- private overlaysList;
13
- private form;
14
- constructor(cfg: Partial<ILayerControlOption>);
15
- getDefault(): {
16
- collapsed: boolean;
17
- position: PositionType;
18
- autoZIndex: boolean;
19
- hideSingleBase: boolean;
20
- sortLayers: boolean;
21
- name: string;
22
- };
23
- onAdd(): HTMLElement;
24
- addVisualLayer(layer: any, name: string | number): this;
25
- expand(): this;
26
- collapse(): this;
27
- onRemove(): void;
28
- private initLayout;
29
- private initLayers;
30
- private update;
31
- private checkDisabledLayers;
32
- private addLayer;
33
- private expandIfNotCollapsed;
34
- private onLayerChange;
35
- private createRadioElement;
36
- private addItem;
37
- private onInputClick;
38
- }
@@ -1,340 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
-
8
- 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); }; }
9
-
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
-
12
- import { PositionType } from '@antv/l7-core';
13
- import { bindAll, DOM } from '@antv/l7-utils';
14
- import Control from "./BaseControl";
15
-
16
- var Layers = /*#__PURE__*/function (_Control) {
17
- _inherits(Layers, _Control);
18
-
19
- var _super = _createSuper(Layers);
20
-
21
- function Layers(cfg) {
22
- var _this;
23
-
24
- _classCallCheck(this, Layers);
25
-
26
- _this = _super.call(this, cfg);
27
- _this.layerControlInputs = [];
28
- _this.layers = [];
29
- _this.lastZIndex = 0;
30
- _this.handlingClick = false;
31
-
32
- _this.initLayers();
33
-
34
- bindAll(['checkDisabledLayers', 'onLayerChange', 'collapse', 'extend', 'expand', 'onInputClick'], _assertThisInitialized(_this));
35
- return _this;
36
- }
37
-
38
- _createClass(Layers, [{
39
- key: "getDefault",
40
- value: function getDefault() {
41
- return {
42
- collapsed: true,
43
- position: PositionType.TOPRIGHT,
44
- autoZIndex: true,
45
- hideSingleBase: false,
46
- sortLayers: false,
47
- name: 'layers'
48
- };
49
- }
50
- }, {
51
- key: "onAdd",
52
- value: function onAdd() {
53
- var _this2 = this;
54
-
55
- this.initLayout();
56
- this.update();
57
- this.mapsService.on('zoomend', this.checkDisabledLayers);
58
- this.layers.forEach(function (layerItem) {
59
- layerItem.layer.on('remove', _this2.onLayerChange);
60
- layerItem.layer.on('add', _this2.onLayerChange);
61
- });
62
- return this.container;
63
- }
64
- }, {
65
- key: "addVisualLayer",
66
- value: function addVisualLayer(layer, name) {
67
- this.addLayer(layer, name, true);
68
- return this.mapsService ? this.update() : this;
69
- }
70
- }, {
71
- key: "expand",
72
- value: function expand() {
73
- var _this$renderService$g = this.renderService.getViewportSize(),
74
- height = _this$renderService$g.height;
75
-
76
- DOM.addClass(this.container, 'l7-control-layers-expanded');
77
- this.form.style.height = 'null';
78
- var acceptableHeight = height - (this.container.offsetTop + 50);
79
-
80
- if (acceptableHeight < this.form.clientHeight) {
81
- DOM.addClass(this.form, 'l7-control-layers-scrollbar');
82
- this.form.style.height = acceptableHeight + 'px';
83
- } else {
84
- DOM.removeClass(this.form, 'l7-control-layers-scrollbar');
85
- }
86
-
87
- this.checkDisabledLayers();
88
- return this;
89
- }
90
- }, {
91
- key: "collapse",
92
- value: function collapse() {
93
- DOM.removeClass(this.container, 'l7-control-layers-expanded');
94
- return this;
95
- }
96
- }, {
97
- key: "onRemove",
98
- value: function onRemove() {
99
- var _this3 = this;
100
-
101
- if (!this.mapsService) {
102
- return;
103
- }
104
-
105
- this.mapsService.off('click', this.collapse);
106
- this.layers.forEach(function (layerItem) {
107
- layerItem.layer.off('remove', _this3.onLayerChange);
108
- layerItem.layer.off('add', _this3.onLayerChange);
109
- });
110
- }
111
- }, {
112
- key: "initLayout",
113
- value: function initLayout() {
114
- var className = 'l7-control-layers';
115
- var container = this.container = DOM.create('div', className);
116
- var collapsed = this.controlOption.collapsed; // makes this work on IE touch devices by stopping it from firing a mouseout event when the touch is released
117
-
118
- container.setAttribute('aria-haspopup', 'true');
119
- var form = this.form = DOM.create('form', className + '-list');
120
-
121
- if (collapsed) {
122
- this.mapsService.on('click', this.collapse);
123
- container.addEventListener('mouseenter', this.expand);
124
- container.addEventListener('mouseleave', this.collapse);
125
- }
126
-
127
- this.layersLink = DOM.create('a', className + '-toggle', container);
128
- var link = this.layersLink; // link.href = '#';
129
-
130
- link.title = 'Layers';
131
-
132
- if (!collapsed) {
133
- this.expand();
134
- }
135
-
136
- this.baseLayersList = DOM.create('div', className + '-base', form);
137
- this.separator = DOM.create('div', className + '-separator', form);
138
- this.overlaysList = DOM.create('div', className + '-overlays', form);
139
- container.appendChild(form);
140
- }
141
- }, {
142
- key: "initLayers",
143
- value: function initLayers() {
144
- var _this4 = this;
145
-
146
- var _this$controlOption = this.controlOption,
147
- _this$controlOption$b = _this$controlOption.baseLayers,
148
- baseLayers = _this$controlOption$b === void 0 ? {} : _this$controlOption$b,
149
- _this$controlOption$o = _this$controlOption.overlayers,
150
- overlayers = _this$controlOption$o === void 0 ? {} : _this$controlOption$o;
151
- Object.keys(baseLayers).forEach(function (name) {
152
- // baseLayers[name].once('inited', this.update);
153
- _this4.addLayer(baseLayers[name], name, false);
154
- });
155
- Object.keys(overlayers).forEach(function (name) {
156
- // overlayers[name].once('inited', this.update);
157
- _this4.addLayer(overlayers[name], name, true);
158
- });
159
- }
160
- }, {
161
- key: "update",
162
- value: function update() {
163
- if (!this.container) {
164
- return this;
165
- }
166
-
167
- DOM.empty(this.baseLayersList);
168
- DOM.empty(this.overlaysList);
169
- this.layerControlInputs = [];
170
- var baseLayersPresent;
171
- var overlaysPresent;
172
- var i;
173
- var obj;
174
- var baseLayersCount = 0;
175
-
176
- for (i = 0; i < this.layers.length; i++) {
177
- obj = this.layers[i];
178
- this.addItem(obj);
179
- overlaysPresent = overlaysPresent || obj.overlay;
180
- baseLayersPresent = baseLayersPresent || !obj.overlay;
181
- baseLayersCount += !obj.overlay ? 1 : 0;
182
- } // Hide base layers section if there's only one layer.
183
-
184
-
185
- if (this.controlOption.hideSingleBase) {
186
- baseLayersPresent = baseLayersPresent && baseLayersCount > 1;
187
- this.baseLayersList.style.display = baseLayersPresent ? '' : 'none';
188
- }
189
-
190
- this.separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';
191
- return this;
192
- }
193
- }, {
194
- key: "checkDisabledLayers",
195
- value: function checkDisabledLayers() {
196
- var inputs = this.layerControlInputs;
197
- var input;
198
- var layer;
199
- var zoom = this.mapsService.getZoom();
200
-
201
- for (var i = inputs.length - 1; i >= 0; i--) {
202
- input = inputs[i];
203
- layer = this.layerService.getLayer(input.layerId);
204
-
205
- if (layer && layer.inited) {
206
- var minZoom = layer.getMinZoom();
207
- var maxZoom = layer.getMaxZoom();
208
- input.disabled = zoom < minZoom || zoom > maxZoom;
209
- }
210
- }
211
- }
212
- }, {
213
- key: "addLayer",
214
- value: function addLayer(layer, name, overlay) {
215
- if (this.mapsService) {
216
- layer.on('add', this.onLayerChange);
217
- layer.on('remove', this.onLayerChange);
218
- }
219
-
220
- this.layers.push({
221
- layer: layer,
222
- name: name,
223
- overlay: overlay
224
- });
225
- var _this$controlOption2 = this.controlOption,
226
- sortLayers = _this$controlOption2.sortLayers,
227
- sortFunction = _this$controlOption2.sortFunction,
228
- autoZIndex = _this$controlOption2.autoZIndex;
229
-
230
- if (sortLayers) {
231
- this.layers.sort(function (a, b) {
232
- return sortFunction(a.layer, b.layer, a.name, b.name);
233
- });
234
- }
235
-
236
- if (autoZIndex && layer.setZIndex) {
237
- this.lastZIndex++;
238
- layer.setZIndex(this.lastZIndex);
239
- }
240
-
241
- this.expandIfNotCollapsed();
242
- }
243
- }, {
244
- key: "expandIfNotCollapsed",
245
- value: function expandIfNotCollapsed() {
246
- if (this.mapsService && !this.controlOption.collapsed) {
247
- this.expand();
248
- }
249
-
250
- return this;
251
- }
252
- }, {
253
- key: "onLayerChange",
254
- value: function onLayerChange(e) {
255
- if (!this.handlingClick) {
256
- this.update();
257
- }
258
-
259
- var obj = this.layerService.getLayer(e.target.layerId); // @ts-ignore
260
-
261
- var type = obj !== null && obj !== void 0 && obj.overlay ? e.type === 'add' ? 'overlayadd' : 'overlayremove' : e.type === 'add' ? 'baselayerchange' : null;
262
-
263
- if (type) {
264
- this.emit(type, obj);
265
- }
266
- }
267
- }, {
268
- key: "createRadioElement",
269
- value: function createRadioElement(name, checked) {
270
- var radioHtml = '<input type="radio" class="l7-control-layers-selector" name="' + name + '"' + (checked ? ' checked="checked"' : '') + '/>';
271
- var radioFragment = document.createElement('div');
272
- radioFragment.innerHTML = radioHtml;
273
- return radioFragment.firstChild;
274
- }
275
- }, {
276
- key: "addItem",
277
- value: function addItem(obj) {
278
- var label = document.createElement('label');
279
- var layer = this.layerService.getLayer(obj.layer.id);
280
- var checked = layer && layer.inited && obj.layer.isVisible();
281
- var input;
282
-
283
- if (obj.overlay) {
284
- input = document.createElement('input');
285
- input.type = 'checkbox';
286
- input.className = 'l7-control-layers-selector';
287
- input.defaultChecked = checked;
288
- } else {
289
- input = this.createRadioElement('l7-base-layers', checked);
290
- }
291
-
292
- this.layerControlInputs.push(input);
293
- input.layerId = obj.layer.id;
294
- input.addEventListener('click', this.onInputClick);
295
- var name = document.createElement('span');
296
- name.innerHTML = ' ' + obj.name;
297
- var holder = document.createElement('div');
298
- label.appendChild(holder);
299
- holder.appendChild(input);
300
- holder.appendChild(name);
301
- var container = obj.overlay ? this.overlaysList : this.baseLayersList;
302
- container.appendChild(label);
303
- this.checkDisabledLayers();
304
- return label;
305
- }
306
- }, {
307
- key: "onInputClick",
308
- value: function onInputClick() {
309
- var inputs = this.layerControlInputs;
310
- var input;
311
- var layer;
312
- var addedLayers = [];
313
- var removedLayers = [];
314
- this.handlingClick = true;
315
-
316
- for (var i = inputs.length - 1; i >= 0; i--) {
317
- input = inputs[i];
318
- layer = this.layerService.getLayer(input.layerId);
319
-
320
- if (input.checked) {
321
- addedLayers.push(layer);
322
- } else if (!input.checked) {
323
- removedLayers.push(layer);
324
- }
325
- }
326
-
327
- removedLayers.forEach(function (l) {
328
- l.hide();
329
- });
330
- addedLayers.forEach(function (l) {
331
- l.show();
332
- });
333
- this.handlingClick = false;
334
- }
335
- }]);
336
-
337
- return Layers;
338
- }(Control);
339
-
340
- export { Layers as default };