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