@antv/l7-component 2.9.36-alpha.1 → 2.9.37

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/control/BaseControl.d.ts +27 -0
  2. package/es/control/BaseControl.js +134 -0
  3. package/es/control/layer.d.ts +38 -0
  4. package/es/control/layer.js +340 -0
  5. package/es/control/logo.d.ts +6 -10
  6. package/es/control/logo.js +11 -41
  7. package/es/control/scale.d.ts +10 -20
  8. package/es/control/scale.js +53 -77
  9. package/es/control/zoom.d.ts +10 -21
  10. package/es/control/zoom.js +49 -76
  11. package/es/css/l7.css +502 -0
  12. package/es/images/logo.png +0 -0
  13. package/es/index.d.ts +8 -15
  14. package/es/index.js +9 -15
  15. package/es/interface.d.ts +20 -1
  16. package/es/popup.d.ts +35 -0
  17. package/es/popup.js +300 -0
  18. package/lib/control/BaseControl.js +160 -0
  19. package/lib/control/layer.js +362 -0
  20. package/lib/control/logo.js +23 -50
  21. package/lib/control/scale.js +62 -82
  22. package/lib/control/zoom.js +59 -78
  23. package/lib/css/l7.css +502 -0
  24. package/lib/images/logo.png +0 -0
  25. package/lib/index.js +50 -165
  26. package/lib/popup.js +317 -0
  27. package/package.json +5 -8
  28. package/es/assets/iconfont/iconfont.js +0 -53
  29. package/es/constants/index.d.ts +0 -60
  30. package/es/constants/index.js +0 -60
  31. package/es/control/baseControl/buttonControl.d.ts +0 -59
  32. package/es/control/baseControl/buttonControl.js +0 -191
  33. package/es/control/baseControl/control.d.ts +0 -106
  34. package/es/control/baseControl/control.js +0 -301
  35. package/es/control/baseControl/index.d.ts +0 -4
  36. package/es/control/baseControl/index.js +0 -4
  37. package/es/control/baseControl/popperControl.d.ts +0 -26
  38. package/es/control/baseControl/popperControl.js +0 -131
  39. package/es/control/baseControl/selectControl.d.ts +0 -46
  40. package/es/control/baseControl/selectControl.js +0 -232
  41. package/es/control/exportImage.d.ts +0 -18
  42. package/es/control/exportImage.js +0 -163
  43. package/es/control/fullscreen.d.ts +0 -19
  44. package/es/control/fullscreen.js +0 -151
  45. package/es/control/geoLocate.d.ts +0 -16
  46. package/es/control/geoLocate.js +0 -139
  47. package/es/control/layerControl.d.ts +0 -21
  48. package/es/control/layerControl.js +0 -172
  49. package/es/control/mapTheme.d.ts +0 -10
  50. package/es/control/mapTheme.js +0 -135
  51. package/es/control/mouseLocation.d.ts +0 -15
  52. package/es/control/mouseLocation.js +0 -104
  53. package/es/css/button.less +0 -70
  54. package/es/css/control.less +0 -71
  55. package/es/css/index.css +0 -567
  56. package/es/css/index.less +0 -12
  57. package/es/css/l7.less +0 -60
  58. package/es/css/layerPopup.less +0 -8
  59. package/es/css/logo.less +0 -18
  60. package/es/css/mouseLocation.less +0 -9
  61. package/es/css/popper.less +0 -64
  62. package/es/css/popup.less +0 -169
  63. package/es/css/scale.less +0 -34
  64. package/es/css/select.less +0 -86
  65. package/es/css/variables.less +0 -28
  66. package/es/css/zoom.less +0 -21
  67. package/es/images/quanping.svg +0 -12
  68. package/es/popup/layerPopup.d.ts +0 -78
  69. package/es/popup/layerPopup.js +0 -308
  70. package/es/popup/popup.d.ts +0 -147
  71. package/es/popup/popup.js +0 -636
  72. package/es/utils/icon.d.ts +0 -1
  73. package/es/utils/icon.js +0 -9
  74. package/es/utils/popper.d.ts +0 -75
  75. package/es/utils/popper.js +0 -286
  76. package/es/utils/screenfull.d.ts +0 -2
  77. package/es/utils/screenfull.js +0 -157
  78. package/lib/assets/iconfont/iconfont.js +0 -55
  79. package/lib/constants/index.js +0 -68
  80. package/lib/control/baseControl/buttonControl.js +0 -207
  81. package/lib/control/baseControl/control.js +0 -333
  82. package/lib/control/baseControl/index.js +0 -57
  83. package/lib/control/baseControl/popperControl.js +0 -142
  84. package/lib/control/baseControl/selectControl.js +0 -253
  85. package/lib/control/exportImage.js +0 -177
  86. package/lib/control/fullscreen.js +0 -164
  87. package/lib/control/geoLocate.js +0 -154
  88. package/lib/control/layerControl.js +0 -182
  89. package/lib/control/mapTheme.js +0 -151
  90. package/lib/control/mouseLocation.js +0 -120
  91. package/lib/css/button.less +0 -70
  92. package/lib/css/control.less +0 -71
  93. package/lib/css/index.css +0 -567
  94. package/lib/css/index.less +0 -12
  95. package/lib/css/l7.less +0 -60
  96. package/lib/css/layerPopup.less +0 -8
  97. package/lib/css/logo.less +0 -18
  98. package/lib/css/mouseLocation.less +0 -9
  99. package/lib/css/popper.less +0 -64
  100. package/lib/css/popup.less +0 -169
  101. package/lib/css/scale.less +0 -34
  102. package/lib/css/select.less +0 -86
  103. package/lib/css/variables.less +0 -28
  104. package/lib/css/zoom.less +0 -21
  105. package/lib/images/quanping.svg +0 -12
  106. package/lib/popup/layerPopup.js +0 -317
  107. package/lib/popup/popup.js +0 -651
  108. package/lib/utils/icon.js +0 -18
  109. package/lib/utils/popper.js +0 -297
  110. package/lib/utils/screenfull.js +0 -167
@@ -0,0 +1,362 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _l7Core = require("@antv/l7-core");
23
+
24
+ var _l7Utils = require("@antv/l7-utils");
25
+
26
+ var _BaseControl = _interopRequireDefault(require("./BaseControl"));
27
+
28
+ 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); }; }
29
+
30
+ 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; } }
31
+
32
+ var Layers = /*#__PURE__*/function (_Control) {
33
+ (0, _inherits2.default)(Layers, _Control);
34
+
35
+ var _super = _createSuper(Layers);
36
+
37
+ function Layers(cfg) {
38
+ var _this;
39
+
40
+ (0, _classCallCheck2.default)(this, Layers);
41
+ _this = _super.call(this, cfg);
42
+ _this.layerControlInputs = [];
43
+ _this.layers = [];
44
+ _this.lastZIndex = 0;
45
+ _this.handlingClick = false;
46
+
47
+ _this.initLayers();
48
+
49
+ (0, _l7Utils.bindAll)(['checkDisabledLayers', 'onLayerChange', 'collapse', 'extend', 'expand', 'onInputClick'], (0, _assertThisInitialized2.default)(_this));
50
+ return _this;
51
+ }
52
+
53
+ (0, _createClass2.default)(Layers, [{
54
+ key: "getDefault",
55
+ value: function getDefault() {
56
+ return {
57
+ collapsed: true,
58
+ position: _l7Core.PositionType.TOPRIGHT,
59
+ autoZIndex: true,
60
+ hideSingleBase: false,
61
+ sortLayers: false,
62
+ name: 'layers'
63
+ };
64
+ }
65
+ }, {
66
+ key: "onAdd",
67
+ value: function onAdd() {
68
+ var _this2 = this;
69
+
70
+ this.initLayout();
71
+ this.update();
72
+ this.mapsService.on('zoomend', this.checkDisabledLayers);
73
+ this.layers.forEach(function (layerItem) {
74
+ layerItem.layer.on('remove', _this2.onLayerChange);
75
+ layerItem.layer.on('add', _this2.onLayerChange);
76
+ });
77
+ return this.container;
78
+ }
79
+ }, {
80
+ key: "addVisualLayer",
81
+ value: function addVisualLayer(layer, name) {
82
+ this.addLayer(layer, name, true);
83
+ return this.mapsService ? this.update() : this;
84
+ }
85
+ }, {
86
+ key: "expand",
87
+ value: function expand() {
88
+ var _this$renderService$g = this.renderService.getViewportSize(),
89
+ height = _this$renderService$g.height;
90
+
91
+ _l7Utils.DOM.addClass(this.container, 'l7-control-layers-expanded');
92
+
93
+ this.form.style.height = 'null';
94
+ var acceptableHeight = height - (this.container.offsetTop + 50);
95
+
96
+ if (acceptableHeight < this.form.clientHeight) {
97
+ _l7Utils.DOM.addClass(this.form, 'l7-control-layers-scrollbar');
98
+
99
+ this.form.style.height = acceptableHeight + 'px';
100
+ } else {
101
+ _l7Utils.DOM.removeClass(this.form, 'l7-control-layers-scrollbar');
102
+ }
103
+
104
+ this.checkDisabledLayers();
105
+ return this;
106
+ }
107
+ }, {
108
+ key: "collapse",
109
+ value: function collapse() {
110
+ _l7Utils.DOM.removeClass(this.container, 'l7-control-layers-expanded');
111
+
112
+ return this;
113
+ }
114
+ }, {
115
+ key: "onRemove",
116
+ value: function onRemove() {
117
+ var _this3 = this;
118
+
119
+ if (!this.mapsService) {
120
+ return;
121
+ }
122
+
123
+ this.mapsService.off('click', this.collapse);
124
+ this.layers.forEach(function (layerItem) {
125
+ layerItem.layer.off('remove', _this3.onLayerChange);
126
+ layerItem.layer.off('add', _this3.onLayerChange);
127
+ });
128
+ }
129
+ }, {
130
+ key: "initLayout",
131
+ value: function initLayout() {
132
+ var className = 'l7-control-layers';
133
+
134
+ var container = this.container = _l7Utils.DOM.create('div', className);
135
+
136
+ 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
137
+
138
+ container.setAttribute('aria-haspopup', 'true');
139
+
140
+ var form = this.form = _l7Utils.DOM.create('form', className + '-list');
141
+
142
+ if (collapsed) {
143
+ this.mapsService.on('click', this.collapse);
144
+ container.addEventListener('mouseenter', this.expand);
145
+ container.addEventListener('mouseleave', this.collapse);
146
+ }
147
+
148
+ this.layersLink = _l7Utils.DOM.create('a', className + '-toggle', container);
149
+ var link = this.layersLink; // link.href = '#';
150
+
151
+ link.title = 'Layers';
152
+
153
+ if (!collapsed) {
154
+ this.expand();
155
+ }
156
+
157
+ this.baseLayersList = _l7Utils.DOM.create('div', className + '-base', form);
158
+ this.separator = _l7Utils.DOM.create('div', className + '-separator', form);
159
+ this.overlaysList = _l7Utils.DOM.create('div', className + '-overlays', form);
160
+ container.appendChild(form);
161
+ }
162
+ }, {
163
+ key: "initLayers",
164
+ value: function initLayers() {
165
+ var _this4 = this;
166
+
167
+ var _this$controlOption = this.controlOption,
168
+ _this$controlOption$b = _this$controlOption.baseLayers,
169
+ baseLayers = _this$controlOption$b === void 0 ? {} : _this$controlOption$b,
170
+ _this$controlOption$o = _this$controlOption.overlayers,
171
+ overlayers = _this$controlOption$o === void 0 ? {} : _this$controlOption$o;
172
+ Object.keys(baseLayers).forEach(function (name) {
173
+ // baseLayers[name].once('inited', this.update);
174
+ _this4.addLayer(baseLayers[name], name, false);
175
+ });
176
+ Object.keys(overlayers).forEach(function (name) {
177
+ // overlayers[name].once('inited', this.update);
178
+ _this4.addLayer(overlayers[name], name, true);
179
+ });
180
+ }
181
+ }, {
182
+ key: "update",
183
+ value: function update() {
184
+ if (!this.container) {
185
+ return this;
186
+ }
187
+
188
+ _l7Utils.DOM.empty(this.baseLayersList);
189
+
190
+ _l7Utils.DOM.empty(this.overlaysList);
191
+
192
+ this.layerControlInputs = [];
193
+ var baseLayersPresent;
194
+ var overlaysPresent;
195
+ var i;
196
+ var obj;
197
+ var baseLayersCount = 0;
198
+
199
+ for (i = 0; i < this.layers.length; i++) {
200
+ obj = this.layers[i];
201
+ this.addItem(obj);
202
+ overlaysPresent = overlaysPresent || obj.overlay;
203
+ baseLayersPresent = baseLayersPresent || !obj.overlay;
204
+ baseLayersCount += !obj.overlay ? 1 : 0;
205
+ } // Hide base layers section if there's only one layer.
206
+
207
+
208
+ if (this.controlOption.hideSingleBase) {
209
+ baseLayersPresent = baseLayersPresent && baseLayersCount > 1;
210
+ this.baseLayersList.style.display = baseLayersPresent ? '' : 'none';
211
+ }
212
+
213
+ this.separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';
214
+ return this;
215
+ }
216
+ }, {
217
+ key: "checkDisabledLayers",
218
+ value: function checkDisabledLayers() {
219
+ var inputs = this.layerControlInputs;
220
+ var input;
221
+ var layer;
222
+ var zoom = this.mapsService.getZoom();
223
+
224
+ for (var i = inputs.length - 1; i >= 0; i--) {
225
+ input = inputs[i];
226
+ layer = this.layerService.getLayer(input.layerId);
227
+
228
+ if (layer && layer.inited) {
229
+ var minZoom = layer.getMinZoom();
230
+ var maxZoom = layer.getMaxZoom();
231
+ input.disabled = zoom < minZoom || zoom > maxZoom;
232
+ }
233
+ }
234
+ }
235
+ }, {
236
+ key: "addLayer",
237
+ value: function addLayer(layer, name, overlay) {
238
+ if (this.mapsService) {
239
+ layer.on('add', this.onLayerChange);
240
+ layer.on('remove', this.onLayerChange);
241
+ }
242
+
243
+ this.layers.push({
244
+ layer: layer,
245
+ name: name,
246
+ overlay: overlay
247
+ });
248
+ var _this$controlOption2 = this.controlOption,
249
+ sortLayers = _this$controlOption2.sortLayers,
250
+ sortFunction = _this$controlOption2.sortFunction,
251
+ autoZIndex = _this$controlOption2.autoZIndex;
252
+
253
+ if (sortLayers) {
254
+ this.layers.sort(function (a, b) {
255
+ return sortFunction(a.layer, b.layer, a.name, b.name);
256
+ });
257
+ }
258
+
259
+ if (autoZIndex && layer.setZIndex) {
260
+ this.lastZIndex++;
261
+ layer.setZIndex(this.lastZIndex);
262
+ }
263
+
264
+ this.expandIfNotCollapsed();
265
+ }
266
+ }, {
267
+ key: "expandIfNotCollapsed",
268
+ value: function expandIfNotCollapsed() {
269
+ if (this.mapsService && !this.controlOption.collapsed) {
270
+ this.expand();
271
+ }
272
+
273
+ return this;
274
+ }
275
+ }, {
276
+ key: "onLayerChange",
277
+ value: function onLayerChange(e) {
278
+ if (!this.handlingClick) {
279
+ this.update();
280
+ }
281
+
282
+ var obj = this.layerService.getLayer(e.target.layerId); // @ts-ignore
283
+
284
+ var type = obj !== null && obj !== void 0 && obj.overlay ? e.type === 'add' ? 'overlayadd' : 'overlayremove' : e.type === 'add' ? 'baselayerchange' : null;
285
+
286
+ if (type) {
287
+ this.emit(type, obj);
288
+ }
289
+ }
290
+ }, {
291
+ key: "createRadioElement",
292
+ value: function createRadioElement(name, checked) {
293
+ var radioHtml = '<input type="radio" class="l7-control-layers-selector" name="' + name + '"' + (checked ? ' checked="checked"' : '') + '/>';
294
+ var radioFragment = document.createElement('div');
295
+ radioFragment.innerHTML = radioHtml;
296
+ return radioFragment.firstChild;
297
+ }
298
+ }, {
299
+ key: "addItem",
300
+ value: function addItem(obj) {
301
+ var label = document.createElement('label');
302
+ var layer = this.layerService.getLayer(obj.layer.id);
303
+ var checked = layer && layer.inited && obj.layer.isVisible();
304
+ var input;
305
+
306
+ if (obj.overlay) {
307
+ input = document.createElement('input');
308
+ input.type = 'checkbox';
309
+ input.className = 'l7-control-layers-selector';
310
+ input.defaultChecked = checked;
311
+ } else {
312
+ input = this.createRadioElement('l7-base-layers', checked);
313
+ }
314
+
315
+ this.layerControlInputs.push(input);
316
+ input.layerId = obj.layer.id;
317
+ input.addEventListener('click', this.onInputClick);
318
+ var name = document.createElement('span');
319
+ name.innerHTML = ' ' + obj.name;
320
+ var holder = document.createElement('div');
321
+ label.appendChild(holder);
322
+ holder.appendChild(input);
323
+ holder.appendChild(name);
324
+ var container = obj.overlay ? this.overlaysList : this.baseLayersList;
325
+ container.appendChild(label);
326
+ this.checkDisabledLayers();
327
+ return label;
328
+ }
329
+ }, {
330
+ key: "onInputClick",
331
+ value: function onInputClick() {
332
+ var inputs = this.layerControlInputs;
333
+ var input;
334
+ var layer;
335
+ var addedLayers = [];
336
+ var removedLayers = [];
337
+ this.handlingClick = true;
338
+
339
+ for (var i = inputs.length - 1; i >= 0; i--) {
340
+ input = inputs[i];
341
+ layer = this.layerService.getLayer(input.layerId);
342
+
343
+ if (input.checked) {
344
+ addedLayers.push(layer);
345
+ } else if (!input.checked) {
346
+ removedLayers.push(layer);
347
+ }
348
+ }
349
+
350
+ removedLayers.forEach(function (l) {
351
+ l.hide();
352
+ });
353
+ addedLayers.forEach(function (l) {
354
+ l.show();
355
+ });
356
+ this.handlingClick = false;
357
+ }
358
+ }]);
359
+ return Layers;
360
+ }(_BaseControl.default);
361
+
362
+ exports.default = Layers;
@@ -2,17 +2,17 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
- exports.default = exports.Logo = void 0;
10
+ exports.default = void 0;
9
11
 
10
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
13
 
12
14
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
15
 
14
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
15
-
16
16
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
17
 
18
18
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
@@ -21,7 +21,11 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
21
21
 
22
22
  var _l7Utils = require("@antv/l7-utils");
23
23
 
24
- var _baseControl = require("./baseControl");
24
+ var _BaseControl = _interopRequireWildcard(require("./BaseControl"));
25
+
26
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
+
28
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
29
 
26
30
  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); }; }
27
31
 
@@ -41,18 +45,25 @@ var Logo = /*#__PURE__*/function (_Control) {
41
45
  key: "getDefault",
42
46
  value: function getDefault() {
43
47
  return {
44
- position: _baseControl.PositionType.BOTTOMLEFT,
45
- name: 'logo',
46
- href: 'https://l7.antv.vision/',
47
- img: 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*GRb1TKp4HcMAAAAAAAAAAAAAARQnAQ'
48
+ position: _BaseControl.PositionType.BOTTOMLEFT,
49
+ name: 'logo'
48
50
  };
49
51
  }
50
52
  }, {
51
53
  key: "onAdd",
52
54
  value: function onAdd() {
53
- var container = _l7Utils.DOM.create('div', 'l7-control-logo');
55
+ var className = 'l7-control-logo';
56
+
57
+ var container = _l7Utils.DOM.create('div', className);
58
+
59
+ var anchor = _l7Utils.DOM.create('a', 'l7-ctrl-logo');
54
60
 
55
- this.setLogoContent(container);
61
+ anchor.target = '_blank';
62
+ anchor.rel = 'noopener nofollow';
63
+ anchor.href = 'https://antv.alipay.com/l7';
64
+ anchor.setAttribute('aria-label', 'AntV logo');
65
+ anchor.setAttribute('rel', 'noopener nofollow');
66
+ container.appendChild(anchor);
56
67
  return container;
57
68
  }
58
69
  }, {
@@ -60,46 +71,8 @@ var Logo = /*#__PURE__*/function (_Control) {
60
71
  value: function onRemove() {
61
72
  return null;
62
73
  }
63
- }, {
64
- key: "setOptions",
65
- value: function setOptions(option) {
66
- (0, _get2.default)((0, _getPrototypeOf2.default)(Logo.prototype), "setOptions", this).call(this, option);
67
-
68
- if (this.checkUpdateOption(option, ['img', 'href'])) {
69
- _l7Utils.DOM.clearChildren(this.container);
70
-
71
- this.setLogoContent(this.container);
72
- }
73
- }
74
- }, {
75
- key: "setLogoContent",
76
- value: function setLogoContent(container) {
77
- var _this$controlOption = this.controlOption,
78
- href = _this$controlOption.href,
79
- img = _this$controlOption.img;
80
-
81
- var imgDOM = _l7Utils.DOM.create('img');
82
-
83
- imgDOM.setAttribute('src', img);
84
- imgDOM.setAttribute('aria-label', 'AntV logo');
85
-
86
- _l7Utils.DOM.setUnDraggable(imgDOM);
87
-
88
- if (href) {
89
- var anchorDOM = _l7Utils.DOM.create('a', 'l7-control-logo-link');
90
-
91
- anchorDOM.target = '_blank';
92
- anchorDOM.href = href;
93
- anchorDOM.rel = 'noopener nofollow';
94
- anchorDOM.setAttribute('rel', 'noopener nofollow');
95
- anchorDOM.appendChild(imgDOM);
96
- container.appendChild(anchorDOM);
97
- } else {
98
- container.appendChild(imgDOM);
99
- }
100
- }
101
74
  }]);
102
75
  return Logo;
103
- }(_baseControl.Control);
76
+ }(_BaseControl.default);
104
77
 
105
- exports.default = exports.Logo = Logo;
78
+ exports.default = Logo;
@@ -2,12 +2,12 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
- exports.default = exports.Scale = void 0;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ exports.default = void 0;
11
11
 
12
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
13
 
@@ -15,19 +15,19 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
15
15
 
16
16
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
17
 
18
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
19
-
20
18
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
19
 
22
20
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
23
21
 
24
22
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
25
23
 
26
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
-
28
24
  var _l7Utils = require("@antv/l7-utils");
29
25
 
30
- var _baseControl = require("./baseControl");
26
+ var _BaseControl = _interopRequireWildcard(require("./BaseControl"));
27
+
28
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
+
30
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
31
 
32
32
  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); }; }
33
33
 
@@ -38,41 +38,26 @@ var Scale = /*#__PURE__*/function (_Control) {
38
38
 
39
39
  var _super = _createSuper(Scale);
40
40
 
41
- function Scale() {
41
+ function Scale(cfg) {
42
42
  var _this;
43
43
 
44
44
  (0, _classCallCheck2.default)(this, Scale);
45
-
46
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
47
- args[_key] = arguments[_key];
48
- }
49
-
50
- _this = _super.call.apply(_super, [this].concat(args));
51
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "update", function () {
52
- var mapsService = _this.mapsService;
53
- var maxWidth = _this.controlOption.maxWidth;
54
- var y = mapsService.getSize()[1] / 2;
55
- var p1 = mapsService.containerToLngLat([0, y]);
56
- var p2 = mapsService.containerToLngLat([maxWidth, y]);
57
- var maxMeters = (0, _l7Utils.lnglatDistance)([p1.lng, p1.lat], [p2.lng, p2.lat]);
58
-
59
- _this.updateScales(maxMeters);
60
- });
45
+ _this = _super.call(this, cfg);
46
+ (0, _l7Utils.bindAll)(['update'], (0, _assertThisInitialized2.default)(_this));
61
47
  return _this;
62
48
  }
63
49
 
64
50
  (0, _createClass2.default)(Scale, [{
65
51
  key: "getDefault",
66
- value: function getDefault(option) {
67
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(Scale.prototype), "getDefault", this).call(this, option)), {}, {
68
- name: 'scale',
69
- position: _baseControl.PositionType.BOTTOMLEFT,
52
+ value: function getDefault() {
53
+ return {
54
+ position: _BaseControl.PositionType.BOTTOMLEFT,
70
55
  maxWidth: 100,
71
56
  metric: true,
72
57
  updateWhenIdle: false,
73
58
  imperial: false,
74
- lockWidth: true
75
- });
59
+ name: 'scale'
60
+ };
76
61
  }
77
62
  }, {
78
63
  key: "onAdd",
@@ -81,10 +66,13 @@ var Scale = /*#__PURE__*/function (_Control) {
81
66
 
82
67
  var container = _l7Utils.DOM.create('div', className);
83
68
 
84
- this.resetScaleLines(container);
85
- var updateWhenIdle = this.controlOption.updateWhenIdle;
69
+ this.addScales(className + '-line', container);
70
+ var updateWhenIdle = this.controlOption.updateWhenIdle; // TODO: 高德地图和MapBox地图事件不一致问题
71
+ // 高德zoomchange
72
+
86
73
  this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
87
74
  this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
75
+ this.update();
88
76
  return container;
89
77
  }
90
78
  }, {
@@ -95,13 +83,15 @@ var Scale = /*#__PURE__*/function (_Control) {
95
83
  this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
96
84
  }
97
85
  }, {
98
- key: "setOptions",
99
- value: function setOptions(newOption) {
100
- (0, _get2.default)((0, _getPrototypeOf2.default)(Scale.prototype), "setOptions", this).call(this, newOption);
101
-
102
- if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
103
- this.resetScaleLines(this.container);
104
- }
86
+ key: "update",
87
+ value: function update() {
88
+ var mapsService = this.mapsService;
89
+ var maxWidth = this.controlOption.maxWidth;
90
+ var y = mapsService.getSize()[1] / 2;
91
+ var p1 = mapsService.containerToLngLat([0, y]);
92
+ var p2 = mapsService.containerToLngLat([maxWidth, y]);
93
+ var maxMeters = (0, _l7Utils.lnglatDistance)([p1.lng, p1.lat], [p2.lng, p2.lat]);
94
+ this.updateScales(maxMeters);
105
95
  }
106
96
  }, {
107
97
  key: "updateScales",
@@ -118,46 +108,6 @@ var Scale = /*#__PURE__*/function (_Control) {
118
108
  this.updateImperial(maxMeters);
119
109
  }
120
110
  }
121
- }, {
122
- key: "resetScaleLines",
123
- value: function resetScaleLines(container) {
124
- _l7Utils.DOM.clearChildren(container);
125
-
126
- var _this$controlOption2 = this.controlOption,
127
- metric = _this$controlOption2.metric,
128
- imperial = _this$controlOption2.imperial,
129
- maxWidth = _this$controlOption2.maxWidth,
130
- lockWidth = _this$controlOption2.lockWidth;
131
-
132
- if (lockWidth) {
133
- _l7Utils.DOM.addStyle(container, "width: ".concat(maxWidth, "px"));
134
- }
135
-
136
- if (metric) {
137
- this.mScale = _l7Utils.DOM.create('div', 'l7-control-scale-line', container);
138
- }
139
-
140
- if (imperial) {
141
- this.iScale = _l7Utils.DOM.create('div', 'l7-control-scale-line', container);
142
- }
143
-
144
- this.update();
145
- }
146
- }, {
147
- key: "updateScale",
148
- value: function updateScale(scale, text, ratio) {
149
- var maxWidth = this.controlOption.maxWidth;
150
- scale.style.width = Math.round(maxWidth * ratio) + 'px';
151
- scale.innerHTML = text;
152
- }
153
- }, {
154
- key: "getRoundNum",
155
- value: function getRoundNum(num) {
156
- var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
157
- var d = num / pow10;
158
- d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
159
- return pow10 * d;
160
- }
161
111
  }, {
162
112
  key: "updateMetric",
163
113
  value: function updateMetric(maxMeters) {
@@ -182,8 +132,38 @@ var Scale = /*#__PURE__*/function (_Control) {
182
132
  this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
183
133
  }
184
134
  }
135
+ }, {
136
+ key: "updateScale",
137
+ value: function updateScale(scale, text, ratio) {
138
+ var maxWidth = this.controlOption.maxWidth;
139
+ scale.style.width = Math.round(maxWidth * ratio) + 'px';
140
+ scale.innerHTML = text;
141
+ }
142
+ }, {
143
+ key: "getRoundNum",
144
+ value: function getRoundNum(num) {
145
+ var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
146
+ var d = num / pow10;
147
+ d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
148
+ return pow10 * d;
149
+ }
150
+ }, {
151
+ key: "addScales",
152
+ value: function addScales(className, container) {
153
+ var _this$controlOption2 = this.controlOption,
154
+ metric = _this$controlOption2.metric,
155
+ imperial = _this$controlOption2.imperial;
156
+
157
+ if (metric) {
158
+ this.mScale = _l7Utils.DOM.create('div', className, container);
159
+ }
160
+
161
+ if (imperial) {
162
+ this.iScale = _l7Utils.DOM.create('div', className, container);
163
+ }
164
+ }
185
165
  }]);
186
166
  return Scale;
187
- }(_baseControl.Control);
167
+ }(_BaseControl.default);
188
168
 
189
- exports.default = exports.Scale = Scale;
169
+ exports.default = Scale;