@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.
- package/es/assets/iconfont/iconfont.js +6 -6
- package/es/constants/index.js +2 -2
- package/es/control/baseControl/buttonControl.js +109 -144
- package/es/control/baseControl/control.js +212 -258
- package/es/control/baseControl/popperControl.js +67 -95
- package/es/control/baseControl/selectControl.js +132 -178
- package/es/control/exportImage.js +59 -142
- package/es/control/fullscreen.js +69 -100
- package/es/control/geoLocate.js +37 -84
- package/es/control/layerSwitch.js +111 -154
- package/es/control/logo.js +43 -69
- package/es/control/mapTheme.js +57 -98
- package/es/control/mouseLocation.js +37 -69
- package/es/control/scale.js +107 -135
- package/es/control/swipe.js +297 -393
- package/es/control/zoom.js +80 -112
- package/es/css/index.css +10 -7
- package/es/index.js +667 -1
- package/es/marker-layer.js +274 -326
- package/es/marker.d.ts +0 -2
- package/es/marker.js +394 -453
- package/es/popup/layerPopup.js +277 -321
- package/es/popup/popup.js +422 -482
- package/es/utils/anchor.js +6 -6
- package/es/utils/icon.js +4 -4
- package/es/utils/popper.js +180 -196
- package/es/utils/screenfull.js +29 -51
- package/lib/assets/iconfont/iconfont.js +6 -6
- package/lib/constants/index.d.ts +60 -0
- package/lib/constants/index.js +2 -2
- package/lib/control/baseControl/buttonControl.d.ts +60 -0
- package/lib/control/baseControl/buttonControl.js +110 -143
- package/lib/control/baseControl/control.d.ts +112 -0
- package/lib/control/baseControl/control.js +213 -257
- package/lib/control/baseControl/index.d.ts +4 -0
- package/lib/control/baseControl/index.js +5 -5
- package/lib/control/baseControl/popperControl.d.ts +28 -0
- package/lib/control/baseControl/popperControl.js +68 -94
- package/lib/control/baseControl/selectControl.d.ts +53 -0
- package/lib/control/baseControl/selectControl.js +133 -177
- package/lib/control/exportImage.d.ts +19 -0
- package/lib/control/exportImage.js +60 -141
- package/lib/control/fullscreen.d.ts +20 -0
- package/lib/control/fullscreen.js +70 -99
- package/lib/control/geoLocate.d.ts +17 -0
- package/lib/control/geoLocate.js +38 -83
- package/lib/control/layerSwitch.d.ts +27 -0
- package/lib/control/layerSwitch.js +112 -153
- package/lib/control/logo.d.ts +14 -0
- package/lib/control/logo.js +44 -69
- package/lib/control/mapTheme.d.ts +11 -0
- package/lib/control/mapTheme.js +58 -97
- package/lib/control/mouseLocation.d.ts +16 -0
- package/lib/control/mouseLocation.js +38 -68
- package/lib/control/scale.d.ts +35 -0
- package/lib/control/scale.js +108 -134
- package/lib/control/swipe.d.ts +66 -0
- package/lib/control/swipe.js +298 -392
- package/lib/control/zoom.d.ts +39 -0
- package/lib/control/zoom.js +81 -111
- package/lib/css/index.css +10 -7
- package/lib/index.d.ts +19 -0
- package/lib/index.js +683 -17
- package/lib/interface.d.ts +18 -0
- package/lib/marker-layer.d.ts +55 -0
- package/lib/marker-layer.js +276 -324
- package/lib/marker.d.ts +58 -0
- package/lib/marker.js +395 -452
- package/lib/popup/layerPopup.d.ts +99 -0
- package/lib/popup/layerPopup.js +278 -320
- package/lib/popup/popup.d.ts +142 -0
- package/lib/popup/popup.js +423 -481
- package/lib/utils/anchor.d.ts +22 -0
- package/lib/utils/anchor.js +6 -6
- package/lib/utils/icon.d.ts +1 -0
- package/lib/utils/icon.js +6 -5
- package/lib/utils/popper.d.ts +76 -0
- package/lib/utils/popper.js +184 -196
- package/lib/utils/screenfull.d.ts +2 -0
- package/lib/utils/screenfull.js +29 -52
- package/package.json +16 -20
- package/CHANGELOG.md +0 -325
- 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(
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 =
|
|
14
|
+
if ((_this$controlOption$l = this.controlOption.layers) !== null && _this$controlOption$l !== void 0 && _this$controlOption$l.length) {
|
|
33
15
|
return;
|
|
34
16
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
options:
|
|
17
|
+
this.selectValue = this.getLayerVisible();
|
|
18
|
+
this.setOptions({
|
|
19
|
+
options: this.getLayerOptions()
|
|
38
20
|
});
|
|
39
21
|
});
|
|
40
|
-
_defineProperty(
|
|
41
|
-
|
|
22
|
+
_defineProperty(this, "onLayerVisibleChane", () => {
|
|
23
|
+
this.setSelectValue(this.getLayerVisible());
|
|
42
24
|
});
|
|
43
|
-
_defineProperty(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
171
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
-
|
|
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
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
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
|
+
}
|
package/es/control/logo.js
CHANGED
|
@@ -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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
74
|
-
}(Control);
|
|
75
|
-
export { Logo as default };
|
|
48
|
+
}
|
|
49
|
+
}
|
package/es/control/mapTheme.js
CHANGED
|
@@ -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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
this.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
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
|
+
}
|