@antv/l7-component 2.21.0 → 2.21.2

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 (83) hide show
  1. package/es/assets/iconfont/iconfont.js +6 -6
  2. package/es/constants/index.js +2 -2
  3. package/es/control/baseControl/buttonControl.js +109 -144
  4. package/es/control/baseControl/control.js +212 -258
  5. package/es/control/baseControl/popperControl.js +67 -95
  6. package/es/control/baseControl/selectControl.js +132 -178
  7. package/es/control/exportImage.js +59 -142
  8. package/es/control/fullscreen.js +69 -100
  9. package/es/control/geoLocate.js +37 -84
  10. package/es/control/layerSwitch.js +111 -154
  11. package/es/control/logo.js +43 -69
  12. package/es/control/mapTheme.js +57 -98
  13. package/es/control/mouseLocation.js +37 -69
  14. package/es/control/scale.js +107 -135
  15. package/es/control/swipe.js +297 -393
  16. package/es/control/zoom.js +80 -112
  17. package/es/css/index.css +10 -7
  18. package/es/index.js +667 -1
  19. package/es/marker-layer.js +274 -326
  20. package/es/marker.d.ts +0 -2
  21. package/es/marker.js +394 -453
  22. package/es/popup/layerPopup.js +277 -321
  23. package/es/popup/popup.js +422 -482
  24. package/es/utils/anchor.js +6 -6
  25. package/es/utils/icon.js +4 -4
  26. package/es/utils/popper.js +180 -196
  27. package/es/utils/screenfull.js +29 -51
  28. package/lib/assets/iconfont/iconfont.js +6 -6
  29. package/lib/constants/index.d.ts +60 -0
  30. package/lib/constants/index.js +2 -2
  31. package/lib/control/baseControl/buttonControl.d.ts +60 -0
  32. package/lib/control/baseControl/buttonControl.js +110 -143
  33. package/lib/control/baseControl/control.d.ts +112 -0
  34. package/lib/control/baseControl/control.js +213 -257
  35. package/lib/control/baseControl/index.d.ts +4 -0
  36. package/lib/control/baseControl/index.js +5 -5
  37. package/lib/control/baseControl/popperControl.d.ts +28 -0
  38. package/lib/control/baseControl/popperControl.js +68 -94
  39. package/lib/control/baseControl/selectControl.d.ts +53 -0
  40. package/lib/control/baseControl/selectControl.js +133 -177
  41. package/lib/control/exportImage.d.ts +19 -0
  42. package/lib/control/exportImage.js +60 -141
  43. package/lib/control/fullscreen.d.ts +20 -0
  44. package/lib/control/fullscreen.js +70 -99
  45. package/lib/control/geoLocate.d.ts +17 -0
  46. package/lib/control/geoLocate.js +38 -83
  47. package/lib/control/layerSwitch.d.ts +27 -0
  48. package/lib/control/layerSwitch.js +112 -153
  49. package/lib/control/logo.d.ts +14 -0
  50. package/lib/control/logo.js +44 -69
  51. package/lib/control/mapTheme.d.ts +11 -0
  52. package/lib/control/mapTheme.js +58 -97
  53. package/lib/control/mouseLocation.d.ts +16 -0
  54. package/lib/control/mouseLocation.js +38 -68
  55. package/lib/control/scale.d.ts +35 -0
  56. package/lib/control/scale.js +108 -134
  57. package/lib/control/swipe.d.ts +66 -0
  58. package/lib/control/swipe.js +298 -392
  59. package/lib/control/zoom.d.ts +39 -0
  60. package/lib/control/zoom.js +81 -111
  61. package/lib/css/index.css +10 -7
  62. package/lib/index.d.ts +19 -0
  63. package/lib/index.js +683 -17
  64. package/lib/interface.d.ts +18 -0
  65. package/lib/marker-layer.d.ts +55 -0
  66. package/lib/marker-layer.js +276 -324
  67. package/lib/marker.d.ts +58 -0
  68. package/lib/marker.js +395 -452
  69. package/lib/popup/layerPopup.d.ts +99 -0
  70. package/lib/popup/layerPopup.js +278 -320
  71. package/lib/popup/popup.d.ts +142 -0
  72. package/lib/popup/popup.js +423 -481
  73. package/lib/utils/anchor.d.ts +22 -0
  74. package/lib/utils/anchor.js +6 -6
  75. package/lib/utils/icon.d.ts +1 -0
  76. package/lib/utils/icon.js +6 -5
  77. package/lib/utils/popper.d.ts +76 -0
  78. package/lib/utils/popper.js +184 -196
  79. package/lib/utils/screenfull.d.ts +2 -0
  80. package/lib/utils/screenfull.js +29 -52
  81. package/package.json +16 -20
  82. package/CHANGELOG.md +0 -325
  83. package/LICENSE.md +0 -21
@@ -1,49 +1,31 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
- import _get from "@babel/runtime/helpers/esm/get";
6
- import _inherits from "@babel/runtime/helpers/esm/inherits";
7
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
8
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
- 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; } }
12
3
  import { createL7Icon } from "../utils/icon";
13
4
  import SelectControl from "./baseControl/selectControl";
14
5
  export { LayerSwitch };
15
6
  function isLayerSwitchItem(obj) {
16
- return Object.keys(obj !== null && obj !== void 0 ? obj : {}).every(function (key) {
17
- return ['layer', 'name', 'img'].includes(key);
18
- });
7
+ return Object.keys(obj !== null && obj !== void 0 ? obj : {}).every(key => ['layer', 'name', 'img'].includes(key));
19
8
  }
20
- var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
21
- _inherits(LayerSwitch, _SelectControl);
22
- var _super = _createSuper(LayerSwitch);
23
- function LayerSwitch() {
24
- var _this;
25
- _classCallCheck(this, LayerSwitch);
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
- _defineProperty(_assertThisInitialized(_this), "onLayerChange", function () {
9
+ export default class LayerSwitch extends SelectControl {
10
+ constructor(...args) {
11
+ super(...args);
12
+ _defineProperty(this, "onLayerChange", () => {
31
13
  var _this$controlOption$l;
32
- if ((_this$controlOption$l = _this.controlOption.layers) !== null && _this$controlOption$l !== void 0 && _this$controlOption$l.length) {
14
+ if ((_this$controlOption$l = this.controlOption.layers) !== null && _this$controlOption$l !== void 0 && _this$controlOption$l.length) {
33
15
  return;
34
16
  }
35
- _this.selectValue = _this.getLayerVisible();
36
- _this.setOptions({
37
- options: _this.getLayerOptions()
17
+ this.selectValue = this.getLayerVisible();
18
+ this.setOptions({
19
+ options: this.getLayerOptions()
38
20
  });
39
21
  });
40
- _defineProperty(_assertThisInitialized(_this), "onLayerVisibleChane", function () {
41
- _this.setSelectValue(_this.getLayerVisible());
22
+ _defineProperty(this, "onLayerVisibleChane", () => {
23
+ this.setSelectValue(this.getLayerVisible());
42
24
  });
43
- _defineProperty(_assertThisInitialized(_this), "onSelectChange", function () {
44
- _this.layers.forEach(function (layer) {
45
- var needShow = _this.selectValue.includes(layer.name);
46
- var isShow = layer.isVisible();
25
+ _defineProperty(this, "onSelectChange", () => {
26
+ this.layers.forEach(layer => {
27
+ const needShow = this.selectValue.includes(layer.name);
28
+ const isShow = layer.isVisible();
47
29
  if (needShow && !isShow) {
48
30
  layer.show();
49
31
  }
@@ -52,143 +34,118 @@ var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
52
34
  }
53
35
  });
54
36
  });
55
- return _this;
56
37
  }
57
- _createClass(LayerSwitch, [{
58
- key: "layers",
59
- get: function get() {
60
- var layerService = this.layerService;
61
- var layers = this.controlOption.layers;
62
- if (Array.isArray(layers) && layers.length) {
63
- var layerInstances = [];
64
- layers.forEach(function (layer) {
65
- if (layer instanceof Object) {
66
- if (isLayerSwitchItem(layer)) {
67
- layerInstances.push(layer.layer);
68
- } else {
69
- layerInstances.push(layer);
70
- }
38
+ get layers() {
39
+ const layerService = this.layerService;
40
+ const {
41
+ layers
42
+ } = this.controlOption;
43
+ if (Array.isArray(layers) && layers.length) {
44
+ const layerInstances = [];
45
+ layers.forEach(layer => {
46
+ if (layer instanceof Object) {
47
+ if (isLayerSwitchItem(layer)) {
48
+ layerInstances.push(layer.layer);
49
+ } else {
50
+ layerInstances.push(layer);
71
51
  }
72
- if (typeof layer === 'string') {
73
- var targetLayer = layerService.getLayer(layer) || layerService.getLayerByName(layer);
74
- if (targetLayer) {
75
- layerInstances.push(targetLayer);
76
- }
52
+ }
53
+ if (typeof layer === 'string') {
54
+ const targetLayer = layerService.getLayer(layer) || layerService.getLayerByName(layer);
55
+ if (targetLayer) {
56
+ layerInstances.push(targetLayer);
77
57
  }
78
- });
79
- return layerInstances;
80
- }
81
- return layerService.getLayers() || [];
82
- }
83
- }, {
84
- key: "getDefault",
85
- value: function getDefault(option) {
86
- var _option$multiple;
87
- return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(LayerSwitch.prototype), "getDefault", this).call(this, option)), {}, {
88
- title: '图层控制',
89
- btnIcon: createL7Icon('l7-icon-layer'),
90
- options: [],
91
- multiple: (_option$multiple = option === null || option === void 0 ? void 0 : option.multiple) !== null && _option$multiple !== void 0 ? _option$multiple : true
92
- });
93
- }
94
- }, {
95
- key: "getLayerVisible",
96
- value: function getLayerVisible() {
97
- return this.layers.filter(function (layer) {
98
- return layer.isVisible();
99
- }).map(function (layer) {
100
- return layer.name;
58
+ }
101
59
  });
60
+ return layerInstances;
102
61
  }
103
- }, {
104
- key: "getLayerOptions",
105
- value: function getLayerOptions() {
106
- var _this2 = this;
107
- var layers = this.controlOption.layers;
108
- var isAllImg = layers === null || layers === void 0 ? void 0 : layers.every(function (item) {
109
- return item.img;
110
- });
111
- if (layers) {
112
- return layers === null || layers === void 0 ? void 0 : layers.map(function (layer) {
113
- if (isLayerSwitchItem(layer)) {
114
- return {
115
- text: layer.name || layer.layer.name,
116
- value: layer.layer.name,
117
- img: isAllImg ? layer.img : undefined
118
- };
119
- } else if (typeof layer === 'string') {
120
- var targetLayer = _this2.layerService.getLayer(layer) || _this2.layerService.getLayerByName(layer);
121
- return {
122
- text: targetLayer === null || targetLayer === void 0 ? void 0 : targetLayer.name,
123
- value: targetLayer === null || targetLayer === void 0 ? void 0 : targetLayer.name
124
- };
125
- }
62
+ return layerService.getLayers() || [];
63
+ }
64
+ getDefault(option) {
65
+ var _option$multiple;
66
+ return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
67
+ title: '图层控制',
68
+ btnIcon: createL7Icon('l7-icon-layer'),
69
+ options: [],
70
+ multiple: (_option$multiple = option === null || option === void 0 ? void 0 : option.multiple) !== null && _option$multiple !== void 0 ? _option$multiple : true
71
+ });
72
+ }
73
+ getLayerVisible() {
74
+ return this.layers.filter(layer => layer.isVisible()).map(layer => layer.name);
75
+ }
76
+ getLayerOptions() {
77
+ const {
78
+ layers
79
+ } = this.controlOption;
80
+ const isAllImg = layers === null || layers === void 0 ? void 0 : layers.every(item => item.img);
81
+ if (layers) {
82
+ return layers === null || layers === void 0 ? void 0 : layers.map(layer => {
83
+ if (isLayerSwitchItem(layer)) {
126
84
  return {
127
- text: layer.name,
128
- value: layer.name
85
+ text: layer.name || layer.layer.name,
86
+ value: layer.layer.name,
87
+ img: isAllImg ? layer.img : undefined
129
88
  };
130
- });
131
- }
132
- return this.layers.map(function (layer) {
89
+ } else if (typeof layer === 'string') {
90
+ const targetLayer = this.layerService.getLayer(layer) || this.layerService.getLayerByName(layer);
91
+ return {
92
+ text: targetLayer === null || targetLayer === void 0 ? void 0 : targetLayer.name,
93
+ value: targetLayer === null || targetLayer === void 0 ? void 0 : targetLayer.name
94
+ };
95
+ }
133
96
  return {
134
97
  text: layer.name,
135
98
  value: layer.name
136
99
  };
137
100
  });
138
101
  }
139
- }, {
140
- key: "setOptions",
141
- value: function setOptions(option) {
142
- var isLayerChange = this.checkUpdateOption(option, ['layers', 'multiple']);
143
- _get(_getPrototypeOf(LayerSwitch.prototype), "setOptions", this).call(this, option);
144
- if (isLayerChange) {
145
- if (this.controlOption.multiple === false) {
146
- this.handleSingleSelection();
147
- }
148
- this.selectValue = this.getLayerVisible();
149
- this.controlOption.options = this.getLayerOptions();
150
- this.popper.setContent(this.getPopperContent(this.controlOption.options));
151
- }
152
- }
153
-
154
- // TODO: 单选模式下,目前默认展示第一项,通过用户提供defaultValue展示默认选项的属性待开发
155
- // 如果是单选模式,则只显示第一个图层
156
- }, {
157
- key: "handleSingleSelection",
158
- value: function handleSingleSelection() {
159
- this.layers.forEach(function (layer, index) {
160
- index === 0 ? layer.show() : layer.hide();
161
- });
162
- }
163
- }, {
164
- key: "onAdd",
165
- value: function onAdd() {
166
- var _this$controlOption$o;
102
+ return this.layers.map(layer => {
103
+ return {
104
+ text: layer.name,
105
+ value: layer.name
106
+ };
107
+ });
108
+ }
109
+ setOptions(option) {
110
+ const isLayerChange = this.checkUpdateOption(option, ['layers', 'multiple']);
111
+ super.setOptions(option);
112
+ if (isLayerChange) {
167
113
  if (this.controlOption.multiple === false) {
168
114
  this.handleSingleSelection();
169
115
  }
170
- if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
171
- this.controlOption.options = this.getLayerOptions();
172
- }
173
- if (!this.controlOption.defaultValue) {
174
- this.controlOption.defaultValue = this.getLayerVisible();
175
- }
176
- this.on('selectChange', this.onSelectChange);
177
- this.layerService.on('layerChange', this.onLayerChange);
178
- return _get(_getPrototypeOf(LayerSwitch.prototype), "onAdd", this).call(this);
116
+ this.selectValue = this.getLayerVisible();
117
+ this.controlOption.options = this.getLayerOptions();
118
+ this.popper.setContent(this.getPopperContent(this.controlOption.options));
179
119
  }
180
- }, {
181
- key: "onRemove",
182
- value: function onRemove() {
183
- this.off('selectChange', this.onSelectChange);
184
- this.layerService.off('layerChange', this.onLayerChange);
120
+ }
121
+
122
+ // TODO: 单选模式下,目前默认展示第一项,通过用户提供defaultValue展示默认选项的属性待开发
123
+ // 如果是单选模式,则只显示第一个图层
124
+ handleSingleSelection() {
125
+ this.layers.forEach((layer, index) => {
126
+ index === 0 ? layer.show() : layer.hide();
127
+ });
128
+ }
129
+ onAdd() {
130
+ var _this$controlOption$o;
131
+ if (this.controlOption.multiple === false) {
132
+ this.handleSingleSelection();
185
133
  }
186
- }, {
187
- key: "getIsMultiple",
188
- value: function getIsMultiple() {
189
- return this.controlOption.multiple;
134
+ if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
135
+ this.controlOption.options = this.getLayerOptions();
190
136
  }
191
- }]);
192
- return LayerSwitch;
193
- }(SelectControl);
194
- export { LayerSwitch as default };
137
+ if (!this.controlOption.defaultValue) {
138
+ this.controlOption.defaultValue = this.getLayerVisible();
139
+ }
140
+ this.on('selectChange', this.onSelectChange);
141
+ this.layerService.on('layerChange', this.onLayerChange);
142
+ return super.onAdd();
143
+ }
144
+ onRemove() {
145
+ this.off('selectChange', this.onSelectChange);
146
+ this.layerService.off('layerChange', this.onLayerChange);
147
+ }
148
+ getIsMultiple() {
149
+ return this.controlOption.multiple;
150
+ }
151
+ }
@@ -1,75 +1,49 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _get from "@babel/runtime/helpers/esm/get";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
- 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; } }
9
1
  import { DOM } from '@antv/l7-utils';
10
2
  import { Control, PositionType } from "./baseControl";
11
3
  export { Logo };
12
- var Logo = /*#__PURE__*/function (_Control) {
13
- _inherits(Logo, _Control);
14
- var _super = _createSuper(Logo);
15
- function Logo() {
16
- _classCallCheck(this, Logo);
17
- return _super.apply(this, arguments);
4
+ export default class Logo extends Control {
5
+ getDefault() {
6
+ return {
7
+ position: PositionType.BOTTOMLEFT,
8
+ name: 'logo',
9
+ href: 'https://l7.antv.antgroup.com/',
10
+ img: 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*GRb1TKp4HcMAAAAAAAAAAAAAARQnAQ'
11
+ };
18
12
  }
19
- _createClass(Logo, [{
20
- key: "getDefault",
21
- value: function getDefault() {
22
- return {
23
- position: PositionType.BOTTOMLEFT,
24
- name: 'logo',
25
- href: 'https://l7.antv.antgroup.com/',
26
- img: 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*GRb1TKp4HcMAAAAAAAAAAAAAARQnAQ'
27
- };
28
- }
29
- }, {
30
- key: "onAdd",
31
- value: function onAdd() {
32
- var container = DOM.create('div', 'l7-control-logo');
33
- this.setLogoContent(container);
34
- return container;
35
- }
36
- }, {
37
- key: "onRemove",
38
- value: function onRemove() {
39
- return null;
40
- }
41
- }, {
42
- key: "setOptions",
43
- value: function setOptions(option) {
44
- _get(_getPrototypeOf(Logo.prototype), "setOptions", this).call(this, option);
45
- if (this.checkUpdateOption(option, ['img', 'href'])) {
46
- DOM.clearChildren(this.container);
47
- this.setLogoContent(this.container);
48
- }
13
+ onAdd() {
14
+ const container = DOM.create('div', 'l7-control-logo');
15
+ this.setLogoContent(container);
16
+ return container;
17
+ }
18
+ onRemove() {
19
+ return null;
20
+ }
21
+ setOptions(option) {
22
+ super.setOptions(option);
23
+ if (this.checkUpdateOption(option, ['img', 'href'])) {
24
+ DOM.clearChildren(this.container);
25
+ this.setLogoContent(this.container);
49
26
  }
50
- }, {
51
- key: "setLogoContent",
52
- value: function setLogoContent(container) {
53
- var _this$controlOption = this.controlOption,
54
- href = _this$controlOption.href,
55
- img = _this$controlOption.img;
56
- var imgDOM = DOM.create('img');
57
- imgDOM.setAttribute('src', img);
58
- imgDOM.setAttribute('aria-label', 'AntV logo');
59
- DOM.setUnDraggable(imgDOM);
60
- if (href) {
61
- var anchorDOM = DOM.create('a', 'l7-control-logo-link');
62
- anchorDOM.target = '_blank';
63
- anchorDOM.href = href;
64
- anchorDOM.rel = 'noopener nofollow';
65
- anchorDOM.setAttribute('rel', 'noopener nofollow');
66
- anchorDOM.appendChild(imgDOM);
67
- container.appendChild(anchorDOM);
68
- } else {
69
- container.appendChild(imgDOM);
70
- }
27
+ }
28
+ setLogoContent(container) {
29
+ const {
30
+ href,
31
+ img
32
+ } = this.controlOption;
33
+ const imgDOM = DOM.create('img');
34
+ imgDOM.setAttribute('src', img);
35
+ imgDOM.setAttribute('aria-label', 'AntV logo');
36
+ DOM.setUnDraggable(imgDOM);
37
+ if (href) {
38
+ const anchorDOM = DOM.create('a', 'l7-control-logo-link');
39
+ anchorDOM.target = '_blank';
40
+ anchorDOM.href = href;
41
+ anchorDOM.rel = 'noopener nofollow';
42
+ anchorDOM.setAttribute('rel', 'noopener nofollow');
43
+ anchorDOM.appendChild(imgDOM);
44
+ container.appendChild(anchorDOM);
45
+ } else {
46
+ container.appendChild(imgDOM);
71
47
  }
72
- }]);
73
- return Logo;
74
- }(Control);
75
- export { Logo as default };
48
+ }
49
+ }
@@ -1,110 +1,69 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/esm/createClass";
5
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
6
- import _get from "@babel/runtime/helpers/esm/get";
7
- import _inherits from "@babel/runtime/helpers/esm/inherits";
8
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
9
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
10
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
- 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; } }
13
3
  import { GaodeMapStyleConfig, MapboxMapStyleConfig } from "../constants";
14
4
  import { createL7Icon } from "../utils/icon";
15
5
  import SelectControl from "./baseControl/selectControl";
16
6
  export { MapTheme };
17
- var MapTheme = /*#__PURE__*/function (_SelectControl) {
18
- _inherits(MapTheme, _SelectControl);
19
- var _super = _createSuper(MapTheme);
20
- function MapTheme() {
21
- var _this;
22
- _classCallCheck(this, MapTheme);
23
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24
- args[_key] = arguments[_key];
25
- }
26
- _this = _super.call.apply(_super, [this].concat(args));
27
- _defineProperty(_assertThisInitialized(_this), "onMapThemeChange", function () {
28
- _this.mapsService.setMapStyle(_this.selectValue[0]);
7
+ export default class MapTheme extends SelectControl {
8
+ constructor(...args) {
9
+ super(...args);
10
+ _defineProperty(this, "onMapThemeChange", () => {
11
+ this.mapsService.setMapStyle(this.selectValue[0]);
29
12
  });
30
- return _this;
31
13
  }
32
- _createClass(MapTheme, [{
33
- key: "getDefault",
34
- value: function getDefault(option) {
35
- return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(MapTheme.prototype), "getDefault", this).call(this, option)), {}, {
36
- title: '地图样式',
37
- btnIcon: createL7Icon('l7-icon-color'),
38
- options: []
39
- });
40
- }
41
- }, {
42
- key: "getStyleOptions",
43
- value: function getStyleOptions() {
44
- var mapStyleConfig = this.mapsService.getType() === 'mapbox' ? MapboxMapStyleConfig : GaodeMapStyleConfig;
45
- return Object.entries(this.mapsService.getMapStyleConfig()).filter(function (_ref) {
46
- var _ref2 = _slicedToArray(_ref, 2),
47
- key = _ref2[0],
48
- value = _ref2[1];
49
- return typeof value === 'string' && key !== 'blank';
50
- }).map(function (_ref3) {
51
- var _mapStyleConfig$key;
52
- var _ref4 = _slicedToArray(_ref3, 2),
53
- key = _ref4[0],
54
- value = _ref4[1];
55
- // @ts-ignore
56
- var _ref5 = (_mapStyleConfig$key = mapStyleConfig[key]) !== null && _mapStyleConfig$key !== void 0 ? _mapStyleConfig$key : {},
57
- text = _ref5.text,
58
- img = _ref5.img;
59
- return {
60
- text: text !== null && text !== void 0 ? text : key,
61
- value: value,
62
- img: img,
63
- key: key
64
- };
65
- });
66
- }
67
- }, {
68
- key: "getMapStyle",
69
- value: function getMapStyle() {
70
- return this.mapsService.getMapStyle();
14
+ getDefault(option) {
15
+ return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
16
+ title: '地图样式',
17
+ btnIcon: createL7Icon('l7-icon-color'),
18
+ options: []
19
+ });
20
+ }
21
+ getStyleOptions() {
22
+ const mapStyleConfig = this.mapsService.getType() === 'mapbox' ? MapboxMapStyleConfig : GaodeMapStyleConfig;
23
+ return Object.entries(this.mapsService.getMapStyleConfig()).filter(([key, value]) => typeof value === 'string' && key !== 'blank').map(([key, value]) => {
24
+ var _mapStyleConfig$key;
25
+ // @ts-ignore
26
+ const {
27
+ text,
28
+ img
29
+ } = (_mapStyleConfig$key = mapStyleConfig[key]) !== null && _mapStyleConfig$key !== void 0 ? _mapStyleConfig$key : {};
30
+ return {
31
+ text: text !== null && text !== void 0 ? text : key,
32
+ value,
33
+ img,
34
+ key
35
+ };
36
+ });
37
+ }
38
+ getMapStyle() {
39
+ return this.mapsService.getMapStyle();
40
+ }
41
+ onAdd() {
42
+ var _this$controlOption$o;
43
+ if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
44
+ this.controlOption.options = this.getStyleOptions();
71
45
  }
72
- }, {
73
- key: "onAdd",
74
- value: function onAdd() {
75
- var _this$controlOption$o,
76
- _this2 = this;
77
- if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
78
- this.controlOption.options = this.getStyleOptions();
79
- }
80
- if (this.controlOption.defaultValue) {
81
- var _this$controlOption$o2, _this$controlOption$o3;
82
- var defaultValue = this.controlOption.defaultValue;
83
- this.controlOption.defaultValue = (_this$controlOption$o2 = (_this$controlOption$o3 = this.controlOption.options.find(function (item) {
84
- return item.key === defaultValue;
85
- })) === null || _this$controlOption$o3 === void 0 ? void 0 : _this$controlOption$o3.value) !== null && _this$controlOption$o2 !== void 0 ? _this$controlOption$o2 : defaultValue;
46
+ if (this.controlOption.defaultValue) {
47
+ var _this$controlOption$o2, _this$controlOption$o3;
48
+ const defaultValue = this.controlOption.defaultValue;
49
+ this.controlOption.defaultValue = (_this$controlOption$o2 = (_this$controlOption$o3 = this.controlOption.options.find(item => item.key === defaultValue)) === null || _this$controlOption$o3 === void 0 ? void 0 : _this$controlOption$o3.value) !== null && _this$controlOption$o2 !== void 0 ? _this$controlOption$o2 : defaultValue;
50
+ } else {
51
+ const defaultStyle = this.getMapStyle();
52
+ if (defaultStyle) {
53
+ this.controlOption.defaultValue = defaultStyle;
86
54
  } else {
87
- var defaultStyle = this.getMapStyle();
88
- if (defaultStyle) {
89
- this.controlOption.defaultValue = defaultStyle;
90
- } else {
91
- // @ts-ignore
92
- this.mapsService.map.once('styledata', function () {
93
- var mapboxStyle = _this2.mapsService.getMapStyle();
94
- _this2.controlOption.defaultValue = mapboxStyle;
95
- _this2.setSelectValue(mapboxStyle, false);
96
- });
97
- }
55
+ // @ts-ignore
56
+ this.mapsService.map.once('styledata', () => {
57
+ const mapboxStyle = this.mapsService.getMapStyle();
58
+ this.controlOption.defaultValue = mapboxStyle;
59
+ this.setSelectValue(mapboxStyle, false);
60
+ });
98
61
  }
99
- this.on('selectChange', this.onMapThemeChange);
100
- return _get(_getPrototypeOf(MapTheme.prototype), "onAdd", this).call(this);
101
62
  }
102
- }, {
103
- key: "getIsMultiple",
104
- value: function getIsMultiple() {
105
- return false;
106
- }
107
- }]);
108
- return MapTheme;
109
- }(SelectControl);
110
- export { MapTheme as default };
63
+ this.on('selectChange', this.onMapThemeChange);
64
+ return super.onAdd();
65
+ }
66
+ getIsMultiple() {
67
+ return false;
68
+ }
69
+ }