@antv/l7-component 2.16.0 → 2.16.1

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 (47) hide show
  1. package/es/assets/iconfont/iconfont.js +17 -10
  2. package/es/control/baseControl/buttonControl.js +42 -9
  3. package/es/control/baseControl/control.js +54 -25
  4. package/es/control/baseControl/popperControl.js +24 -10
  5. package/es/control/baseControl/selectControl.js +45 -6
  6. package/es/control/exportImage.js +116 -76
  7. package/es/control/fullscreen.js +53 -20
  8. package/es/control/geoLocate.js +66 -36
  9. package/es/control/layerSwitch.js +31 -0
  10. package/es/control/logo.js +14 -2
  11. package/es/control/mapTheme.js +32 -7
  12. package/es/control/mouseLocation.js +23 -2
  13. package/es/control/scale.js +29 -6
  14. package/es/control/zoom.js +23 -0
  15. package/es/index.js +12 -2
  16. package/es/marker-layer.js +75 -41
  17. package/es/marker.js +83 -29
  18. package/es/popup/layerPopup.js +82 -31
  19. package/es/popup/popup.js +127 -48
  20. package/es/utils/anchor.js +7 -3
  21. package/es/utils/popper.js +64 -15
  22. package/es/utils/screenfull.js +52 -23
  23. package/lib/assets/iconfont/iconfont.js +17 -10
  24. package/lib/control/baseControl/buttonControl.js +52 -9
  25. package/lib/control/baseControl/control.js +69 -25
  26. package/lib/control/baseControl/index.js +8 -0
  27. package/lib/control/baseControl/popperControl.js +29 -10
  28. package/lib/control/baseControl/selectControl.js +60 -6
  29. package/lib/control/exportImage.js +125 -76
  30. package/lib/control/fullscreen.js +60 -20
  31. package/lib/control/geoLocate.js +75 -36
  32. package/lib/control/layerSwitch.js +36 -0
  33. package/lib/control/logo.js +26 -2
  34. package/lib/control/mapTheme.js +42 -7
  35. package/lib/control/mouseLocation.js +33 -2
  36. package/lib/control/scale.js +40 -6
  37. package/lib/control/zoom.js +33 -0
  38. package/lib/index.js +41 -0
  39. package/lib/marker-layer.js +86 -39
  40. package/lib/marker.js +91 -29
  41. package/lib/popup/layerPopup.js +94 -29
  42. package/lib/popup/popup.js +139 -48
  43. package/lib/utils/anchor.js +9 -4
  44. package/lib/utils/icon.js +2 -0
  45. package/lib/utils/popper.js +71 -14
  46. package/lib/utils/screenfull.js +54 -23
  47. package/package.json +6 -6
@@ -9,90 +9,120 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
9
9
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
10
10
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
11
  import _regeneratorRuntime from "@babel/runtime/regenerator";
12
+
12
13
  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); }; }
14
+
13
15
  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; } }
16
+
14
17
  import { DOM } from '@antv/l7-utils';
15
18
  import { createL7Icon } from "../utils/icon";
16
19
  import ScreenFull from "../utils/screenfull";
17
20
  import ButtonControl from "./baseControl/buttonControl";
18
21
  export { Fullscreen };
22
+
19
23
  var Fullscreen = /*#__PURE__*/function (_ButtonControl) {
20
24
  _inherits(Fullscreen, _ButtonControl);
25
+
21
26
  var _super = _createSuper(Fullscreen);
27
+
22
28
  function Fullscreen(option) {
23
29
  var _this;
30
+
24
31
  _classCallCheck(this, Fullscreen);
32
+
25
33
  _this = _super.call(this, option);
34
+
26
35
  _defineProperty(_assertThisInitialized(_this), "isFullscreen", false);
36
+
27
37
  _defineProperty(_assertThisInitialized(_this), "toggleFullscreen", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
28
38
  return _regeneratorRuntime.wrap(function _callee$(_context) {
29
- while (1) switch (_context.prev = _context.next) {
30
- case 0:
31
- if (!ScreenFull.isEnabled) {
39
+ while (1) {
40
+ switch (_context.prev = _context.next) {
41
+ case 0:
42
+ if (!ScreenFull.isEnabled) {
43
+ _context.next = 3;
44
+ break;
45
+ }
46
+
32
47
  _context.next = 3;
33
- break;
34
- }
35
- _context.next = 3;
36
- return ScreenFull.toggle(_this.mapContainer);
37
- case 3:
38
- case "end":
39
- return _context.stop();
48
+ return ScreenFull.toggle(_this.mapContainer);
49
+
50
+ case 3:
51
+ case "end":
52
+ return _context.stop();
53
+ }
40
54
  }
41
55
  }, _callee);
42
56
  })));
57
+
43
58
  _defineProperty(_assertThisInitialized(_this), "onClick", function () {
44
59
  _this.toggleFullscreen();
45
60
  });
61
+
46
62
  _defineProperty(_assertThisInitialized(_this), "onFullscreenChange", function () {
47
63
  _this.isFullscreen = !!document.fullscreenElement;
48
64
  var _this$controlOption = _this.controlOption,
49
- btnText = _this$controlOption.btnText,
50
- btnIcon = _this$controlOption.btnIcon,
51
- title = _this$controlOption.title,
52
- exitBtnText = _this$controlOption.exitBtnText,
53
- exitBtnIcon = _this$controlOption.exitBtnIcon,
54
- exitTitle = _this$controlOption.exitTitle;
65
+ btnText = _this$controlOption.btnText,
66
+ btnIcon = _this$controlOption.btnIcon,
67
+ title = _this$controlOption.title,
68
+ exitBtnText = _this$controlOption.exitBtnText,
69
+ exitBtnIcon = _this$controlOption.exitBtnIcon,
70
+ exitTitle = _this$controlOption.exitTitle;
71
+
55
72
  if (_this.isFullscreen) {
56
73
  _this.setBtnTitle(exitTitle);
74
+
57
75
  _this.setBtnText(exitBtnText);
76
+
58
77
  _this.setBtnIcon(exitBtnIcon);
59
78
  } else {
60
79
  _this.setBtnTitle(title);
80
+
61
81
  _this.setBtnText(btnText);
82
+
62
83
  _this.setBtnIcon(btnIcon);
63
84
  }
85
+
64
86
  _this.emit('fullscreenChange', _this.isFullscreen);
65
87
  });
88
+
66
89
  if (!ScreenFull.isEnabled) {
67
90
  console.warn('当前浏览器环境不支持对地图全屏化');
68
91
  }
92
+
69
93
  return _this;
70
94
  }
95
+
71
96
  _createClass(Fullscreen, [{
72
97
  key: "setOptions",
73
98
  value: function setOptions(newOptions) {
74
99
  var exitBtnText = newOptions.exitBtnText,
75
- exitBtnIcon = newOptions.exitBtnIcon,
76
- exitTitle = newOptions.exitTitle;
100
+ exitBtnIcon = newOptions.exitBtnIcon,
101
+ exitTitle = newOptions.exitTitle;
102
+
77
103
  if (this.isFullscreen) {
78
104
  if (this.checkUpdateOption(newOptions, ['exitBtnIcon'])) {
79
105
  this.setBtnIcon(exitBtnIcon);
80
106
  }
107
+
81
108
  if (this.checkUpdateOption(newOptions, ['exitBtnText'])) {
82
109
  this.setBtnText(exitBtnText);
83
110
  }
111
+
84
112
  if (this.checkUpdateOption(newOptions, ['exitTitle'])) {
85
113
  this.setBtnTitle(exitTitle);
86
114
  }
87
115
  }
116
+
88
117
  _get(_getPrototypeOf(Fullscreen.prototype), "setOptions", this).call(this, newOptions);
89
118
  }
90
119
  }, {
91
120
  key: "onAdd",
92
121
  value: function onAdd() {
93
122
  var button = _get(_getPrototypeOf(Fullscreen.prototype), "onAdd", this).call(this);
94
- button.addEventListener('click', this.onClick);
95
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
123
+
124
+ button.addEventListener('click', this.onClick); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
125
+
96
126
  this.mapContainer = DOM.getContainer(this.scene.getSceneConfig().id);
97
127
  this.mapContainer.addEventListener('fullscreenchange', this.onFullscreenChange);
98
128
  return button;
@@ -101,6 +131,7 @@ var Fullscreen = /*#__PURE__*/function (_ButtonControl) {
101
131
  key: "onRemove",
102
132
  value: function onRemove() {
103
133
  _get(_getPrototypeOf(Fullscreen.prototype), "onRemove", this).call(this);
134
+
104
135
  this.mapContainer.removeEventListener('fullscreenchange', this.onFullscreenChange);
105
136
  }
106
137
  }, {
@@ -114,6 +145,8 @@ var Fullscreen = /*#__PURE__*/function (_ButtonControl) {
114
145
  });
115
146
  }
116
147
  }]);
148
+
117
149
  return Fullscreen;
118
150
  }(ButtonControl);
151
+
119
152
  export { Fullscreen as default };
@@ -9,26 +9,37 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
9
9
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
10
10
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
11
  import _regeneratorRuntime from "@babel/runtime/regenerator";
12
+
12
13
  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); }; }
14
+
13
15
  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; } }
16
+
14
17
  import { isNaN } from 'lodash';
15
18
  import { createL7Icon } from "../utils/icon";
16
19
  import ButtonControl from "./baseControl/buttonControl";
17
20
  export { GeoLocate };
21
+
18
22
  var GeoLocate = /*#__PURE__*/function (_ButtonControl) {
19
23
  _inherits(GeoLocate, _ButtonControl);
24
+
20
25
  var _super = _createSuper(GeoLocate);
26
+
21
27
  function GeoLocate(option) {
22
28
  var _this;
29
+
23
30
  _classCallCheck(this, GeoLocate);
31
+
24
32
  _this = _super.call(this, option);
33
+
25
34
  _defineProperty(_assertThisInitialized(_this), "getGeoLocation", function () {
26
35
  return new Promise(function (resolve, reject) {
27
36
  window.navigator.geolocation.getCurrentPosition(function (_ref) {
28
37
  var coords = _ref.coords;
38
+
29
39
  var _ref2 = coords !== null && coords !== void 0 ? coords : {},
30
- longitude = _ref2.longitude,
31
- latitude = _ref2.latitude;
40
+ longitude = _ref2.longitude,
41
+ latitude = _ref2.latitude;
42
+
32
43
  if (!isNaN(longitude) && !isNaN(latitude)) {
33
44
  resolve([longitude, latitude]);
34
45
  } else {
@@ -39,51 +50,67 @@ var GeoLocate = /*#__PURE__*/function (_ButtonControl) {
39
50
  });
40
51
  });
41
52
  });
53
+
42
54
  _defineProperty(_assertThisInitialized(_this), "onClick", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
43
55
  var transform, position, currentZoom;
44
56
  return _regeneratorRuntime.wrap(function _callee$(_context) {
45
- while (1) switch (_context.prev = _context.next) {
46
- case 0:
47
- if (window.navigator.geolocation) {
48
- _context.next = 2;
49
- break;
50
- }
51
- return _context.abrupt("return");
52
- case 2:
53
- transform = _this.controlOption.transform;
54
- _context.next = 5;
55
- return _this.getGeoLocation();
56
- case 5:
57
- position = _context.sent;
58
- currentZoom = _this.mapsService.getZoom();
59
- _context.t0 = _this.mapsService;
60
- _context.t1 = currentZoom > 15 ? currentZoom : 15;
61
- if (!transform) {
62
- _context.next = 15;
57
+ while (1) {
58
+ switch (_context.prev = _context.next) {
59
+ case 0:
60
+ if (window.navigator.geolocation) {
61
+ _context.next = 2;
62
+ break;
63
+ }
64
+
65
+ return _context.abrupt("return");
66
+
67
+ case 2:
68
+ transform = _this.controlOption.transform;
69
+ _context.next = 5;
70
+ return _this.getGeoLocation();
71
+
72
+ case 5:
73
+ position = _context.sent;
74
+ currentZoom = _this.mapsService.getZoom();
75
+ _context.t0 = _this.mapsService;
76
+ _context.t1 = currentZoom > 15 ? currentZoom : 15;
77
+
78
+ if (!transform) {
79
+ _context.next = 15;
80
+ break;
81
+ }
82
+
83
+ _context.next = 12;
84
+ return transform(position);
85
+
86
+ case 12:
87
+ _context.t2 = _context.sent;
88
+ _context.next = 16;
63
89
  break;
64
- }
65
- _context.next = 12;
66
- return transform(position);
67
- case 12:
68
- _context.t2 = _context.sent;
69
- _context.next = 16;
70
- break;
71
- case 15:
72
- _context.t2 = position;
73
- case 16:
74
- _context.t3 = _context.t2;
75
- _context.t0.setZoomAndCenter.call(_context.t0, _context.t1, _context.t3);
76
- case 18:
77
- case "end":
78
- return _context.stop();
90
+
91
+ case 15:
92
+ _context.t2 = position;
93
+
94
+ case 16:
95
+ _context.t3 = _context.t2;
96
+
97
+ _context.t0.setZoomAndCenter.call(_context.t0, _context.t1, _context.t3);
98
+
99
+ case 18:
100
+ case "end":
101
+ return _context.stop();
102
+ }
79
103
  }
80
104
  }, _callee);
81
105
  })));
106
+
82
107
  if (!window.navigator.geolocation) {
83
108
  console.warn('当前浏览器环境不支持获取地理定位');
84
109
  }
110
+
85
111
  return _this;
86
112
  }
113
+
87
114
  _createClass(GeoLocate, [{
88
115
  key: "getDefault",
89
116
  value: function getDefault(option) {
@@ -96,14 +123,17 @@ var GeoLocate = /*#__PURE__*/function (_ButtonControl) {
96
123
  key: "onAdd",
97
124
  value: function onAdd() {
98
125
  var button = _get(_getPrototypeOf(GeoLocate.prototype), "onAdd", this).call(this);
126
+
99
127
  button.addEventListener('click', this.onClick);
100
128
  return button;
101
129
  }
102
-
103
130
  /**
104
131
  * 通过浏览器 API 获取当前所在经纬度
105
132
  */
133
+
106
134
  }]);
135
+
107
136
  return GeoLocate;
108
137
  }(ButtonControl);
138
+
109
139
  export { GeoLocate as default };
@@ -7,61 +7,84 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
9
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
+
10
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
+
11
13
  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; } }
14
+
12
15
  import { createL7Icon } from "../utils/icon";
13
16
  import SelectControl from "./baseControl/selectControl";
14
17
  export { LayerSwitch };
18
+
15
19
  var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
16
20
  _inherits(LayerSwitch, _SelectControl);
21
+
17
22
  var _super = _createSuper(LayerSwitch);
23
+
18
24
  function LayerSwitch() {
19
25
  var _this;
26
+
20
27
  _classCallCheck(this, LayerSwitch);
28
+
21
29
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
22
30
  args[_key] = arguments[_key];
23
31
  }
32
+
24
33
  _this = _super.call.apply(_super, [this].concat(args));
34
+
25
35
  _defineProperty(_assertThisInitialized(_this), "onLayerChange", function () {
26
36
  var _this$controlOption$l;
37
+
27
38
  if ((_this$controlOption$l = _this.controlOption.layers) !== null && _this$controlOption$l !== void 0 && _this$controlOption$l.length) {
28
39
  return;
29
40
  }
41
+
30
42
  _this.selectValue = _this.getLayerVisible();
43
+
31
44
  _this.setOptions({
32
45
  options: _this.getLayerOptions()
33
46
  });
34
47
  });
48
+
35
49
  _defineProperty(_assertThisInitialized(_this), "onLayerVisibleChane", function () {
36
50
  _this.setSelectValue(_this.getLayerVisible());
37
51
  });
52
+
38
53
  _defineProperty(_assertThisInitialized(_this), "onSelectChange", function () {
39
54
  _this.layers.forEach(function (layer) {
40
55
  var needShow = _this.selectValue.includes(layer.name);
56
+
41
57
  var isShow = layer.isVisible();
58
+
42
59
  if (needShow && !isShow) {
43
60
  layer.show();
44
61
  }
62
+
45
63
  if (!needShow && isShow) {
46
64
  layer.hide();
47
65
  }
48
66
  });
49
67
  });
68
+
50
69
  return _this;
51
70
  }
71
+
52
72
  _createClass(LayerSwitch, [{
53
73
  key: "layers",
54
74
  get: function get() {
55
75
  var layerService = this.layerService;
56
76
  var layers = this.controlOption.layers;
77
+
57
78
  if (Array.isArray(layers) && layers.length) {
58
79
  var layerInstances = [];
59
80
  layers.forEach(function (layer) {
60
81
  if (layer instanceof Object) {
61
82
  layerInstances.push(layer);
62
83
  }
84
+
63
85
  if (typeof layer === 'string') {
64
86
  var targetLayer = layerService.getLayer(layer) || layerService.getLayerByName(layer);
87
+
65
88
  if (targetLayer) {
66
89
  layerInstances.push(targetLayer);
67
90
  }
@@ -69,6 +92,7 @@ var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
69
92
  });
70
93
  return layerInstances;
71
94
  }
95
+
72
96
  return layerService.getLayers() || [];
73
97
  }
74
98
  }, {
@@ -103,7 +127,9 @@ var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
103
127
  key: "setOptions",
104
128
  value: function setOptions(option) {
105
129
  var isLayerChange = this.checkUpdateOption(option, ['layers']);
130
+
106
131
  _get(_getPrototypeOf(LayerSwitch.prototype), "setOptions", this).call(this, option);
132
+
107
133
  if (isLayerChange) {
108
134
  this.selectValue = this.getLayerVisible();
109
135
  this.controlOption.options = this.getLayerOptions();
@@ -114,12 +140,15 @@ var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
114
140
  key: "onAdd",
115
141
  value: function onAdd() {
116
142
  var _this$controlOption$o;
143
+
117
144
  if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
118
145
  this.controlOption.options = this.getLayerOptions();
119
146
  }
147
+
120
148
  if (!this.controlOption.defaultValue) {
121
149
  this.controlOption.defaultValue = this.getLayerVisible();
122
150
  }
151
+
123
152
  this.on('selectChange', this.onSelectChange);
124
153
  this.layerService.on('layerChange', this.onLayerChange);
125
154
  return _get(_getPrototypeOf(LayerSwitch.prototype), "onAdd", this).call(this);
@@ -136,6 +165,8 @@ var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
136
165
  return true;
137
166
  }
138
167
  }]);
168
+
139
169
  return LayerSwitch;
140
170
  }(SelectControl);
171
+
141
172
  export { LayerSwitch as default };
@@ -4,18 +4,26 @@ import _get from "@babel/runtime/helpers/esm/get";
4
4
  import _inherits from "@babel/runtime/helpers/esm/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
+
7
8
  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); }; }
9
+
8
10
  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; } }
11
+
9
12
  import { DOM } from '@antv/l7-utils';
10
13
  import { Control, PositionType } from "./baseControl";
11
14
  export { Logo };
15
+
12
16
  var Logo = /*#__PURE__*/function (_Control) {
13
17
  _inherits(Logo, _Control);
18
+
14
19
  var _super = _createSuper(Logo);
20
+
15
21
  function Logo() {
16
22
  _classCallCheck(this, Logo);
23
+
17
24
  return _super.apply(this, arguments);
18
25
  }
26
+
19
27
  _createClass(Logo, [{
20
28
  key: "getDefault",
21
29
  value: function getDefault() {
@@ -42,6 +50,7 @@ var Logo = /*#__PURE__*/function (_Control) {
42
50
  key: "setOptions",
43
51
  value: function setOptions(option) {
44
52
  _get(_getPrototypeOf(Logo.prototype), "setOptions", this).call(this, option);
53
+
45
54
  if (this.checkUpdateOption(option, ['img', 'href'])) {
46
55
  DOM.clearChildren(this.container);
47
56
  this.setLogoContent(this.container);
@@ -51,12 +60,13 @@ var Logo = /*#__PURE__*/function (_Control) {
51
60
  key: "setLogoContent",
52
61
  value: function setLogoContent(container) {
53
62
  var _this$controlOption = this.controlOption,
54
- href = _this$controlOption.href,
55
- img = _this$controlOption.img;
63
+ href = _this$controlOption.href,
64
+ img = _this$controlOption.img;
56
65
  var imgDOM = DOM.create('img');
57
66
  imgDOM.setAttribute('src', img);
58
67
  imgDOM.setAttribute('aria-label', 'AntV logo');
59
68
  DOM.setUnDraggable(imgDOM);
69
+
60
70
  if (href) {
61
71
  var anchorDOM = DOM.create('a', 'l7-control-logo-link');
62
72
  anchorDOM.target = '_blank';
@@ -70,6 +80,8 @@ var Logo = /*#__PURE__*/function (_Control) {
70
80
  }
71
81
  }
72
82
  }]);
83
+
73
84
  return Logo;
74
85
  }(Control);
86
+
75
87
  export { Logo as default };
@@ -8,27 +8,39 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
8
8
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
9
9
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
10
10
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
11
+
11
12
  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); }; }
13
+
12
14
  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; } }
15
+
13
16
  import { GaodeMapStyleConfig, MapboxMapStyleConfig } from "../constants";
14
17
  import { createL7Icon } from "../utils/icon";
15
18
  import SelectControl from "./baseControl/selectControl";
16
19
  export { MapTheme };
20
+
17
21
  var MapTheme = /*#__PURE__*/function (_SelectControl) {
18
22
  _inherits(MapTheme, _SelectControl);
23
+
19
24
  var _super = _createSuper(MapTheme);
25
+
20
26
  function MapTheme() {
21
27
  var _this;
28
+
22
29
  _classCallCheck(this, MapTheme);
30
+
23
31
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24
32
  args[_key] = arguments[_key];
25
33
  }
34
+
26
35
  _this = _super.call.apply(_super, [this].concat(args));
36
+
27
37
  _defineProperty(_assertThisInitialized(_this), "onMapThemeChange", function () {
28
38
  _this.mapsService.setMapStyle(_this.selectValue[0]);
29
39
  });
40
+
30
41
  return _this;
31
42
  }
43
+
32
44
  _createClass(MapTheme, [{
33
45
  key: "getDefault",
34
46
  value: function getDefault(option) {
@@ -44,18 +56,22 @@ var MapTheme = /*#__PURE__*/function (_SelectControl) {
44
56
  var mapStyleConfig = this.mapsService.getType() === 'mapbox' ? MapboxMapStyleConfig : GaodeMapStyleConfig;
45
57
  return Object.entries(this.mapsService.getMapStyleConfig()).filter(function (_ref) {
46
58
  var _ref2 = _slicedToArray(_ref, 2),
47
- key = _ref2[0],
48
- value = _ref2[1];
59
+ key = _ref2[0],
60
+ value = _ref2[1];
61
+
49
62
  return typeof value === 'string' && key !== 'blank';
50
63
  }).map(function (_ref3) {
51
64
  var _mapStyleConfig$key;
65
+
52
66
  var _ref4 = _slicedToArray(_ref3, 2),
53
- key = _ref4[0],
54
- value = _ref4[1];
67
+ key = _ref4[0],
68
+ value = _ref4[1];
69
+
55
70
  // @ts-ignore
56
71
  var _ref5 = (_mapStyleConfig$key = mapStyleConfig[key]) !== null && _mapStyleConfig$key !== void 0 ? _mapStyleConfig$key : {},
57
- text = _ref5.text,
58
- img = _ref5.img;
72
+ text = _ref5.text,
73
+ img = _ref5.img;
74
+
59
75
  return {
60
76
  text: text !== null && text !== void 0 ? text : key,
61
77
  value: value,
@@ -73,29 +89,36 @@ var MapTheme = /*#__PURE__*/function (_SelectControl) {
73
89
  key: "onAdd",
74
90
  value: function onAdd() {
75
91
  var _this$controlOption$o,
76
- _this2 = this;
92
+ _this2 = this;
93
+
77
94
  if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
78
95
  this.controlOption.options = this.getStyleOptions();
79
96
  }
97
+
80
98
  if (this.controlOption.defaultValue) {
81
99
  var _this$controlOption$o2, _this$controlOption$o3;
100
+
82
101
  var defaultValue = this.controlOption.defaultValue;
83
102
  this.controlOption.defaultValue = (_this$controlOption$o2 = (_this$controlOption$o3 = this.controlOption.options.find(function (item) {
84
103
  return item.key === defaultValue;
85
104
  })) === null || _this$controlOption$o3 === void 0 ? void 0 : _this$controlOption$o3.value) !== null && _this$controlOption$o2 !== void 0 ? _this$controlOption$o2 : defaultValue;
86
105
  } else {
87
106
  var defaultStyle = this.getMapStyle();
107
+
88
108
  if (defaultStyle) {
89
109
  this.controlOption.defaultValue = defaultStyle;
90
110
  } else {
91
111
  // @ts-ignore
92
112
  this.mapsService.map.once('styledata', function () {
93
113
  var mapboxStyle = _this2.mapsService.getMapStyle();
114
+
94
115
  _this2.controlOption.defaultValue = mapboxStyle;
116
+
95
117
  _this2.setSelectValue(mapboxStyle, false);
96
118
  });
97
119
  }
98
120
  }
121
+
99
122
  this.on('selectChange', this.onMapThemeChange);
100
123
  return _get(_getPrototypeOf(MapTheme.prototype), "onAdd", this).call(this);
101
124
  }
@@ -105,6 +128,8 @@ var MapTheme = /*#__PURE__*/function (_SelectControl) {
105
128
  return false;
106
129
  }
107
130
  }]);
131
+
108
132
  return MapTheme;
109
133
  }(SelectControl);
134
+
110
135
  export { MapTheme as default };