@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
|
@@ -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(
|
|
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
|
-
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
|
|
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 =
|
|
20
|
+
if ((_this$controlOption$l = this.controlOption.layers) !== null && _this$controlOption$l !== void 0 && _this$controlOption$l.length) {
|
|
39
21
|
return;
|
|
40
22
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
options:
|
|
23
|
+
this.selectValue = this.getLayerVisible();
|
|
24
|
+
this.setOptions({
|
|
25
|
+
options: this.getLayerOptions()
|
|
44
26
|
});
|
|
45
27
|
});
|
|
46
|
-
(0, _defineProperty2.default)(
|
|
47
|
-
|
|
28
|
+
(0, _defineProperty2.default)(this, "onLayerVisibleChane", () => {
|
|
29
|
+
this.setSelectValue(this.getLayerVisible());
|
|
48
30
|
});
|
|
49
|
-
(0, _defineProperty2.default)(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
177
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
194
|
-
value: function getIsMultiple() {
|
|
195
|
-
return this.controlOption.multiple;
|
|
143
|
+
if (!this.controlOption.defaultValue) {
|
|
144
|
+
this.controlOption.defaultValue = this.getLayerVisible();
|
|
196
145
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
+
}
|
package/lib/control/logo.js
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
80
|
-
|
|
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
|
+
}
|
package/lib/control/mapTheme.js
CHANGED
|
@@ -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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
(
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
this.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
69
|
+
this.on('selectChange', this.onMapThemeChange);
|
|
70
|
+
return super.onAdd();
|
|
71
|
+
}
|
|
72
|
+
getIsMultiple() {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.default = exports.MapTheme = MapTheme;
|