@antv/l7-component 2.18.2 → 2.19.0
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 +46 -0
- package/es/constants/index.d.ts +60 -0
- package/es/constants/index.js +60 -0
- package/es/control/baseControl/buttonControl.d.ts +59 -0
- package/es/control/baseControl/buttonControl.js +177 -0
- package/es/control/baseControl/control.d.ts +112 -0
- package/es/control/baseControl/control.js +302 -0
- package/es/control/baseControl/index.d.ts +4 -0
- package/es/control/baseControl/index.js +4 -0
- package/es/control/baseControl/popperControl.d.ts +26 -0
- package/es/control/baseControl/popperControl.js +120 -0
- package/es/control/baseControl/selectControl.d.ts +46 -0
- package/es/control/baseControl/selectControl.js +204 -0
- package/es/control/exportImage.d.ts +18 -0
- package/es/control/exportImage.js +159 -0
- package/es/control/fullscreen.d.ts +19 -0
- package/es/control/fullscreen.js +119 -0
- package/es/control/geoLocate.d.ts +16 -0
- package/es/control/geoLocate.js +107 -0
- package/es/control/layerSwitch.d.ts +19 -0
- package/es/control/layerSwitch.js +141 -0
- package/es/control/logo.d.ts +13 -0
- package/es/control/logo.js +75 -0
- package/es/control/mapTheme.d.ts +10 -0
- package/es/control/mapTheme.js +110 -0
- package/es/control/mouseLocation.d.ts +15 -0
- package/es/control/mouseLocation.js +83 -0
- package/es/control/scale.d.ts +34 -0
- package/es/control/scale.js +149 -0
- package/es/control/zoom.d.ts +38 -0
- package/es/control/zoom.js +132 -0
- package/es/css/button.less +70 -0
- package/es/css/control.less +71 -0
- package/es/css/index.css +594 -0
- package/es/css/index.less +12 -0
- package/es/css/l7.less +62 -0
- package/es/css/layerPopup.less +8 -0
- package/es/css/logo.less +18 -0
- package/es/css/mouseLocation.less +9 -0
- package/es/css/popper.less +64 -0
- package/es/css/popup.less +185 -0
- package/es/css/scale.less +34 -0
- package/es/css/select.less +86 -0
- package/es/css/variables.less +30 -0
- package/es/css/zoom.less +29 -0
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +1 -0
- package/es/images/logo.png +0 -0
- package/es/images/quanping.svg +12 -0
- package/es/index.d.ts +18 -0
- package/es/index.js +49 -0
- package/es/interface.d.ts +18 -0
- package/es/interface.js +1 -0
- package/es/marker-layer.d.ts +54 -0
- package/es/marker-layer.js +343 -0
- package/es/marker.d.ts +55 -0
- package/es/marker.js +410 -0
- package/es/popup/layerPopup.d.ts +95 -0
- package/es/popup/layerPopup.js +343 -0
- package/es/popup/popup.d.ts +139 -0
- package/es/popup/popup.js +575 -0
- package/es/utils/anchor.d.ts +22 -0
- package/es/utils/anchor.js +31 -0
- package/es/utils/icon.d.ts +1 -0
- package/es/utils/icon.js +9 -0
- package/es/utils/popper.d.ts +76 -0
- package/es/utils/popper.js +266 -0
- package/es/utils/screenfull.d.ts +2 -0
- package/es/utils/screenfull.js +128 -0
- package/lib/assets/iconfont/iconfont.js +48 -0
- package/lib/constants/index.js +68 -0
- package/lib/control/baseControl/buttonControl.js +183 -0
- package/lib/control/baseControl/control.js +314 -0
- package/lib/control/baseControl/index.js +39 -0
- package/lib/control/baseControl/popperControl.js +126 -0
- package/lib/control/baseControl/selectControl.js +210 -0
- package/lib/control/exportImage.js +165 -0
- package/lib/control/fullscreen.js +125 -0
- package/lib/control/geoLocate.js +113 -0
- package/lib/control/layerSwitch.js +147 -0
- package/lib/control/logo.js +81 -0
- package/lib/control/mapTheme.js +116 -0
- package/lib/control/mouseLocation.js +89 -0
- package/lib/control/scale.js +155 -0
- package/lib/control/zoom.js +138 -0
- package/lib/css/button.less +70 -0
- package/lib/css/control.less +71 -0
- package/lib/css/index.css +594 -0
- package/lib/css/index.less +12 -0
- package/lib/css/l7.less +62 -0
- package/lib/css/layerPopup.less +8 -0
- package/lib/css/logo.less +18 -0
- package/lib/css/mouseLocation.less +9 -0
- package/lib/css/popper.less +64 -0
- package/lib/css/popup.less +185 -0
- package/lib/css/scale.less +34 -0
- package/lib/css/select.less +86 -0
- package/lib/css/variables.less +30 -0
- package/lib/css/zoom.less +29 -0
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +1 -0
- package/lib/images/logo.png +0 -0
- package/lib/images/quanping.svg +12 -0
- package/lib/index.js +169 -0
- package/lib/interface.js +5 -0
- package/lib/marker-layer.js +349 -0
- package/lib/marker.js +417 -0
- package/lib/popup/layerPopup.js +349 -0
- package/lib/popup/popup.js +581 -0
- package/lib/utils/anchor.js +40 -0
- package/lib/utils/icon.js +16 -0
- package/lib/utils/popper.js +270 -0
- package/lib/utils/screenfull.js +136 -0
- package/package.json +6 -6
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.ButtonControl = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
17
|
+
var _control = _interopRequireDefault(require("./control"));
|
|
18
|
+
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); }; }
|
|
19
|
+
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; } }
|
|
20
|
+
var ButtonControl = /*#__PURE__*/function (_Control) {
|
|
21
|
+
(0, _inherits2.default)(ButtonControl, _Control);
|
|
22
|
+
var _super = _createSuper(ButtonControl);
|
|
23
|
+
function ButtonControl() {
|
|
24
|
+
var _this;
|
|
25
|
+
(0, _classCallCheck2.default)(this, ButtonControl);
|
|
26
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
27
|
+
args[_key] = arguments[_key];
|
|
28
|
+
}
|
|
29
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
30
|
+
/**
|
|
31
|
+
* 当前按钮是否禁用
|
|
32
|
+
* @protected
|
|
33
|
+
*/
|
|
34
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isDisable", false);
|
|
35
|
+
return _this;
|
|
36
|
+
}
|
|
37
|
+
(0, _createClass2.default)(ButtonControl, [{
|
|
38
|
+
key: "setIsDisable",
|
|
39
|
+
value:
|
|
40
|
+
/**
|
|
41
|
+
* 按钮的 DOM
|
|
42
|
+
* @protected
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 按钮中文本对应的 DOM
|
|
47
|
+
* @protected
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 按钮中图标对应的 DOM
|
|
52
|
+
* @protected
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 设置当前按钮
|
|
57
|
+
* @param newIsDisable
|
|
58
|
+
*/
|
|
59
|
+
function setIsDisable(newIsDisable) {
|
|
60
|
+
this.isDisable = newIsDisable;
|
|
61
|
+
if (newIsDisable) {
|
|
62
|
+
var _this$button;
|
|
63
|
+
(_this$button = this.button) === null || _this$button === void 0 ? void 0 : _this$button.setAttribute('disabled', 'true');
|
|
64
|
+
} else {
|
|
65
|
+
var _this$button2;
|
|
66
|
+
(_this$button2 = this.button) === null || _this$button2 === void 0 ? void 0 : _this$button2.removeAttribute('disabled');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "createButton",
|
|
71
|
+
value: function createButton() {
|
|
72
|
+
var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
73
|
+
return _l7Utils.DOM.create('button', "l7-button-control ".concat(className));
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "onAdd",
|
|
77
|
+
value: function onAdd() {
|
|
78
|
+
this.button = this.createButton();
|
|
79
|
+
this.isDisable = false;
|
|
80
|
+
var _this$controlOption = this.controlOption,
|
|
81
|
+
title = _this$controlOption.title,
|
|
82
|
+
btnText = _this$controlOption.btnText,
|
|
83
|
+
btnIcon = _this$controlOption.btnIcon;
|
|
84
|
+
this.setBtnTitle(title);
|
|
85
|
+
this.setBtnText(btnText);
|
|
86
|
+
this.setBtnIcon(btnIcon);
|
|
87
|
+
return this.button;
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "onRemove",
|
|
91
|
+
value: function onRemove() {
|
|
92
|
+
this.button = this.buttonIcon = this.buttonText = undefined;
|
|
93
|
+
this.isDisable = false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 更新配置方法
|
|
98
|
+
* @param newOptions
|
|
99
|
+
*/
|
|
100
|
+
}, {
|
|
101
|
+
key: "setOptions",
|
|
102
|
+
value: function setOptions(newOptions) {
|
|
103
|
+
var title = newOptions.title,
|
|
104
|
+
btnText = newOptions.btnText,
|
|
105
|
+
btnIcon = newOptions.btnIcon;
|
|
106
|
+
if (this.checkUpdateOption(newOptions, ['title'])) {
|
|
107
|
+
this.setBtnTitle(title);
|
|
108
|
+
}
|
|
109
|
+
if (this.checkUpdateOption(newOptions, ['btnIcon'])) {
|
|
110
|
+
this.setBtnIcon(btnIcon);
|
|
111
|
+
}
|
|
112
|
+
if (this.checkUpdateOption(newOptions, ['btnText'])) {
|
|
113
|
+
this.setBtnText(btnText);
|
|
114
|
+
}
|
|
115
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(ButtonControl.prototype), "setOptions", this).call(this, newOptions);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 设置按钮 title
|
|
120
|
+
* @param title
|
|
121
|
+
*/
|
|
122
|
+
}, {
|
|
123
|
+
key: "setBtnTitle",
|
|
124
|
+
value: function setBtnTitle(title) {
|
|
125
|
+
var _this$button3;
|
|
126
|
+
(_this$button3 = this.button) === null || _this$button3 === void 0 ? void 0 : _this$button3.setAttribute('title', title !== null && title !== void 0 ? title : '');
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 设置按钮 Icon
|
|
131
|
+
* @param newIcon
|
|
132
|
+
*/
|
|
133
|
+
}, {
|
|
134
|
+
key: "setBtnIcon",
|
|
135
|
+
value: function setBtnIcon(newIcon) {
|
|
136
|
+
if (this.buttonIcon) {
|
|
137
|
+
_l7Utils.DOM.remove(this.buttonIcon);
|
|
138
|
+
}
|
|
139
|
+
if (newIcon) {
|
|
140
|
+
var _this$button4;
|
|
141
|
+
var firstChild = (_this$button4 = this.button) === null || _this$button4 === void 0 ? void 0 : _this$button4.firstChild;
|
|
142
|
+
if (firstChild) {
|
|
143
|
+
var _this$button5;
|
|
144
|
+
(_this$button5 = this.button) === null || _this$button5 === void 0 ? void 0 : _this$button5.insertBefore(newIcon, firstChild);
|
|
145
|
+
} else {
|
|
146
|
+
var _this$button6;
|
|
147
|
+
(_this$button6 = this.button) === null || _this$button6 === void 0 ? void 0 : _this$button6.appendChild(newIcon);
|
|
148
|
+
}
|
|
149
|
+
this.buttonIcon = newIcon;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 设置按钮文本
|
|
155
|
+
* @param newText
|
|
156
|
+
*/
|
|
157
|
+
}, {
|
|
158
|
+
key: "setBtnText",
|
|
159
|
+
value: function setBtnText(newText) {
|
|
160
|
+
if (!this.button) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
_l7Utils.DOM.removeClass(this.button, 'l7-button-control--row');
|
|
164
|
+
_l7Utils.DOM.removeClass(this.button, 'l7-button-control--column');
|
|
165
|
+
if (newText) {
|
|
166
|
+
var btnText = this.buttonText;
|
|
167
|
+
if (!btnText) {
|
|
168
|
+
var _this$button7;
|
|
169
|
+
btnText = _l7Utils.DOM.create('div', 'l7-button-control__text');
|
|
170
|
+
(_this$button7 = this.button) === null || _this$button7 === void 0 ? void 0 : _this$button7.appendChild(btnText);
|
|
171
|
+
this.buttonText = btnText;
|
|
172
|
+
}
|
|
173
|
+
btnText.innerText = newText;
|
|
174
|
+
_l7Utils.DOM.addClass(this.button, this.controlOption.vertical ? 'l7-button-control--column' : 'l7-button-control--row');
|
|
175
|
+
} else if (!newText && this.buttonText) {
|
|
176
|
+
_l7Utils.DOM.remove(this.buttonText);
|
|
177
|
+
this.buttonText = undefined;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}]);
|
|
181
|
+
return ButtonControl;
|
|
182
|
+
}(_control.default);
|
|
183
|
+
exports.default = exports.ButtonControl = ButtonControl;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.Control = void 0;
|
|
8
|
+
Object.defineProperty(exports, "PositionType", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _l7Core.PositionType;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
exports.default = void 0;
|
|
15
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
16
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
17
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
var _l7Core = require("@antv/l7-core");
|
|
24
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
25
|
+
var _eventemitter = _interopRequireDefault(require("eventemitter3"));
|
|
26
|
+
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
|
+
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; } }
|
|
28
|
+
var Control = /*#__PURE__*/function (_ref) {
|
|
29
|
+
(0, _inherits2.default)(Control, _ref);
|
|
30
|
+
var _super = _createSuper(Control);
|
|
31
|
+
/**
|
|
32
|
+
* 当前控件实例配置
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 控件的 DOM 容器
|
|
37
|
+
* @protected
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 当前控件是否显示
|
|
42
|
+
* @protected
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
function Control(option) {
|
|
46
|
+
var _this;
|
|
47
|
+
(0, _classCallCheck2.default)(this, Control);
|
|
48
|
+
_this = _super.call(this);
|
|
49
|
+
Control.controlCount++;
|
|
50
|
+
_this.controlOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _this.getDefault(option)), option || {});
|
|
51
|
+
return _this;
|
|
52
|
+
}
|
|
53
|
+
(0, _createClass2.default)(Control, [{
|
|
54
|
+
key: "getOptions",
|
|
55
|
+
value: function getOptions() {
|
|
56
|
+
return this.controlOption;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 更新配置的方法,子类如果有自己的配置,也需要重写该方法
|
|
61
|
+
* @param newOptions
|
|
62
|
+
*/
|
|
63
|
+
}, {
|
|
64
|
+
key: "setOptions",
|
|
65
|
+
value: function setOptions(newOptions) {
|
|
66
|
+
var defaultOptions = this.getDefault(newOptions);
|
|
67
|
+
Object.entries(newOptions).forEach(function (_ref2) {
|
|
68
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
69
|
+
key = _ref3[0],
|
|
70
|
+
value = _ref3[1];
|
|
71
|
+
if (value === undefined) {
|
|
72
|
+
newOptions[key] = defaultOptions[key];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
if ('position' in newOptions) {
|
|
76
|
+
this.setPosition(newOptions.position);
|
|
77
|
+
}
|
|
78
|
+
if ('className' in newOptions) {
|
|
79
|
+
this.setClassName(newOptions.className);
|
|
80
|
+
}
|
|
81
|
+
if ('style' in newOptions) {
|
|
82
|
+
this.setStyle(newOptions.style);
|
|
83
|
+
}
|
|
84
|
+
this.controlOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.controlOption), newOptions);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 当 Control 被添加至 Scene 中,被 controlService 调用的方法
|
|
89
|
+
* @param sceneContainer
|
|
90
|
+
*/
|
|
91
|
+
}, {
|
|
92
|
+
key: "addTo",
|
|
93
|
+
value: function addTo(sceneContainer) {
|
|
94
|
+
// 初始化各个 Service 实例
|
|
95
|
+
this.mapsService = sceneContainer.get(_l7Core.TYPES.IMapService);
|
|
96
|
+
this.renderService = sceneContainer.get(_l7Core.TYPES.IRendererService);
|
|
97
|
+
this.layerService = sceneContainer.get(_l7Core.TYPES.ILayerService);
|
|
98
|
+
this.controlService = sceneContainer.get(_l7Core.TYPES.IControlService);
|
|
99
|
+
this.configService = sceneContainer.get(_l7Core.TYPES.IGlobalConfigService);
|
|
100
|
+
this.scene = sceneContainer.get(_l7Core.TYPES.ISceneService);
|
|
101
|
+
this.sceneContainer = sceneContainer;
|
|
102
|
+
this.isShow = true;
|
|
103
|
+
|
|
104
|
+
// 初始化 container
|
|
105
|
+
this.container = this.onAdd();
|
|
106
|
+
_l7Utils.DOM.addClass(this.container, 'l7-control');
|
|
107
|
+
var _this$controlOption = this.controlOption,
|
|
108
|
+
className = _this$controlOption.className,
|
|
109
|
+
style = _this$controlOption.style;
|
|
110
|
+
if (className) {
|
|
111
|
+
this.setClassName(className);
|
|
112
|
+
}
|
|
113
|
+
if (style) {
|
|
114
|
+
this.setStyle(style);
|
|
115
|
+
}
|
|
116
|
+
// 将 container 插入容器中
|
|
117
|
+
this.insertContainer();
|
|
118
|
+
this.emit('add', this);
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 将控件移除时触发
|
|
124
|
+
*/
|
|
125
|
+
}, {
|
|
126
|
+
key: "remove",
|
|
127
|
+
value: function remove() {
|
|
128
|
+
if (!this.mapsService) {
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
_l7Utils.DOM.remove(this.container);
|
|
132
|
+
this.onRemove();
|
|
133
|
+
this.emit('remove', this);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Control 被添加的时候被调用,返回 Control 对应的 DOM 容器
|
|
138
|
+
*/
|
|
139
|
+
}, {
|
|
140
|
+
key: "onAdd",
|
|
141
|
+
value: function onAdd() {
|
|
142
|
+
return _l7Utils.DOM.create('div');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Control 被移除时调用
|
|
147
|
+
*/
|
|
148
|
+
// tslint:disable-next-line:no-empty
|
|
149
|
+
}, {
|
|
150
|
+
key: "onRemove",
|
|
151
|
+
value: function onRemove() {}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 显示控件时触发
|
|
155
|
+
*/
|
|
156
|
+
}, {
|
|
157
|
+
key: "show",
|
|
158
|
+
value: function show() {
|
|
159
|
+
var container = this.container;
|
|
160
|
+
_l7Utils.DOM.removeClass(container, 'l7-control--hide');
|
|
161
|
+
this.isShow = true;
|
|
162
|
+
this.emit('show', this);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 隐藏控件时触发
|
|
167
|
+
*/
|
|
168
|
+
}, {
|
|
169
|
+
key: "hide",
|
|
170
|
+
value: function hide() {
|
|
171
|
+
var container = this.container;
|
|
172
|
+
_l7Utils.DOM.addClass(container, 'l7-control--hide');
|
|
173
|
+
this.isShow = false;
|
|
174
|
+
this.emit('hide', this);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 获取默认构造器参数
|
|
179
|
+
*/
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
181
|
+
}, {
|
|
182
|
+
key: "getDefault",
|
|
183
|
+
value: function getDefault(option) {
|
|
184
|
+
// tslint:disable-next-line:no-object-literal-type-assertion
|
|
185
|
+
return {
|
|
186
|
+
position: _l7Core.PositionType.TOPRIGHT,
|
|
187
|
+
name: "".concat(Control.controlCount)
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 获取当前控件对应的 DOM 容器
|
|
193
|
+
*/
|
|
194
|
+
}, {
|
|
195
|
+
key: "getContainer",
|
|
196
|
+
value: function getContainer() {
|
|
197
|
+
return this.container;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 获取当前 Control 是否展示
|
|
202
|
+
*/
|
|
203
|
+
}, {
|
|
204
|
+
key: "getIsShow",
|
|
205
|
+
value: function getIsShow() {
|
|
206
|
+
return this.isShow;
|
|
207
|
+
}
|
|
208
|
+
}, {
|
|
209
|
+
key: "_refocusOnMap",
|
|
210
|
+
value: function _refocusOnMap(e) {
|
|
211
|
+
// if map exists and event is not a keyboard event
|
|
212
|
+
if (this.mapsService && e && e.screenX > 0 && e.screenY > 0) {
|
|
213
|
+
var container = this.mapsService.getContainer();
|
|
214
|
+
if (container !== null) {
|
|
215
|
+
container.focus();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* 设置当前控件位置
|
|
222
|
+
* @param position
|
|
223
|
+
*/
|
|
224
|
+
}, {
|
|
225
|
+
key: "setPosition",
|
|
226
|
+
value: function setPosition() {
|
|
227
|
+
var position = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _l7Core.PositionType.TOPLEFT;
|
|
228
|
+
// 考虑组件的自动布局,需要销毁重建
|
|
229
|
+
var controlService = this.controlService;
|
|
230
|
+
if (controlService) {
|
|
231
|
+
controlService.removeControl(this);
|
|
232
|
+
}
|
|
233
|
+
this.controlOption.position = position;
|
|
234
|
+
if (controlService) {
|
|
235
|
+
controlService.addControl(this, this.sceneContainer);
|
|
236
|
+
}
|
|
237
|
+
return this;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* 设置容器 container 的样式相关位置,包含 className
|
|
242
|
+
* @param className
|
|
243
|
+
*/
|
|
244
|
+
}, {
|
|
245
|
+
key: "setClassName",
|
|
246
|
+
value: function setClassName(className) {
|
|
247
|
+
var container = this.container;
|
|
248
|
+
var oldClassName = this.controlOption.className;
|
|
249
|
+
if (oldClassName) {
|
|
250
|
+
_l7Utils.DOM.removeClass(container, oldClassName);
|
|
251
|
+
}
|
|
252
|
+
if (className) {
|
|
253
|
+
_l7Utils.DOM.addClass(container, className);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 设置容器 container 的样式相关位置,包含 style
|
|
259
|
+
* @param style
|
|
260
|
+
*/
|
|
261
|
+
}, {
|
|
262
|
+
key: "setStyle",
|
|
263
|
+
value: function setStyle(style) {
|
|
264
|
+
var container = this.container;
|
|
265
|
+
if (style) {
|
|
266
|
+
container.setAttribute('style', style);
|
|
267
|
+
} else {
|
|
268
|
+
container.removeAttribute('style');
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 将控件 DOM 插入到对应 position 的容器中
|
|
274
|
+
* @protected
|
|
275
|
+
*/
|
|
276
|
+
}, {
|
|
277
|
+
key: "insertContainer",
|
|
278
|
+
value: function insertContainer() {
|
|
279
|
+
var position = this.controlOption.position;
|
|
280
|
+
var container = this.container;
|
|
281
|
+
if (position instanceof Element) {
|
|
282
|
+
position.appendChild(container);
|
|
283
|
+
} else {
|
|
284
|
+
var corner = this.controlService.controlCorners[position];
|
|
285
|
+
if (['bottomleft', 'bottomright', 'righttop', 'rightbottom'].includes(position)) {
|
|
286
|
+
corner.insertBefore(container, corner.firstChild);
|
|
287
|
+
} else {
|
|
288
|
+
corner.appendChild(container);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* 检查当前传入 option 是否包含 keys 字段
|
|
295
|
+
* @param option
|
|
296
|
+
* @param keys
|
|
297
|
+
* @protected
|
|
298
|
+
*/
|
|
299
|
+
}, {
|
|
300
|
+
key: "checkUpdateOption",
|
|
301
|
+
value: function checkUpdateOption(option, keys) {
|
|
302
|
+
return keys.some(function (key) {
|
|
303
|
+
return key in option;
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}]);
|
|
307
|
+
return Control;
|
|
308
|
+
}(_eventemitter.default);
|
|
309
|
+
exports.default = exports.Control = Control;
|
|
310
|
+
/**
|
|
311
|
+
* 当前类型控件实例个数
|
|
312
|
+
* @protected
|
|
313
|
+
*/
|
|
314
|
+
(0, _defineProperty2.default)(Control, "controlCount", 0);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ButtonControl", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _buttonControl.ButtonControl;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "Control", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _control.Control;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "PopperControl", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _popperControl.PopperControl;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "PositionType", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _control.PositionType;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "SelectControl", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _selectControl.SelectControl;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _buttonControl = require("./buttonControl");
|
|
37
|
+
var _control = require("./control");
|
|
38
|
+
var _popperControl = require("./popperControl");
|
|
39
|
+
var _selectControl = require("./selectControl");
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.PopperControl = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
+
var _popper = require("../../utils/popper");
|
|
16
|
+
var _buttonControl = _interopRequireDefault(require("./buttonControl"));
|
|
17
|
+
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); }; }
|
|
18
|
+
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; } }
|
|
19
|
+
var PopperPlacementMap = {
|
|
20
|
+
topleft: 'right-start',
|
|
21
|
+
topcenter: 'bottom',
|
|
22
|
+
topright: 'left-start',
|
|
23
|
+
bottomleft: 'right-end',
|
|
24
|
+
bottomcenter: 'top',
|
|
25
|
+
bottomright: 'left-end',
|
|
26
|
+
lefttop: 'bottom-start',
|
|
27
|
+
leftcenter: 'right',
|
|
28
|
+
leftbottom: 'top-start',
|
|
29
|
+
righttop: 'bottom-end',
|
|
30
|
+
rightcenter: 'left',
|
|
31
|
+
rightbottom: 'top-end'
|
|
32
|
+
};
|
|
33
|
+
var PopperControl = /*#__PURE__*/function (_ButtonControl) {
|
|
34
|
+
(0, _inherits2.default)(PopperControl, _ButtonControl);
|
|
35
|
+
var _super = _createSuper(PopperControl);
|
|
36
|
+
function PopperControl() {
|
|
37
|
+
(0, _classCallCheck2.default)(this, PopperControl);
|
|
38
|
+
return _super.apply(this, arguments);
|
|
39
|
+
}
|
|
40
|
+
(0, _createClass2.default)(PopperControl, [{
|
|
41
|
+
key: "getPopper",
|
|
42
|
+
value:
|
|
43
|
+
/**
|
|
44
|
+
* 气泡实例
|
|
45
|
+
* @protected
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
function getPopper() {
|
|
49
|
+
return this.popper;
|
|
50
|
+
}
|
|
51
|
+
}, {
|
|
52
|
+
key: "hide",
|
|
53
|
+
value: function hide() {
|
|
54
|
+
this.popper.hide();
|
|
55
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(PopperControl.prototype), "hide", this).call(this);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 获取默认配置
|
|
60
|
+
* @param option
|
|
61
|
+
*/
|
|
62
|
+
}, {
|
|
63
|
+
key: "getDefault",
|
|
64
|
+
value: function getDefault(option) {
|
|
65
|
+
var _option$position;
|
|
66
|
+
var defaultOption = (0, _get2.default)((0, _getPrototypeOf2.default)(PopperControl.prototype), "getDefault", this).call(this, option);
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
68
|
+
var position = (_option$position = option === null || option === void 0 ? void 0 : option.position) !== null && _option$position !== void 0 ? _option$position : defaultOption.position;
|
|
69
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(PopperControl.prototype), "getDefault", this).call(this, option)), {}, {
|
|
70
|
+
popperPlacement: position instanceof Element ? 'bottom' : PopperPlacementMap[position],
|
|
71
|
+
popperTrigger: 'click'
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "onAdd",
|
|
76
|
+
value: function onAdd() {
|
|
77
|
+
var button = (0, _get2.default)((0, _getPrototypeOf2.default)(PopperControl.prototype), "onAdd", this).call(this);
|
|
78
|
+
this.initPopper();
|
|
79
|
+
return button;
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "onRemove",
|
|
83
|
+
value: function onRemove() {
|
|
84
|
+
this.popper.destroy();
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "initPopper",
|
|
88
|
+
value: function initPopper() {
|
|
89
|
+
var _this = this;
|
|
90
|
+
var _this$controlOption = this.controlOption,
|
|
91
|
+
popperClassName = _this$controlOption.popperClassName,
|
|
92
|
+
popperPlacement = _this$controlOption.popperPlacement,
|
|
93
|
+
popperTrigger = _this$controlOption.popperTrigger;
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
95
|
+
var popperContainer = this.mapsService.getMapContainer();
|
|
96
|
+
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
98
|
+
this.popper = new _popper.Popper(this.button, {
|
|
99
|
+
className: popperClassName,
|
|
100
|
+
placement: popperPlacement,
|
|
101
|
+
trigger: popperTrigger,
|
|
102
|
+
container: popperContainer,
|
|
103
|
+
unique: true
|
|
104
|
+
});
|
|
105
|
+
this.popper.on('show', function () {
|
|
106
|
+
_this.emit('popperShow', _this);
|
|
107
|
+
}).on('hide', function () {
|
|
108
|
+
_this.emit('popperHide', _this);
|
|
109
|
+
});
|
|
110
|
+
return this.popper;
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "setOptions",
|
|
114
|
+
value: function setOptions(option) {
|
|
115
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(PopperControl.prototype), "setOptions", this).call(this, option);
|
|
116
|
+
if (this.checkUpdateOption(option, ['popperPlacement', 'popperTrigger', 'popperClassName'])) {
|
|
117
|
+
var content = this.popper.getContent();
|
|
118
|
+
this.popper.destroy();
|
|
119
|
+
this.initPopper();
|
|
120
|
+
this.popper.setContent(content);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}]);
|
|
124
|
+
return PopperControl;
|
|
125
|
+
}(_buttonControl.default);
|
|
126
|
+
exports.default = exports.PopperControl = PopperControl;
|