@antv/l7-component 2.17.3 → 2.17.4

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 (50) hide show
  1. package/es/assets/iconfont/iconfont.js +17 -10
  2. package/es/control/baseControl/buttonControl.js +42 -9
  3. package/es/control/baseControl/control.js +53 -24
  4. package/es/control/baseControl/index.d.ts +4 -4
  5. package/es/control/baseControl/index.js +4 -4
  6. package/es/control/baseControl/popperControl.js +24 -10
  7. package/es/control/baseControl/selectControl.js +45 -6
  8. package/es/control/exportImage.js +116 -76
  9. package/es/control/fullscreen.js +53 -20
  10. package/es/control/geoLocate.js +66 -36
  11. package/es/control/layerSwitch.js +31 -0
  12. package/es/control/logo.js +14 -2
  13. package/es/control/mapTheme.js +32 -7
  14. package/es/control/mouseLocation.js +23 -2
  15. package/es/control/scale.js +29 -6
  16. package/es/control/zoom.js +23 -0
  17. package/es/index.d.ts +11 -11
  18. package/es/index.js +23 -13
  19. package/es/marker-layer.js +75 -41
  20. package/es/marker.js +83 -29
  21. package/es/popup/layerPopup.js +82 -31
  22. package/es/popup/popup.js +127 -48
  23. package/es/utils/anchor.js +7 -3
  24. package/es/utils/popper.js +64 -15
  25. package/es/utils/screenfull.js +52 -23
  26. package/lib/assets/iconfont/iconfont.js +17 -10
  27. package/lib/control/baseControl/buttonControl.js +52 -9
  28. package/lib/control/baseControl/control.js +68 -24
  29. package/lib/control/baseControl/index.js +35 -41
  30. package/lib/control/baseControl/popperControl.js +29 -10
  31. package/lib/control/baseControl/selectControl.js +60 -6
  32. package/lib/control/exportImage.js +125 -76
  33. package/lib/control/fullscreen.js +60 -20
  34. package/lib/control/geoLocate.js +75 -36
  35. package/lib/control/layerSwitch.js +36 -0
  36. package/lib/control/logo.js +26 -2
  37. package/lib/control/mapTheme.js +42 -7
  38. package/lib/control/mouseLocation.js +33 -2
  39. package/lib/control/scale.js +40 -6
  40. package/lib/control/zoom.js +33 -0
  41. package/lib/index.js +108 -122
  42. package/lib/marker-layer.js +86 -39
  43. package/lib/marker.js +91 -29
  44. package/lib/popup/layerPopup.js +94 -29
  45. package/lib/popup/popup.js +139 -48
  46. package/lib/utils/anchor.js +9 -4
  47. package/lib/utils/icon.js +2 -0
  48. package/lib/utils/popper.js +71 -14
  49. package/lib/utils/screenfull.js +54 -23
  50. package/package.json +6 -6
@@ -5,8 +5,11 @@ import _get from "@babel/runtime/helpers/esm/get";
5
5
  import _inherits from "@babel/runtime/helpers/esm/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
+
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
+
9
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
+
10
13
  import { Popper } from "../../utils/popper";
11
14
  import ButtonControl from "./buttonControl";
12
15
  export { PopperControl };
@@ -24,13 +27,18 @@ var PopperPlacementMap = {
24
27
  rightcenter: 'left',
25
28
  rightbottom: 'top-end'
26
29
  };
30
+
27
31
  var PopperControl = /*#__PURE__*/function (_ButtonControl) {
28
32
  _inherits(PopperControl, _ButtonControl);
33
+
29
34
  var _super = _createSuper(PopperControl);
35
+
30
36
  function PopperControl() {
31
37
  _classCallCheck(this, PopperControl);
38
+
32
39
  return _super.apply(this, arguments);
33
40
  }
41
+
34
42
  _createClass(PopperControl, [{
35
43
  key: "getPopper",
36
44
  value:
@@ -38,7 +46,6 @@ var PopperControl = /*#__PURE__*/function (_ButtonControl) {
38
46
  * 气泡实例
39
47
  * @protected
40
48
  */
41
-
42
49
  function getPopper() {
43
50
  return this.popper;
44
51
  }
@@ -46,19 +53,22 @@ var PopperControl = /*#__PURE__*/function (_ButtonControl) {
46
53
  key: "hide",
47
54
  value: function hide() {
48
55
  this.popper.hide();
56
+
49
57
  _get(_getPrototypeOf(PopperControl.prototype), "hide", this).call(this);
50
58
  }
51
-
52
59
  /**
53
60
  * 获取默认配置
54
61
  * @param option
55
62
  */
63
+
56
64
  }, {
57
65
  key: "getDefault",
58
66
  value: function getDefault(option) {
59
67
  var _option$position;
60
- var defaultOption = _get(_getPrototypeOf(PopperControl.prototype), "getDefault", this).call(this, option);
61
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
68
+
69
+ var defaultOption = _get(_getPrototypeOf(PopperControl.prototype), "getDefault", this).call(this, option); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
70
+
71
+
62
72
  var position = (_option$position = option === null || option === void 0 ? void 0 : option.position) !== null && _option$position !== void 0 ? _option$position : defaultOption.position;
63
73
  return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(PopperControl.prototype), "getDefault", this).call(this, option)), {}, {
64
74
  popperPlacement: position instanceof Element ? 'bottom' : PopperPlacementMap[position],
@@ -69,6 +79,7 @@ var PopperControl = /*#__PURE__*/function (_ButtonControl) {
69
79
  key: "onAdd",
70
80
  value: function onAdd() {
71
81
  var button = _get(_getPrototypeOf(PopperControl.prototype), "onAdd", this).call(this);
82
+
72
83
  this.initPopper();
73
84
  return button;
74
85
  }
@@ -81,14 +92,14 @@ var PopperControl = /*#__PURE__*/function (_ButtonControl) {
81
92
  key: "initPopper",
82
93
  value: function initPopper() {
83
94
  var _this = this;
95
+
84
96
  var _this$controlOption = this.controlOption,
85
- popperClassName = _this$controlOption.popperClassName,
86
- popperPlacement = _this$controlOption.popperPlacement,
87
- popperTrigger = _this$controlOption.popperTrigger;
88
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
89
- var popperContainer = this.mapsService.getMapContainer();
97
+ popperClassName = _this$controlOption.popperClassName,
98
+ popperPlacement = _this$controlOption.popperPlacement,
99
+ popperTrigger = _this$controlOption.popperTrigger; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
100
+
101
+ var popperContainer = this.mapsService.getMapContainer(); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
90
102
 
91
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
92
103
  this.popper = new Popper(this.button, {
93
104
  className: popperClassName,
94
105
  placement: popperPlacement,
@@ -107,6 +118,7 @@ var PopperControl = /*#__PURE__*/function (_ButtonControl) {
107
118
  key: "setOptions",
108
119
  value: function setOptions(option) {
109
120
  _get(_getPrototypeOf(PopperControl.prototype), "setOptions", this).call(this, option);
121
+
110
122
  if (this.checkUpdateOption(option, ['popperPlacement', 'popperTrigger', 'popperClassName'])) {
111
123
  var content = this.popper.getContent();
112
124
  this.popper.destroy();
@@ -115,6 +127,8 @@ var PopperControl = /*#__PURE__*/function (_ButtonControl) {
115
127
  }
116
128
  }
117
129
  }]);
130
+
118
131
  return PopperControl;
119
132
  }(ButtonControl);
133
+
120
134
  export { PopperControl as default };
@@ -7,47 +7,65 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
+
10
11
  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); }; }
12
+
11
13
  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; } }
14
+
12
15
  import { DOM } from '@antv/l7-utils';
13
16
  import { PopperControl } from "./popperControl";
14
17
  export { SelectControl };
15
- var SelectControlConstant = /*#__PURE__*/function (SelectControlConstant) {
18
+ var SelectControlConstant;
19
+
20
+ (function (SelectControlConstant) {
16
21
  SelectControlConstant["ActiveOptionClassName"] = "l7-select-control-item-active";
17
22
  SelectControlConstant["OptionValueAttrKey"] = "data-option-value";
18
23
  SelectControlConstant["OptionIndexAttrKey"] = "data-option-index";
19
- return SelectControlConstant;
20
- }(SelectControlConstant || {});
24
+ })(SelectControlConstant || (SelectControlConstant = {}));
25
+
21
26
  var SelectControl = /*#__PURE__*/function (_PopperControl) {
22
27
  _inherits(SelectControl, _PopperControl);
28
+
23
29
  var _super = _createSuper(SelectControl);
30
+
24
31
  function SelectControl() {
25
32
  var _this;
33
+
26
34
  _classCallCheck(this, SelectControl);
35
+
27
36
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28
37
  args[_key] = arguments[_key];
29
38
  }
39
+
30
40
  _this = _super.call.apply(_super, [this].concat(args));
41
+
31
42
  _defineProperty(_assertThisInitialized(_this), "selectValue", []);
43
+
32
44
  _defineProperty(_assertThisInitialized(_this), "createNormalOption", function (option) {
33
45
  var isSelect = _this.selectValue.includes(option.value);
46
+
34
47
  var optionDOM = DOM.create('div', "l7-select-control-item ".concat(isSelect ? SelectControlConstant.ActiveOptionClassName : ''));
48
+
35
49
  if (_this.getIsMultiple()) {
36
50
  optionDOM.appendChild(_this.createCheckbox(isSelect));
37
51
  }
52
+
38
53
  if (option.icon) {
39
54
  optionDOM.appendChild(option.icon);
40
55
  }
56
+
41
57
  var textDOM = DOM.create('span');
42
58
  textDOM.innerText = option.text;
43
59
  optionDOM.appendChild(textDOM);
44
60
  return optionDOM;
45
61
  });
62
+
46
63
  _defineProperty(_assertThisInitialized(_this), "onItemClick", function (item) {
47
64
  if (_this.getIsMultiple()) {
48
65
  var targetIndex = _this.selectValue.findIndex(function (value) {
49
66
  return value === item.value;
50
67
  });
68
+
51
69
  if (targetIndex > -1) {
52
70
  _this.selectValue.splice(targetIndex, 1);
53
71
  } else {
@@ -56,15 +74,20 @@ var SelectControl = /*#__PURE__*/function (_PopperControl) {
56
74
  } else {
57
75
  _this.selectValue = [item.value];
58
76
  }
77
+
59
78
  _this.setSelectValue(_this.selectValue);
60
79
  });
80
+
61
81
  return _this;
62
82
  }
83
+
63
84
  _createClass(SelectControl, [{
64
85
  key: "setOptions",
65
86
  value: function setOptions(option) {
66
87
  _get(_getPrototypeOf(SelectControl.prototype), "setOptions", this).call(this, option);
88
+
67
89
  var options = option.options;
90
+
68
91
  if (options) {
69
92
  this.popper.setContent(this.getPopperContent(options));
70
93
  }
@@ -73,10 +96,13 @@ var SelectControl = /*#__PURE__*/function (_PopperControl) {
73
96
  key: "onAdd",
74
97
  value: function onAdd() {
75
98
  var button = _get(_getPrototypeOf(SelectControl.prototype), "onAdd", this).call(this);
99
+
76
100
  var defaultValue = this.controlOption.defaultValue;
101
+
77
102
  if (defaultValue) {
78
103
  this.selectValue = this.transSelectValue(defaultValue);
79
104
  }
105
+
80
106
  this.popper.setContent(this.getPopperContent(this.controlOption.options));
81
107
  return button;
82
108
  }
@@ -89,20 +115,24 @@ var SelectControl = /*#__PURE__*/function (_PopperControl) {
89
115
  key: "setSelectValue",
90
116
  value: function setSelectValue(value) {
91
117
  var _this2 = this;
118
+
92
119
  var emitEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
93
120
  var finalValue = this.transSelectValue(value);
94
121
  this.optionDOMList.forEach(function (optionDOM) {
95
122
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
96
123
  var optionValue = optionDOM.getAttribute(SelectControlConstant.OptionValueAttrKey);
97
124
  var checkboxDOM = _this2.getIsMultiple() ? optionDOM.querySelector('input[type=checkbox]') : undefined;
125
+
98
126
  if (finalValue.includes(optionValue)) {
99
127
  DOM.addClass(optionDOM, SelectControlConstant.ActiveOptionClassName);
128
+
100
129
  if (checkboxDOM) {
101
130
  // @ts-ignore
102
131
  DOM.setChecked(checkboxDOM, true);
103
132
  }
104
133
  } else {
105
134
  DOM.removeClass(optionDOM, SelectControlConstant.ActiveOptionClassName);
135
+
106
136
  if (checkboxDOM) {
107
137
  // @ts-ignore
108
138
  DOM.setChecked(checkboxDOM, false);
@@ -110,15 +140,16 @@ var SelectControl = /*#__PURE__*/function (_PopperControl) {
110
140
  }
111
141
  });
112
142
  this.selectValue = finalValue;
143
+
113
144
  if (emitEvent) {
114
145
  this.emit('selectChange', this.getIsMultiple() ? finalValue : finalValue[0]);
115
146
  }
116
147
  }
117
-
118
148
  /**
119
149
  * 是否为多选
120
150
  * @protected
121
151
  */
152
+
122
153
  }, {
123
154
  key: "getIsMultiple",
124
155
  value: function getIsMultiple() {
@@ -128,14 +159,16 @@ var SelectControl = /*#__PURE__*/function (_PopperControl) {
128
159
  key: "getPopperContent",
129
160
  value: function getPopperContent(options) {
130
161
  var _this3 = this;
162
+
131
163
  var isImageOptions = this.isImageOptions();
132
164
  var content = DOM.create('div', isImageOptions ? 'l7-select-control--image' : 'l7-select-control--normal');
165
+
133
166
  if (this.getIsMultiple()) {
134
167
  DOM.addClass(content, 'l7-select-control--multiple');
135
168
  }
169
+
136
170
  var optionsDOMList = options.map(function (option, optionIndex) {
137
- var optionDOM = isImageOptions ?
138
- // @ts-ignore
171
+ var optionDOM = isImageOptions ? // @ts-ignore
139
172
  _this3.createImageOption(option) : _this3.createNormalOption(option);
140
173
  optionDOM.setAttribute(SelectControlConstant.OptionValueAttrKey, option.value);
141
174
  optionDOM.setAttribute(SelectControlConstant.OptionIndexAttrKey, window.String(optionIndex));
@@ -156,9 +189,11 @@ var SelectControl = /*#__PURE__*/function (_PopperControl) {
156
189
  DOM.setUnDraggable(imgDOM);
157
190
  optionDOM.appendChild(imgDOM);
158
191
  var rowDOM = DOM.create('div', 'l7-select-control-item-row');
192
+
159
193
  if (this.getIsMultiple()) {
160
194
  optionDOM.appendChild(this.createCheckbox(isSelect));
161
195
  }
196
+
162
197
  var textDOM = DOM.create('span');
163
198
  textDOM.innerText = option.text;
164
199
  rowDOM.appendChild(textDOM);
@@ -170,9 +205,11 @@ var SelectControl = /*#__PURE__*/function (_PopperControl) {
170
205
  value: function createCheckbox(isSelect) {
171
206
  var checkboxDOM = DOM.create('input');
172
207
  checkboxDOM.setAttribute('type', 'checkbox');
208
+
173
209
  if (isSelect) {
174
210
  DOM.setChecked(checkboxDOM, true);
175
211
  }
212
+
176
213
  return checkboxDOM;
177
214
  }
178
215
  }, {
@@ -189,6 +226,8 @@ var SelectControl = /*#__PURE__*/function (_PopperControl) {
189
226
  return Array.isArray(value) ? value : [value];
190
227
  }
191
228
  }]);
229
+
192
230
  return SelectControl;
193
231
  }(PopperControl);
232
+
194
233
  export { SelectControl as default };
@@ -10,102 +10,133 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
10
10
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
11
11
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
12
12
  import _regeneratorRuntime from "@babel/runtime/regenerator";
13
+
13
14
  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); }; }
15
+
14
16
  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; } }
17
+
15
18
  import { createL7Icon } from "../utils/icon";
16
19
  import ButtonControl from "./baseControl/buttonControl";
17
20
  export { ExportImage };
21
+
18
22
  var ExportImage = /*#__PURE__*/function (_ButtonControl) {
19
23
  _inherits(ExportImage, _ButtonControl);
24
+
20
25
  var _super = _createSuper(ExportImage);
26
+
21
27
  function ExportImage() {
22
28
  var _this;
29
+
23
30
  _classCallCheck(this, ExportImage);
31
+
24
32
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
25
33
  args[_key] = arguments[_key];
26
34
  }
35
+
27
36
  _this = _super.call.apply(_super, [this].concat(args));
37
+
28
38
  _defineProperty(_assertThisInitialized(_this), "onClick", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
29
39
  var onExport;
30
40
  return _regeneratorRuntime.wrap(function _callee$(_context) {
31
- while (1) switch (_context.prev = _context.next) {
32
- case 0:
33
- onExport = _this.controlOption.onExport;
34
- if (!(onExport === null || onExport === void 0)) {
35
- _context.next = 5;
41
+ while (1) {
42
+ switch (_context.prev = _context.next) {
43
+ case 0:
44
+ onExport = _this.controlOption.onExport;
45
+
46
+ if (!(onExport === null || onExport === void 0)) {
47
+ _context.next = 5;
48
+ break;
49
+ }
50
+
51
+ void 0;
52
+ _context.next = 10;
36
53
  break;
37
- }
38
- void 0;
39
- _context.next = 10;
40
- break;
41
- case 5:
42
- _context.t0 = onExport;
43
- _context.next = 8;
44
- return _this.getImage();
45
- case 8:
46
- _context.t1 = _context.sent;
47
- (0, _context.t0)(_context.t1);
48
- case 10:
49
- case "end":
50
- return _context.stop();
54
+
55
+ case 5:
56
+ _context.t0 = onExport;
57
+ _context.next = 8;
58
+ return _this.getImage();
59
+
60
+ case 8:
61
+ _context.t1 = _context.sent;
62
+ (0, _context.t0)(_context.t1);
63
+
64
+ case 10:
65
+ case "end":
66
+ return _context.stop();
67
+ }
51
68
  }
52
69
  }, _callee);
53
70
  })));
71
+
54
72
  _defineProperty(_assertThisInitialized(_this), "mergeImage", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
55
73
  var _this$mapsService$get, _this$mapsService$get2;
74
+
56
75
  var imageType,
57
- _ref3,
58
- _ref3$width,
59
- width,
60
- _ref3$height,
61
- height,
62
- canvas,
63
- context,
64
- _len2,
65
- base64List,
66
- _key2,
67
- imgList,
68
- _args2 = arguments;
76
+ _ref3,
77
+ _ref3$width,
78
+ width,
79
+ _ref3$height,
80
+ height,
81
+ canvas,
82
+ context,
83
+ _len2,
84
+ base64List,
85
+ _key2,
86
+ imgList,
87
+ _args2 = arguments;
88
+
69
89
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
70
- while (1) switch (_context2.prev = _context2.next) {
71
- case 0:
72
- imageType = _this.controlOption.imageType;
73
- _ref3 = (_this$mapsService$get = (_this$mapsService$get2 = _this.mapsService.getContainer()) === null || _this$mapsService$get2 === void 0 ? void 0 : _this$mapsService$get2.getBoundingClientRect()) !== null && _this$mapsService$get !== void 0 ? _this$mapsService$get : {}, _ref3$width = _ref3.width, width = _ref3$width === void 0 ? 0 : _ref3$width, _ref3$height = _ref3.height, height = _ref3$height === void 0 ? 0 : _ref3$height;
74
- canvas = document.createElement('canvas');
75
- canvas.width = width;
76
- canvas.height = height;
77
- context = canvas.getContext('2d');
78
- for (_len2 = _args2.length, base64List = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
79
- base64List[_key2] = _args2[_key2];
80
- }
81
- _context2.next = 9;
82
- return Promise.all(base64List.map(function (base64) {
83
- return new Promise(function (resolve) {
84
- var img = new Image();
85
- img.onload = function () {
86
- resolve(img);
87
- };
88
- img.src = base64;
90
+ while (1) {
91
+ switch (_context2.prev = _context2.next) {
92
+ case 0:
93
+ imageType = _this.controlOption.imageType;
94
+ _ref3 = (_this$mapsService$get = (_this$mapsService$get2 = _this.mapsService.getContainer()) === null || _this$mapsService$get2 === void 0 ? void 0 : _this$mapsService$get2.getBoundingClientRect()) !== null && _this$mapsService$get !== void 0 ? _this$mapsService$get : {}, _ref3$width = _ref3.width, width = _ref3$width === void 0 ? 0 : _ref3$width, _ref3$height = _ref3.height, height = _ref3$height === void 0 ? 0 : _ref3$height;
95
+ canvas = document.createElement('canvas');
96
+ canvas.width = width;
97
+ canvas.height = height;
98
+ context = canvas.getContext('2d');
99
+
100
+ for (_len2 = _args2.length, base64List = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
101
+ base64List[_key2] = _args2[_key2];
102
+ }
103
+
104
+ _context2.next = 9;
105
+ return Promise.all(base64List.map(function (base64) {
106
+ return new Promise(function (resolve) {
107
+ var img = new Image();
108
+
109
+ img.onload = function () {
110
+ resolve(img);
111
+ };
112
+
113
+ img.src = base64;
114
+ });
115
+ }));
116
+
117
+ case 9:
118
+ imgList = _context2.sent;
119
+ imgList.forEach(function (img) {
120
+ context === null || context === void 0 ? void 0 : context.drawImage(img, 0, 0, width, height);
89
121
  });
90
- }));
91
- case 9:
92
- imgList = _context2.sent;
93
- imgList.forEach(function (img) {
94
- context === null || context === void 0 ? void 0 : context.drawImage(img, 0, 0, width, height);
95
- });
96
- return _context2.abrupt("return", canvas.toDataURL("image/".concat(imageType)));
97
- case 12:
98
- case "end":
99
- return _context2.stop();
122
+ return _context2.abrupt("return", canvas.toDataURL("image/".concat(imageType)));
123
+
124
+ case 12:
125
+ case "end":
126
+ return _context2.stop();
127
+ }
100
128
  }
101
129
  }, _callee2);
102
130
  })));
131
+
103
132
  return _this;
104
133
  }
134
+
105
135
  _createClass(ExportImage, [{
106
136
  key: "onAdd",
107
137
  value: function onAdd() {
108
138
  var button = _get(_getPrototypeOf(ExportImage.prototype), "onAdd", this).call(this);
139
+
109
140
  button.addEventListener('click', this.onClick);
110
141
  return button;
111
142
  }
@@ -124,31 +155,40 @@ var ExportImage = /*#__PURE__*/function (_ButtonControl) {
124
155
  var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
125
156
  var mapImage, layerImage;
126
157
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
127
- while (1) switch (_context3.prev = _context3.next) {
128
- case 0:
129
- _context3.next = 2;
130
- return this.mapsService.exportMap('png');
131
- case 2:
132
- mapImage = _context3.sent;
133
- _context3.next = 5;
134
- return this.scene.exportPng('png');
135
- case 5:
136
- layerImage = _context3.sent;
137
- return _context3.abrupt("return", this.mergeImage.apply(this, _toConsumableArray([mapImage, layerImage].filter(function (base64) {
138
- return base64;
139
- }))));
140
- case 7:
141
- case "end":
142
- return _context3.stop();
158
+ while (1) {
159
+ switch (_context3.prev = _context3.next) {
160
+ case 0:
161
+ _context3.next = 2;
162
+ return this.mapsService.exportMap('png');
163
+
164
+ case 2:
165
+ mapImage = _context3.sent;
166
+ _context3.next = 5;
167
+ return this.scene.exportPng('png');
168
+
169
+ case 5:
170
+ layerImage = _context3.sent;
171
+ return _context3.abrupt("return", this.mergeImage.apply(this, _toConsumableArray([mapImage, layerImage].filter(function (base64) {
172
+ return base64;
173
+ }))));
174
+
175
+ case 7:
176
+ case "end":
177
+ return _context3.stop();
178
+ }
143
179
  }
144
180
  }, _callee3, this);
145
181
  }));
182
+
146
183
  function getImage() {
147
184
  return _getImage.apply(this, arguments);
148
185
  }
186
+
149
187
  return getImage;
150
188
  }()
151
189
  }]);
190
+
152
191
  return ExportImage;
153
192
  }(ButtonControl);
193
+
154
194
  export { ExportImage as default };