@antv/l7-component 2.9.32-alpha.4 → 2.9.32-alpha.5
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/control/baseControl/buttonControl.d.ts +1 -1
- package/es/control/baseControl/control.d.ts +4 -5
- package/es/control/baseControl/control.js +18 -5
- package/es/control/baseControl/popperControl.d.ts +1 -1
- package/es/control/baseControl/selectControl.d.ts +2 -2
- package/es/control/baseControl/selectControl.js +5 -0
- package/es/control/zoom.d.ts +3 -2
- package/lib/assets/iconfont/iconfont.js +46 -30
- package/lib/constants/index.js +34 -56
- package/lib/control/baseControl/buttonControl.js +194 -105
- package/lib/control/baseControl/control.js +317 -156
- package/lib/control/baseControl/index.js +57 -22
- package/lib/control/baseControl/popperControl.js +136 -102
- package/lib/control/baseControl/selectControl.js +230 -130
- package/lib/control/exportImage.js +175 -81
- package/lib/control/fullscreen.js +157 -102
- package/lib/control/geoLocate.js +143 -67
- package/lib/control/layerControl.js +162 -116
- package/lib/control/logo.js +101 -70
- package/lib/control/mapTheme.js +144 -85
- package/lib/control/mouseLocation.js +112 -71
- package/lib/control/scale.js +180 -127
- package/lib/control/zoom.js +154 -111
- package/lib/index.js +251 -48
- package/lib/interface.js +4 -16
- package/lib/marker-layer.js +367 -249
- package/lib/marker.js +419 -277
- package/lib/popup/layerPopup.js +305 -188
- package/lib/popup/popup.js +602 -339
- package/lib/utils/anchor.js +37 -55
- package/lib/utils/icon.js +13 -32
- package/lib/utils/popper.js +268 -180
- package/lib/utils/screenfull.js +110 -103
- package/package.json +5 -5
package/lib/control/geoLocate.js
CHANGED
|
@@ -1,78 +1,154 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
|
|
22
|
-
// src/control/geoLocate.ts
|
|
23
|
-
var geoLocate_exports = {};
|
|
24
|
-
__export(geoLocate_exports, {
|
|
25
|
-
GeoLocate: () => GeoLocate,
|
|
26
|
-
default: () => GeoLocate
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
27
7
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
8
|
+
exports.default = exports.GeoLocate = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
+
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
|
|
16
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
|
+
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
+
|
|
20
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
21
|
+
|
|
22
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
23
|
+
|
|
24
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
25
|
+
|
|
26
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
27
|
+
|
|
28
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
29
|
+
|
|
30
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
31
|
+
|
|
32
|
+
var _lodash = require("lodash");
|
|
33
|
+
|
|
34
|
+
var _icon = require("../utils/icon");
|
|
35
|
+
|
|
36
|
+
var _buttonControl = _interopRequireDefault(require("./baseControl/buttonControl"));
|
|
37
|
+
|
|
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
|
+
|
|
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
|
+
|
|
42
|
+
var GeoLocate = /*#__PURE__*/function (_ButtonControl) {
|
|
43
|
+
(0, _inherits2.default)(GeoLocate, _ButtonControl);
|
|
44
|
+
|
|
45
|
+
var _super = _createSuper(GeoLocate);
|
|
46
|
+
|
|
47
|
+
function GeoLocate(option) {
|
|
48
|
+
var _this;
|
|
49
|
+
|
|
50
|
+
(0, _classCallCheck2.default)(this, GeoLocate);
|
|
51
|
+
_this = _super.call(this, option);
|
|
52
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getGeoLocation", function () {
|
|
53
|
+
return new Promise(function (resolve, reject) {
|
|
54
|
+
window.navigator.geolocation.getCurrentPosition(function (_ref) {
|
|
55
|
+
var coords = _ref.coords;
|
|
56
|
+
|
|
57
|
+
var _ref2 = coords !== null && coords !== void 0 ? coords : {},
|
|
58
|
+
longitude = _ref2.longitude,
|
|
59
|
+
latitude = _ref2.latitude;
|
|
60
|
+
|
|
61
|
+
if (!(0, _lodash.isNaN)(longitude) && !(0, _lodash.isNaN)(latitude)) {
|
|
40
62
|
resolve([longitude, latitude]);
|
|
41
63
|
} else {
|
|
42
64
|
reject();
|
|
43
65
|
}
|
|
44
|
-
}, (e)
|
|
66
|
+
}, function (e) {
|
|
45
67
|
reject(e);
|
|
46
68
|
});
|
|
47
69
|
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
});
|
|
71
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClick", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
72
|
+
var transform, position, currentZoom;
|
|
73
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
74
|
+
while (1) {
|
|
75
|
+
switch (_context.prev = _context.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
if (window.navigator.geolocation) {
|
|
78
|
+
_context.next = 2;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return _context.abrupt("return");
|
|
83
|
+
|
|
84
|
+
case 2:
|
|
85
|
+
transform = _this.controlOption.transform;
|
|
86
|
+
_context.next = 5;
|
|
87
|
+
return _this.getGeoLocation();
|
|
88
|
+
|
|
89
|
+
case 5:
|
|
90
|
+
position = _context.sent;
|
|
91
|
+
currentZoom = _this.mapsService.getZoom();
|
|
92
|
+
_context.t0 = _this.mapsService;
|
|
93
|
+
_context.t1 = currentZoom > 15 ? currentZoom : 15;
|
|
94
|
+
|
|
95
|
+
if (!transform) {
|
|
96
|
+
_context.next = 15;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
_context.next = 12;
|
|
101
|
+
return transform(position);
|
|
102
|
+
|
|
103
|
+
case 12:
|
|
104
|
+
_context.t2 = _context.sent;
|
|
105
|
+
_context.next = 16;
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
case 15:
|
|
109
|
+
_context.t2 = position;
|
|
110
|
+
|
|
111
|
+
case 16:
|
|
112
|
+
_context.t3 = _context.t2;
|
|
113
|
+
|
|
114
|
+
_context.t0.setZoomAndCenter.call(_context.t0, _context.t1, _context.t3);
|
|
115
|
+
|
|
116
|
+
case 18:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context.stop();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, _callee);
|
|
122
|
+
})));
|
|
123
|
+
|
|
58
124
|
if (!window.navigator.geolocation) {
|
|
59
|
-
console.warn(
|
|
125
|
+
console.warn('当前浏览器环境不支持获取地理定位');
|
|
60
126
|
}
|
|
127
|
+
|
|
128
|
+
return _this;
|
|
61
129
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
130
|
+
|
|
131
|
+
(0, _createClass2.default)(GeoLocate, [{
|
|
132
|
+
key: "getDefault",
|
|
133
|
+
value: function getDefault(option) {
|
|
134
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(GeoLocate.prototype), "getDefault", this).call(this, option)), {}, {
|
|
135
|
+
title: '定位',
|
|
136
|
+
btnIcon: (0, _icon.createL7Icon)('l7-icon-reposition')
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "onAdd",
|
|
141
|
+
value: function onAdd() {
|
|
142
|
+
var button = (0, _get2.default)((0, _getPrototypeOf2.default)(GeoLocate.prototype), "onAdd", this).call(this);
|
|
143
|
+
button.addEventListener('click', this.onClick);
|
|
144
|
+
return button;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* 通过浏览器 API 获取当前所在经纬度
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
}]);
|
|
151
|
+
return GeoLocate;
|
|
152
|
+
}(_buttonControl.default);
|
|
153
|
+
|
|
154
|
+
exports.default = exports.GeoLocate = GeoLocate;
|
|
@@ -1,136 +1,182 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
|
|
22
|
-
// src/control/layerControl.ts
|
|
23
|
-
var layerControl_exports = {};
|
|
24
|
-
__export(layerControl_exports, {
|
|
25
|
-
LayerControl: () => LayerControl,
|
|
26
|
-
default: () => LayerControl
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
27
7
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
8
|
+
exports.default = exports.LayerControl = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
24
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
26
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
+
|
|
28
|
+
var _icon = require("../utils/icon");
|
|
29
|
+
|
|
30
|
+
var _selectControl = _interopRequireDefault(require("./baseControl/selectControl"));
|
|
31
|
+
|
|
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
|
+
|
|
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; } }
|
|
35
|
+
|
|
36
|
+
var LayerControl = /*#__PURE__*/function (_SelectControl) {
|
|
37
|
+
(0, _inherits2.default)(LayerControl, _SelectControl);
|
|
38
|
+
|
|
39
|
+
var _super = _createSuper(LayerControl);
|
|
40
|
+
|
|
41
|
+
function LayerControl() {
|
|
42
|
+
var _this;
|
|
43
|
+
|
|
44
|
+
(0, _classCallCheck2.default)(this, LayerControl);
|
|
45
|
+
|
|
46
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
47
|
+
args[_key] = arguments[_key];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
51
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "bindLayerVisibleCallback", function () {
|
|
52
|
+
_this.layers.forEach(function (layer) {
|
|
53
|
+
layer.on('show', _this.onLayerVisibleChane);
|
|
54
|
+
layer.on('hide', _this.onLayerVisibleChane);
|
|
38
55
|
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
layer.off(
|
|
43
|
-
layer.off(
|
|
56
|
+
});
|
|
57
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unbindLayerVisibleCallback", function () {
|
|
58
|
+
_this.layers.forEach(function (layer) {
|
|
59
|
+
layer.off('show', _this.onLayerVisibleChane);
|
|
60
|
+
layer.off('hide', _this.onLayerVisibleChane);
|
|
44
61
|
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
|
|
62
|
+
});
|
|
63
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onLayerChange", function () {
|
|
64
|
+
var _this$controlOption$l;
|
|
65
|
+
|
|
66
|
+
if ((_this$controlOption$l = _this.controlOption.layers) !== null && _this$controlOption$l !== void 0 && _this$controlOption$l.length) {
|
|
49
67
|
return;
|
|
50
68
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
69
|
+
|
|
70
|
+
_this.selectValue = _this.getLayerVisible();
|
|
71
|
+
|
|
72
|
+
_this.setOptions({
|
|
73
|
+
options: _this.getLayerOptions()
|
|
54
74
|
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
});
|
|
76
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onLayerVisibleChane", function () {
|
|
77
|
+
_this.setSelectValue(_this.getLayerVisible());
|
|
78
|
+
});
|
|
79
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectChange", function () {
|
|
80
|
+
_this.layers.forEach(function (layer) {
|
|
81
|
+
var needShow = _this.selectValue.includes(layer.name);
|
|
82
|
+
|
|
83
|
+
var isShow = layer.isVisible();
|
|
84
|
+
|
|
63
85
|
if (needShow && !isShow) {
|
|
64
86
|
layer.show();
|
|
65
87
|
}
|
|
88
|
+
|
|
66
89
|
if (!needShow && isShow) {
|
|
67
90
|
layer.hide();
|
|
68
91
|
}
|
|
69
92
|
});
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
get layers() {
|
|
73
|
-
return this.controlOption.layers || this.layerService.getLayers() || [];
|
|
74
|
-
}
|
|
75
|
-
getDefault(option) {
|
|
76
|
-
return {
|
|
77
|
-
...super.getDefault(option),
|
|
78
|
-
title: "\u56FE\u5C42\u63A7\u5236",
|
|
79
|
-
btnIcon: (0, import_icon.createL7Icon)("l7-icon-layer"),
|
|
80
|
-
options: []
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
getLayerVisible() {
|
|
84
|
-
return this.layers.filter((layer) => {
|
|
85
|
-
return layer.isVisible();
|
|
86
|
-
}).map((layer) => {
|
|
87
|
-
return layer.name;
|
|
88
93
|
});
|
|
94
|
+
return _this;
|
|
89
95
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
|
|
97
|
+
(0, _createClass2.default)(LayerControl, [{
|
|
98
|
+
key: "layers",
|
|
99
|
+
get: function get() {
|
|
100
|
+
return this.controlOption.layers || this.layerService.getLayers() || [];
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "getDefault",
|
|
104
|
+
value: function getDefault(option) {
|
|
105
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(LayerControl.prototype), "getDefault", this).call(this, option)), {}, {
|
|
106
|
+
title: '图层控制',
|
|
107
|
+
btnIcon: (0, _icon.createL7Icon)('l7-icon-layer'),
|
|
108
|
+
options: []
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "getLayerVisible",
|
|
113
|
+
value: function getLayerVisible() {
|
|
114
|
+
return this.layers.filter(function (layer) {
|
|
115
|
+
return layer.isVisible();
|
|
116
|
+
}).map(function (layer) {
|
|
117
|
+
return layer.name;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "getLayerOptions",
|
|
122
|
+
value: function getLayerOptions() {
|
|
123
|
+
return this.layers.map(function (layer) {
|
|
124
|
+
return {
|
|
125
|
+
text: layer.name,
|
|
126
|
+
value: layer.name
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
key: "setOptions",
|
|
132
|
+
value: function setOptions(option) {
|
|
133
|
+
var isLayerChange = this.checkUpdateOption(option, ['layers']);
|
|
134
|
+
|
|
135
|
+
if (isLayerChange) {
|
|
136
|
+
this.unbindLayerVisibleCallback();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(LayerControl.prototype), "setOptions", this).call(this, option);
|
|
140
|
+
|
|
141
|
+
if (isLayerChange) {
|
|
142
|
+
this.bindLayerVisibleCallback();
|
|
143
|
+
this.selectValue = this.getLayerVisible();
|
|
144
|
+
this.controlOption.options = this.getLayerOptions();
|
|
145
|
+
this.popper.setContent(this.getPopperContent(this.controlOption.options));
|
|
146
|
+
}
|
|
102
147
|
}
|
|
103
|
-
|
|
104
|
-
|
|
148
|
+
}, {
|
|
149
|
+
key: "onAdd",
|
|
150
|
+
value: function onAdd() {
|
|
151
|
+
var _this$controlOption$o;
|
|
152
|
+
|
|
153
|
+
if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
|
|
154
|
+
this.controlOption.options = this.getLayerOptions();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (!this.controlOption.defaultValue) {
|
|
158
|
+
this.controlOption.defaultValue = this.getLayerVisible();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
this.on('selectChange', this.onSelectChange);
|
|
162
|
+
this.layerService.on('layerChange', this.onLayerChange);
|
|
105
163
|
this.bindLayerVisibleCallback();
|
|
106
|
-
|
|
107
|
-
this.controlOption.options = this.getLayerOptions();
|
|
108
|
-
this.popper.setContent(this.getPopperContent(this.controlOption.options));
|
|
164
|
+
return (0, _get2.default)((0, _getPrototypeOf2.default)(LayerControl.prototype), "onAdd", this).call(this);
|
|
109
165
|
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.
|
|
166
|
+
}, {
|
|
167
|
+
key: "onRemove",
|
|
168
|
+
value: function onRemove() {
|
|
169
|
+
this.off('selectChange', this.onSelectChange);
|
|
170
|
+
this.layerService.off('layerChange', this.onLayerChange);
|
|
171
|
+
this.unbindLayerVisibleCallback();
|
|
115
172
|
}
|
|
116
|
-
|
|
117
|
-
|
|
173
|
+
}, {
|
|
174
|
+
key: "getIsMultiple",
|
|
175
|
+
value: function getIsMultiple() {
|
|
176
|
+
return true;
|
|
118
177
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
onRemove() {
|
|
125
|
-
this.off("selectChange", this.onSelectChange);
|
|
126
|
-
this.layerService.off("layerChange", this.onLayerChange);
|
|
127
|
-
this.unbindLayerVisibleCallback();
|
|
128
|
-
}
|
|
129
|
-
getIsMultiple() {
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
-
0 && (module.exports = {
|
|
135
|
-
LayerControl
|
|
136
|
-
});
|
|
178
|
+
}]);
|
|
179
|
+
return LayerControl;
|
|
180
|
+
}(_selectControl.default);
|
|
181
|
+
|
|
182
|
+
exports.default = exports.LayerControl = LayerControl;
|