@antv/l7-component 2.9.36-alpha.1 → 2.9.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/es/control/BaseControl.d.ts +27 -0
  2. package/es/control/BaseControl.js +134 -0
  3. package/es/control/layer.d.ts +38 -0
  4. package/es/control/layer.js +340 -0
  5. package/es/control/logo.d.ts +6 -10
  6. package/es/control/logo.js +11 -41
  7. package/es/control/scale.d.ts +10 -20
  8. package/es/control/scale.js +53 -77
  9. package/es/control/zoom.d.ts +10 -21
  10. package/es/control/zoom.js +49 -76
  11. package/es/css/l7.css +502 -0
  12. package/es/images/logo.png +0 -0
  13. package/es/index.d.ts +8 -15
  14. package/es/index.js +9 -15
  15. package/es/interface.d.ts +20 -1
  16. package/es/popup.d.ts +35 -0
  17. package/es/popup.js +300 -0
  18. package/lib/control/BaseControl.js +160 -0
  19. package/lib/control/layer.js +362 -0
  20. package/lib/control/logo.js +23 -50
  21. package/lib/control/scale.js +62 -82
  22. package/lib/control/zoom.js +59 -78
  23. package/lib/css/l7.css +502 -0
  24. package/lib/images/logo.png +0 -0
  25. package/lib/index.js +50 -165
  26. package/lib/popup.js +317 -0
  27. package/package.json +5 -8
  28. package/es/assets/iconfont/iconfont.js +0 -53
  29. package/es/constants/index.d.ts +0 -60
  30. package/es/constants/index.js +0 -60
  31. package/es/control/baseControl/buttonControl.d.ts +0 -59
  32. package/es/control/baseControl/buttonControl.js +0 -191
  33. package/es/control/baseControl/control.d.ts +0 -106
  34. package/es/control/baseControl/control.js +0 -301
  35. package/es/control/baseControl/index.d.ts +0 -4
  36. package/es/control/baseControl/index.js +0 -4
  37. package/es/control/baseControl/popperControl.d.ts +0 -26
  38. package/es/control/baseControl/popperControl.js +0 -131
  39. package/es/control/baseControl/selectControl.d.ts +0 -46
  40. package/es/control/baseControl/selectControl.js +0 -232
  41. package/es/control/exportImage.d.ts +0 -18
  42. package/es/control/exportImage.js +0 -163
  43. package/es/control/fullscreen.d.ts +0 -19
  44. package/es/control/fullscreen.js +0 -151
  45. package/es/control/geoLocate.d.ts +0 -16
  46. package/es/control/geoLocate.js +0 -139
  47. package/es/control/layerControl.d.ts +0 -21
  48. package/es/control/layerControl.js +0 -172
  49. package/es/control/mapTheme.d.ts +0 -10
  50. package/es/control/mapTheme.js +0 -135
  51. package/es/control/mouseLocation.d.ts +0 -15
  52. package/es/control/mouseLocation.js +0 -104
  53. package/es/css/button.less +0 -70
  54. package/es/css/control.less +0 -71
  55. package/es/css/index.css +0 -567
  56. package/es/css/index.less +0 -12
  57. package/es/css/l7.less +0 -60
  58. package/es/css/layerPopup.less +0 -8
  59. package/es/css/logo.less +0 -18
  60. package/es/css/mouseLocation.less +0 -9
  61. package/es/css/popper.less +0 -64
  62. package/es/css/popup.less +0 -169
  63. package/es/css/scale.less +0 -34
  64. package/es/css/select.less +0 -86
  65. package/es/css/variables.less +0 -28
  66. package/es/css/zoom.less +0 -21
  67. package/es/images/quanping.svg +0 -12
  68. package/es/popup/layerPopup.d.ts +0 -78
  69. package/es/popup/layerPopup.js +0 -308
  70. package/es/popup/popup.d.ts +0 -147
  71. package/es/popup/popup.js +0 -636
  72. package/es/utils/icon.d.ts +0 -1
  73. package/es/utils/icon.js +0 -9
  74. package/es/utils/popper.d.ts +0 -75
  75. package/es/utils/popper.js +0 -286
  76. package/es/utils/screenfull.d.ts +0 -2
  77. package/es/utils/screenfull.js +0 -157
  78. package/lib/assets/iconfont/iconfont.js +0 -55
  79. package/lib/constants/index.js +0 -68
  80. package/lib/control/baseControl/buttonControl.js +0 -207
  81. package/lib/control/baseControl/control.js +0 -333
  82. package/lib/control/baseControl/index.js +0 -57
  83. package/lib/control/baseControl/popperControl.js +0 -142
  84. package/lib/control/baseControl/selectControl.js +0 -253
  85. package/lib/control/exportImage.js +0 -177
  86. package/lib/control/fullscreen.js +0 -164
  87. package/lib/control/geoLocate.js +0 -154
  88. package/lib/control/layerControl.js +0 -182
  89. package/lib/control/mapTheme.js +0 -151
  90. package/lib/control/mouseLocation.js +0 -120
  91. package/lib/css/button.less +0 -70
  92. package/lib/css/control.less +0 -71
  93. package/lib/css/index.css +0 -567
  94. package/lib/css/index.less +0 -12
  95. package/lib/css/l7.less +0 -60
  96. package/lib/css/layerPopup.less +0 -8
  97. package/lib/css/logo.less +0 -18
  98. package/lib/css/mouseLocation.less +0 -9
  99. package/lib/css/popper.less +0 -64
  100. package/lib/css/popup.less +0 -169
  101. package/lib/css/scale.less +0 -34
  102. package/lib/css/select.less +0 -86
  103. package/lib/css/variables.less +0 -28
  104. package/lib/css/zoom.less +0 -21
  105. package/lib/images/quanping.svg +0 -12
  106. package/lib/popup/layerPopup.js +0 -317
  107. package/lib/popup/popup.js +0 -651
  108. package/lib/utils/icon.js +0 -18
  109. package/lib/utils/popper.js +0 -297
  110. package/lib/utils/screenfull.js +0 -167
@@ -1,164 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = exports.Fullscreen = 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 _l7Utils = require("@antv/l7-utils");
33
-
34
- var _icon = require("../utils/icon");
35
-
36
- var _screenfull = _interopRequireDefault(require("../utils/screenfull"));
37
-
38
- var _buttonControl = _interopRequireDefault(require("./baseControl/buttonControl"));
39
-
40
- 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
- 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
- var Fullscreen = /*#__PURE__*/function (_ButtonControl) {
45
- (0, _inherits2.default)(Fullscreen, _ButtonControl);
46
-
47
- var _super = _createSuper(Fullscreen);
48
-
49
- function Fullscreen(option) {
50
- var _this;
51
-
52
- (0, _classCallCheck2.default)(this, Fullscreen);
53
- _this = _super.call(this, option);
54
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isFullscreen", false);
55
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "toggleFullscreen", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
56
- return _regenerator.default.wrap(function _callee$(_context) {
57
- while (1) {
58
- switch (_context.prev = _context.next) {
59
- case 0:
60
- if (!_screenfull.default.isEnabled) {
61
- _context.next = 3;
62
- break;
63
- }
64
-
65
- _context.next = 3;
66
- return _screenfull.default.toggle(_this.mapContainer);
67
-
68
- case 3:
69
- case "end":
70
- return _context.stop();
71
- }
72
- }
73
- }, _callee);
74
- })));
75
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClick", function () {
76
- _this.toggleFullscreen();
77
- });
78
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onFullscreenChange", function () {
79
- _this.isFullscreen = !!document.fullscreenElement;
80
- var _this$controlOption = _this.controlOption,
81
- btnText = _this$controlOption.btnText,
82
- btnIcon = _this$controlOption.btnIcon,
83
- title = _this$controlOption.title,
84
- exitBtnText = _this$controlOption.exitBtnText,
85
- exitBtnIcon = _this$controlOption.exitBtnIcon,
86
- exitTitle = _this$controlOption.exitTitle;
87
-
88
- if (_this.isFullscreen) {
89
- _this.setBtnTitle(exitTitle);
90
-
91
- _this.setBtnText(exitBtnText);
92
-
93
- _this.setBtnIcon(exitBtnIcon);
94
- } else {
95
- _this.setBtnTitle(title);
96
-
97
- _this.setBtnText(btnText);
98
-
99
- _this.setBtnIcon(btnIcon);
100
- }
101
-
102
- _this.emit('fullscreenChange', _this.isFullscreen);
103
- });
104
-
105
- if (!_screenfull.default.isEnabled) {
106
- console.warn('当前浏览器环境不支持对地图全屏化');
107
- }
108
-
109
- return _this;
110
- }
111
-
112
- (0, _createClass2.default)(Fullscreen, [{
113
- key: "setOptions",
114
- value: function setOptions(newOptions) {
115
- var exitBtnText = newOptions.exitBtnText,
116
- exitBtnIcon = newOptions.exitBtnIcon,
117
- exitTitle = newOptions.exitTitle;
118
-
119
- if (this.isFullscreen) {
120
- if (this.checkUpdateOption(newOptions, ['exitBtnIcon'])) {
121
- this.setBtnIcon(exitBtnIcon);
122
- }
123
-
124
- if (this.checkUpdateOption(newOptions, ['exitBtnText'])) {
125
- this.setBtnText(exitBtnText);
126
- }
127
-
128
- if (this.checkUpdateOption(newOptions, ['exitTitle'])) {
129
- this.setBtnTitle(exitTitle);
130
- }
131
- }
132
-
133
- (0, _get2.default)((0, _getPrototypeOf2.default)(Fullscreen.prototype), "setOptions", this).call(this, newOptions);
134
- }
135
- }, {
136
- key: "onAdd",
137
- value: function onAdd() {
138
- var button = (0, _get2.default)((0, _getPrototypeOf2.default)(Fullscreen.prototype), "onAdd", this).call(this);
139
- button.addEventListener('click', this.onClick);
140
- this.mapContainer = _l7Utils.DOM.getContainer(this.scene.getSceneConfig().id);
141
- this.mapContainer.addEventListener('fullscreenchange', this.onFullscreenChange);
142
- return button;
143
- }
144
- }, {
145
- key: "onRemove",
146
- value: function onRemove() {
147
- (0, _get2.default)((0, _getPrototypeOf2.default)(Fullscreen.prototype), "onRemove", this).call(this);
148
- this.mapContainer.removeEventListener('fullscreenchange', this.onFullscreenChange);
149
- }
150
- }, {
151
- key: "getDefault",
152
- value: function getDefault(option) {
153
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(Fullscreen.prototype), "getDefault", this).call(this, option)), {}, {
154
- title: '全屏',
155
- btnIcon: (0, _icon.createL7Icon)('l7-icon-fullscreen'),
156
- exitTitle: '退出全屏',
157
- exitBtnIcon: (0, _icon.createL7Icon)('l7-icon-exit-fullscreen')
158
- });
159
- }
160
- }]);
161
- return Fullscreen;
162
- }(_buttonControl.default);
163
-
164
- exports.default = exports.Fullscreen = Fullscreen;
@@ -1,154 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
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)) {
62
- resolve([longitude, latitude]);
63
- } else {
64
- reject();
65
- }
66
- }, function (e) {
67
- reject(e);
68
- });
69
- });
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
-
124
- if (!window.navigator.geolocation) {
125
- console.warn('当前浏览器环境不支持获取地理定位');
126
- }
127
-
128
- return _this;
129
- }
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,182 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
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);
55
- });
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);
61
- });
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) {
67
- return;
68
- }
69
-
70
- _this.selectValue = _this.getLayerVisible();
71
-
72
- _this.setOptions({
73
- options: _this.getLayerOptions()
74
- });
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
-
85
- if (needShow && !isShow) {
86
- layer.show();
87
- }
88
-
89
- if (!needShow && isShow) {
90
- layer.hide();
91
- }
92
- });
93
- });
94
- return _this;
95
- }
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
- }
147
- }
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);
163
- this.bindLayerVisibleCallback();
164
- return (0, _get2.default)((0, _getPrototypeOf2.default)(LayerControl.prototype), "onAdd", this).call(this);
165
- }
166
- }, {
167
- key: "onRemove",
168
- value: function onRemove() {
169
- this.off('selectChange', this.onSelectChange);
170
- this.layerService.off('layerChange', this.onLayerChange);
171
- this.unbindLayerVisibleCallback();
172
- }
173
- }, {
174
- key: "getIsMultiple",
175
- value: function getIsMultiple() {
176
- return true;
177
- }
178
- }]);
179
- return LayerControl;
180
- }(_selectControl.default);
181
-
182
- exports.default = exports.LayerControl = LayerControl;
@@ -1,151 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = exports.MapTheme = void 0;
9
-
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
21
-
22
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
-
24
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
25
-
26
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
27
-
28
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
29
-
30
- var _constants = require("../constants");
31
-
32
- var _icon = require("../utils/icon");
33
-
34
- var _selectControl = _interopRequireDefault(require("./baseControl/selectControl"));
35
-
36
- 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); }; }
37
-
38
- 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; } }
39
-
40
- var MapTheme = /*#__PURE__*/function (_SelectControl) {
41
- (0, _inherits2.default)(MapTheme, _SelectControl);
42
-
43
- var _super = _createSuper(MapTheme);
44
-
45
- function MapTheme() {
46
- var _this;
47
-
48
- (0, _classCallCheck2.default)(this, MapTheme);
49
-
50
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
51
- args[_key] = arguments[_key];
52
- }
53
-
54
- _this = _super.call.apply(_super, [this].concat(args));
55
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMapThemeChange", function () {
56
- _this.mapsService.setMapStyle(_this.selectValue[0]);
57
- });
58
- return _this;
59
- }
60
-
61
- (0, _createClass2.default)(MapTheme, [{
62
- key: "getDefault",
63
- value: function getDefault(option) {
64
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(MapTheme.prototype), "getDefault", this).call(this, option)), {}, {
65
- title: '地图样式',
66
- btnIcon: (0, _icon.createL7Icon)('l7-icon-color'),
67
- options: []
68
- });
69
- }
70
- }, {
71
- key: "getStyleOptions",
72
- value: function getStyleOptions() {
73
- var mapStyleConfig = this.mapsService.getType() === 'mapbox' ? _constants.MapboxMapStyleConfig : _constants.GaodeMapStyleConfig;
74
- return Object.entries(this.mapsService.getMapStyleConfig()).filter(function (_ref) {
75
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
76
- key = _ref2[0],
77
- value = _ref2[1];
78
-
79
- return typeof value === 'string' && key !== 'blank';
80
- }).map(function (_ref3) {
81
- var _mapStyleConfig$key;
82
-
83
- var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
84
- key = _ref4[0],
85
- value = _ref4[1];
86
-
87
- // @ts-ignore
88
- var _ref5 = (_mapStyleConfig$key = mapStyleConfig[key]) !== null && _mapStyleConfig$key !== void 0 ? _mapStyleConfig$key : {},
89
- text = _ref5.text,
90
- img = _ref5.img;
91
-
92
- return {
93
- text: text !== null && text !== void 0 ? text : key,
94
- value: value,
95
- img: img,
96
- key: key
97
- };
98
- });
99
- }
100
- }, {
101
- key: "getMapStyle",
102
- value: function getMapStyle() {
103
- return this.mapsService.getMapStyle();
104
- }
105
- }, {
106
- key: "onAdd",
107
- value: function onAdd() {
108
- var _this$controlOption$o,
109
- _this2 = this;
110
-
111
- if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
112
- this.controlOption.options = this.getStyleOptions();
113
- }
114
-
115
- if (this.controlOption.defaultValue) {
116
- var _this$controlOption$o2, _this$controlOption$o3;
117
-
118
- var defaultValue = this.controlOption.defaultValue;
119
- this.controlOption.defaultValue = (_this$controlOption$o2 = (_this$controlOption$o3 = this.controlOption.options.find(function (item) {
120
- return item.key === defaultValue;
121
- })) === null || _this$controlOption$o3 === void 0 ? void 0 : _this$controlOption$o3.value) !== null && _this$controlOption$o2 !== void 0 ? _this$controlOption$o2 : defaultValue;
122
- } else {
123
- var defaultStyle = this.getMapStyle();
124
-
125
- if (defaultStyle) {
126
- this.controlOption.defaultValue = defaultStyle;
127
- } else {
128
- // @ts-ignore
129
- this.mapsService.map.once('styledata', function () {
130
- var mapboxStyle = _this2.mapsService.getMapStyle();
131
-
132
- _this2.controlOption.defaultValue = mapboxStyle;
133
-
134
- _this2.setSelectValue(mapboxStyle, false);
135
- });
136
- }
137
- }
138
-
139
- this.on('selectChange', this.onMapThemeChange);
140
- return (0, _get2.default)((0, _getPrototypeOf2.default)(MapTheme.prototype), "onAdd", this).call(this);
141
- }
142
- }, {
143
- key: "getIsMultiple",
144
- value: function getIsMultiple() {
145
- return false;
146
- }
147
- }]);
148
- return MapTheme;
149
- }(_selectControl.default);
150
-
151
- exports.default = exports.MapTheme = MapTheme;