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