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