@antv/l7-component 2.9.37 → 2.10.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.
- package/es/assets/iconfont/iconfont.js +53 -0
- package/es/constants/index.d.ts +60 -0
- package/es/constants/index.js +60 -0
- package/es/control/baseControl/buttonControl.d.ts +59 -0
- package/es/control/baseControl/buttonControl.js +191 -0
- package/es/control/baseControl/control.d.ts +113 -0
- package/es/control/baseControl/control.js +313 -0
- package/es/control/baseControl/index.d.ts +4 -0
- package/es/control/baseControl/index.js +4 -0
- package/es/control/baseControl/popperControl.d.ts +26 -0
- package/es/control/baseControl/popperControl.js +131 -0
- package/es/control/baseControl/selectControl.d.ts +46 -0
- package/es/control/baseControl/selectControl.js +232 -0
- package/es/control/exportImage.d.ts +18 -0
- package/es/control/exportImage.js +163 -0
- package/es/control/fullscreen.d.ts +19 -0
- package/es/control/fullscreen.js +151 -0
- package/es/control/geoLocate.d.ts +16 -0
- package/es/control/geoLocate.js +139 -0
- package/es/control/layerSwitch.d.ts +19 -0
- package/es/control/layerSwitch.js +172 -0
- package/es/control/logo.d.ts +10 -6
- package/es/control/logo.js +41 -11
- package/es/control/mapTheme.d.ts +10 -0
- package/es/control/mapTheme.js +135 -0
- package/es/control/mouseLocation.d.ts +15 -0
- package/es/control/mouseLocation.js +104 -0
- package/es/control/scale.d.ts +20 -10
- package/es/control/scale.js +77 -53
- package/es/control/zoom.d.ts +21 -10
- package/es/control/zoom.js +76 -49
- package/es/css/button.less +70 -0
- package/es/css/control.less +71 -0
- package/es/css/index.css +567 -0
- package/es/css/index.less +12 -0
- package/es/css/l7.less +60 -0
- package/es/css/layerPopup.less +8 -0
- package/es/css/logo.less +18 -0
- package/es/css/mouseLocation.less +9 -0
- package/es/css/popper.less +64 -0
- package/es/css/popup.less +169 -0
- package/es/css/scale.less +34 -0
- package/es/css/select.less +86 -0
- package/es/css/variables.less +28 -0
- package/es/css/zoom.less +21 -0
- package/es/images/logo.png +0 -0
- package/es/images/quanping.svg +12 -0
- package/es/index.d.ts +15 -8
- package/es/index.js +15 -9
- package/es/interface.d.ts +1 -20
- package/es/popup/layerPopup.d.ts +78 -0
- package/es/popup/layerPopup.js +308 -0
- package/es/popup/popup.d.ts +147 -0
- package/es/popup/popup.js +636 -0
- package/es/utils/icon.d.ts +1 -0
- package/es/utils/icon.js +9 -0
- package/es/utils/popper.d.ts +75 -0
- package/es/utils/popper.js +286 -0
- package/es/utils/screenfull.d.ts +2 -0
- package/es/utils/screenfull.js +157 -0
- package/lib/assets/iconfont/iconfont.js +55 -0
- package/lib/constants/index.js +68 -0
- package/lib/control/baseControl/buttonControl.js +207 -0
- package/lib/control/baseControl/control.js +340 -0
- package/lib/control/baseControl/index.js +57 -0
- package/lib/control/baseControl/popperControl.js +142 -0
- package/lib/control/baseControl/selectControl.js +253 -0
- package/lib/control/exportImage.js +177 -0
- package/lib/control/fullscreen.js +164 -0
- package/lib/control/geoLocate.js +154 -0
- package/lib/control/layerSwitch.js +183 -0
- package/lib/control/logo.js +50 -23
- package/lib/control/mapTheme.js +151 -0
- package/lib/control/mouseLocation.js +120 -0
- package/lib/control/scale.js +82 -62
- package/lib/control/zoom.js +78 -59
- package/lib/css/button.less +70 -0
- package/lib/css/control.less +71 -0
- package/lib/css/index.css +567 -0
- package/lib/css/index.less +12 -0
- package/lib/css/l7.less +60 -0
- package/lib/css/layerPopup.less +8 -0
- package/lib/css/logo.less +18 -0
- package/lib/css/mouseLocation.less +9 -0
- package/lib/css/popper.less +64 -0
- package/lib/css/popup.less +169 -0
- package/lib/css/scale.less +34 -0
- package/lib/css/select.less +86 -0
- package/lib/css/variables.less +28 -0
- package/lib/css/zoom.less +21 -0
- package/lib/images/logo.png +0 -0
- package/lib/images/quanping.svg +12 -0
- package/lib/index.js +165 -50
- package/lib/popup/layerPopup.js +317 -0
- package/lib/popup/popup.js +651 -0
- package/lib/utils/icon.js +18 -0
- package/lib/utils/popper.js +297 -0
- package/lib/utils/screenfull.js +167 -0
- package/package.json +8 -5
- package/es/control/BaseControl.d.ts +0 -27
- package/es/control/BaseControl.js +0 -134
- package/es/control/layer.d.ts +0 -38
- package/es/control/layer.js +0 -340
- package/es/css/l7.css +0 -502
- package/es/popup.d.ts +0 -35
- package/es/popup.js +0 -300
- package/lib/control/BaseControl.js +0 -160
- package/lib/control/layer.js +0 -362
- package/lib/css/l7.css +0 -502
- package/lib/popup.js +0 -317
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
+
import _get from "@babel/runtime/helpers/get";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
9
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
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
|
+
|
|
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
|
+
|
|
17
|
+
import { isNaN } from 'lodash';
|
|
18
|
+
import { createL7Icon } from "../utils/icon";
|
|
19
|
+
import ButtonControl from "./baseControl/buttonControl";
|
|
20
|
+
export { GeoLocate };
|
|
21
|
+
|
|
22
|
+
var GeoLocate = /*#__PURE__*/function (_ButtonControl) {
|
|
23
|
+
_inherits(GeoLocate, _ButtonControl);
|
|
24
|
+
|
|
25
|
+
var _super = _createSuper(GeoLocate);
|
|
26
|
+
|
|
27
|
+
function GeoLocate(option) {
|
|
28
|
+
var _this;
|
|
29
|
+
|
|
30
|
+
_classCallCheck(this, GeoLocate);
|
|
31
|
+
|
|
32
|
+
_this = _super.call(this, option);
|
|
33
|
+
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "getGeoLocation", function () {
|
|
35
|
+
return new Promise(function (resolve, reject) {
|
|
36
|
+
window.navigator.geolocation.getCurrentPosition(function (_ref) {
|
|
37
|
+
var coords = _ref.coords;
|
|
38
|
+
|
|
39
|
+
var _ref2 = coords !== null && coords !== void 0 ? coords : {},
|
|
40
|
+
longitude = _ref2.longitude,
|
|
41
|
+
latitude = _ref2.latitude;
|
|
42
|
+
|
|
43
|
+
if (!isNaN(longitude) && !isNaN(latitude)) {
|
|
44
|
+
resolve([longitude, latitude]);
|
|
45
|
+
} else {
|
|
46
|
+
reject();
|
|
47
|
+
}
|
|
48
|
+
}, function (e) {
|
|
49
|
+
reject(e);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "onClick", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
55
|
+
var transform, position, currentZoom;
|
|
56
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
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;
|
|
89
|
+
break;
|
|
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
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}, _callee);
|
|
105
|
+
})));
|
|
106
|
+
|
|
107
|
+
if (!window.navigator.geolocation) {
|
|
108
|
+
console.warn('当前浏览器环境不支持获取地理定位');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return _this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_createClass(GeoLocate, [{
|
|
115
|
+
key: "getDefault",
|
|
116
|
+
value: function getDefault(option) {
|
|
117
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(GeoLocate.prototype), "getDefault", this).call(this, option)), {}, {
|
|
118
|
+
title: '定位',
|
|
119
|
+
btnIcon: createL7Icon('l7-icon-reposition')
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "onAdd",
|
|
124
|
+
value: function onAdd() {
|
|
125
|
+
var button = _get(_getPrototypeOf(GeoLocate.prototype), "onAdd", this).call(this);
|
|
126
|
+
|
|
127
|
+
button.addEventListener('click', this.onClick);
|
|
128
|
+
return button;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 通过浏览器 API 获取当前所在经纬度
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
}]);
|
|
135
|
+
|
|
136
|
+
return GeoLocate;
|
|
137
|
+
}(ButtonControl);
|
|
138
|
+
|
|
139
|
+
export { GeoLocate as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ILayer } from '@antv/l7-core';
|
|
2
|
+
import SelectControl, { ControlOptionItem, ISelectControlOption } from './baseControl/selectControl';
|
|
3
|
+
export interface ILayerSwitchOption extends ISelectControlOption {
|
|
4
|
+
layers: Array<ILayer | string>;
|
|
5
|
+
}
|
|
6
|
+
export { LayerSwitch };
|
|
7
|
+
export default class LayerSwitch extends SelectControl<ILayerSwitchOption> {
|
|
8
|
+
protected get layers(): ILayer[];
|
|
9
|
+
getDefault(option?: Partial<ILayerSwitchOption>): ILayerSwitchOption;
|
|
10
|
+
getLayerVisible(): string[];
|
|
11
|
+
getLayerOptions(): ControlOptionItem[];
|
|
12
|
+
setOptions(option: Partial<ILayerSwitchOption>): void;
|
|
13
|
+
onAdd(): HTMLElement;
|
|
14
|
+
onRemove(): void;
|
|
15
|
+
protected onLayerChange: () => void;
|
|
16
|
+
protected onLayerVisibleChane: () => void;
|
|
17
|
+
protected onSelectChange: () => void;
|
|
18
|
+
protected getIsMultiple(): boolean;
|
|
19
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
+
import _get from "@babel/runtime/helpers/get";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
|
|
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
|
+
|
|
15
|
+
import { createL7Icon } from "../utils/icon";
|
|
16
|
+
import SelectControl from "./baseControl/selectControl";
|
|
17
|
+
export { LayerSwitch };
|
|
18
|
+
|
|
19
|
+
var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
|
|
20
|
+
_inherits(LayerSwitch, _SelectControl);
|
|
21
|
+
|
|
22
|
+
var _super = _createSuper(LayerSwitch);
|
|
23
|
+
|
|
24
|
+
function LayerSwitch() {
|
|
25
|
+
var _this;
|
|
26
|
+
|
|
27
|
+
_classCallCheck(this, LayerSwitch);
|
|
28
|
+
|
|
29
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
|
+
args[_key] = arguments[_key];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
+
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "onLayerChange", function () {
|
|
36
|
+
var _this$controlOption$l;
|
|
37
|
+
|
|
38
|
+
if ((_this$controlOption$l = _this.controlOption.layers) !== null && _this$controlOption$l !== void 0 && _this$controlOption$l.length) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_this.selectValue = _this.getLayerVisible();
|
|
43
|
+
|
|
44
|
+
_this.setOptions({
|
|
45
|
+
options: _this.getLayerOptions()
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "onLayerVisibleChane", function () {
|
|
50
|
+
_this.setSelectValue(_this.getLayerVisible());
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
_defineProperty(_assertThisInitialized(_this), "onSelectChange", function () {
|
|
54
|
+
_this.layers.forEach(function (layer) {
|
|
55
|
+
var needShow = _this.selectValue.includes(layer.name);
|
|
56
|
+
|
|
57
|
+
var isShow = layer.isVisible();
|
|
58
|
+
|
|
59
|
+
if (needShow && !isShow) {
|
|
60
|
+
layer.show();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!needShow && isShow) {
|
|
64
|
+
layer.hide();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_createClass(LayerSwitch, [{
|
|
73
|
+
key: "layers",
|
|
74
|
+
get: function get() {
|
|
75
|
+
var layerService = this.layerService;
|
|
76
|
+
var layers = this.controlOption.layers;
|
|
77
|
+
|
|
78
|
+
if (Array.isArray(layers) && layers.length) {
|
|
79
|
+
var layerInstances = [];
|
|
80
|
+
layers.forEach(function (layer) {
|
|
81
|
+
if (layer instanceof Object) {
|
|
82
|
+
layerInstances.push(layer);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (typeof layer === 'string') {
|
|
86
|
+
var targetLayer = layerService.getLayer(layer) || layerService.getLayerByName(layer);
|
|
87
|
+
|
|
88
|
+
if (targetLayer) {
|
|
89
|
+
layerInstances.push(targetLayer);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return layerInstances;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return layerService.getLayers() || [];
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "getDefault",
|
|
100
|
+
value: function getDefault(option) {
|
|
101
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(LayerSwitch.prototype), "getDefault", this).call(this, option)), {}, {
|
|
102
|
+
title: '图层控制',
|
|
103
|
+
btnIcon: createL7Icon('l7-icon-layer'),
|
|
104
|
+
options: []
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
key: "getLayerVisible",
|
|
109
|
+
value: function getLayerVisible() {
|
|
110
|
+
return this.layers.filter(function (layer) {
|
|
111
|
+
return layer.isVisible();
|
|
112
|
+
}).map(function (layer) {
|
|
113
|
+
return layer.name;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}, {
|
|
117
|
+
key: "getLayerOptions",
|
|
118
|
+
value: function getLayerOptions() {
|
|
119
|
+
return this.layers.map(function (layer) {
|
|
120
|
+
return {
|
|
121
|
+
text: layer.name,
|
|
122
|
+
value: layer.name
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "setOptions",
|
|
128
|
+
value: function setOptions(option) {
|
|
129
|
+
var isLayerChange = this.checkUpdateOption(option, ['layers']);
|
|
130
|
+
|
|
131
|
+
_get(_getPrototypeOf(LayerSwitch.prototype), "setOptions", this).call(this, option);
|
|
132
|
+
|
|
133
|
+
if (isLayerChange) {
|
|
134
|
+
this.selectValue = this.getLayerVisible();
|
|
135
|
+
this.controlOption.options = this.getLayerOptions();
|
|
136
|
+
this.popper.setContent(this.getPopperContent(this.controlOption.options));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "onAdd",
|
|
141
|
+
value: function onAdd() {
|
|
142
|
+
var _this$controlOption$o;
|
|
143
|
+
|
|
144
|
+
if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
|
|
145
|
+
this.controlOption.options = this.getLayerOptions();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (!this.controlOption.defaultValue) {
|
|
149
|
+
this.controlOption.defaultValue = this.getLayerVisible();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
this.on('selectChange', this.onSelectChange);
|
|
153
|
+
this.layerService.on('layerChange', this.onLayerChange);
|
|
154
|
+
return _get(_getPrototypeOf(LayerSwitch.prototype), "onAdd", this).call(this);
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "onRemove",
|
|
158
|
+
value: function onRemove() {
|
|
159
|
+
this.off('selectChange', this.onSelectChange);
|
|
160
|
+
this.layerService.off('layerChange', this.onLayerChange);
|
|
161
|
+
}
|
|
162
|
+
}, {
|
|
163
|
+
key: "getIsMultiple",
|
|
164
|
+
value: function getIsMultiple() {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
}]);
|
|
168
|
+
|
|
169
|
+
return LayerSwitch;
|
|
170
|
+
}(SelectControl);
|
|
171
|
+
|
|
172
|
+
export { LayerSwitch as default };
|
package/es/control/logo.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import Control,
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Control, IControlOption } from './baseControl';
|
|
2
|
+
export interface ILogoControlOption extends IControlOption {
|
|
3
|
+
img: string;
|
|
4
|
+
href?: string | null;
|
|
5
|
+
}
|
|
6
|
+
export { Logo };
|
|
7
|
+
export default class Logo extends Control<ILogoControlOption> {
|
|
8
|
+
getDefault(): ILogoControlOption;
|
|
7
9
|
onAdd(): any;
|
|
8
10
|
onRemove(): null;
|
|
11
|
+
setOptions(option: Partial<ILogoControlOption>): void;
|
|
12
|
+
protected setLogoContent(container: HTMLElement): void;
|
|
9
13
|
}
|
package/es/control/logo.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _get from "@babel/runtime/helpers/get";
|
|
3
4
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
@@ -9,7 +10,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
9
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; } }
|
|
10
11
|
|
|
11
12
|
import { DOM } from '@antv/l7-utils';
|
|
12
|
-
import Control,
|
|
13
|
+
import { Control, PositionType } from "./baseControl";
|
|
14
|
+
export { Logo };
|
|
13
15
|
|
|
14
16
|
var Logo = /*#__PURE__*/function (_Control) {
|
|
15
17
|
_inherits(Logo, _Control);
|
|
@@ -27,21 +29,16 @@ var Logo = /*#__PURE__*/function (_Control) {
|
|
|
27
29
|
value: function getDefault() {
|
|
28
30
|
return {
|
|
29
31
|
position: PositionType.BOTTOMLEFT,
|
|
30
|
-
name: 'logo'
|
|
32
|
+
name: 'logo',
|
|
33
|
+
href: 'https://l7.antv.vision/',
|
|
34
|
+
img: 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*GRb1TKp4HcMAAAAAAAAAAAAAARQnAQ'
|
|
31
35
|
};
|
|
32
36
|
}
|
|
33
37
|
}, {
|
|
34
38
|
key: "onAdd",
|
|
35
39
|
value: function onAdd() {
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var anchor = DOM.create('a', 'l7-ctrl-logo');
|
|
39
|
-
anchor.target = '_blank';
|
|
40
|
-
anchor.rel = 'noopener nofollow';
|
|
41
|
-
anchor.href = 'https://antv.alipay.com/l7';
|
|
42
|
-
anchor.setAttribute('aria-label', 'AntV logo');
|
|
43
|
-
anchor.setAttribute('rel', 'noopener nofollow');
|
|
44
|
-
container.appendChild(anchor);
|
|
40
|
+
var container = DOM.create('div', 'l7-control-logo');
|
|
41
|
+
this.setLogoContent(container);
|
|
45
42
|
return container;
|
|
46
43
|
}
|
|
47
44
|
}, {
|
|
@@ -49,6 +46,39 @@ var Logo = /*#__PURE__*/function (_Control) {
|
|
|
49
46
|
value: function onRemove() {
|
|
50
47
|
return null;
|
|
51
48
|
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "setOptions",
|
|
51
|
+
value: function setOptions(option) {
|
|
52
|
+
_get(_getPrototypeOf(Logo.prototype), "setOptions", this).call(this, option);
|
|
53
|
+
|
|
54
|
+
if (this.checkUpdateOption(option, ['img', 'href'])) {
|
|
55
|
+
DOM.clearChildren(this.container);
|
|
56
|
+
this.setLogoContent(this.container);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
key: "setLogoContent",
|
|
61
|
+
value: function setLogoContent(container) {
|
|
62
|
+
var _this$controlOption = this.controlOption,
|
|
63
|
+
href = _this$controlOption.href,
|
|
64
|
+
img = _this$controlOption.img;
|
|
65
|
+
var imgDOM = DOM.create('img');
|
|
66
|
+
imgDOM.setAttribute('src', img);
|
|
67
|
+
imgDOM.setAttribute('aria-label', 'AntV logo');
|
|
68
|
+
DOM.setUnDraggable(imgDOM);
|
|
69
|
+
|
|
70
|
+
if (href) {
|
|
71
|
+
var anchorDOM = DOM.create('a', 'l7-control-logo-link');
|
|
72
|
+
anchorDOM.target = '_blank';
|
|
73
|
+
anchorDOM.href = href;
|
|
74
|
+
anchorDOM.rel = 'noopener nofollow';
|
|
75
|
+
anchorDOM.setAttribute('rel', 'noopener nofollow');
|
|
76
|
+
anchorDOM.appendChild(imgDOM);
|
|
77
|
+
container.appendChild(anchorDOM);
|
|
78
|
+
} else {
|
|
79
|
+
container.appendChild(imgDOM);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
52
82
|
}]);
|
|
53
83
|
|
|
54
84
|
return Logo;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import SelectControl, { ControlOptionItem, ISelectControlOption } from './baseControl/selectControl';
|
|
2
|
+
export { MapTheme };
|
|
3
|
+
export default class MapTheme extends SelectControl<ISelectControlOption> {
|
|
4
|
+
getDefault(option?: Partial<ISelectControlOption>): ISelectControlOption;
|
|
5
|
+
getStyleOptions(): ControlOptionItem[];
|
|
6
|
+
getMapStyle(): any;
|
|
7
|
+
onAdd(): HTMLElement;
|
|
8
|
+
protected onMapThemeChange: () => void;
|
|
9
|
+
protected getIsMultiple(): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
+
import _get from "@babel/runtime/helpers/get";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
9
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
|
|
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
|
+
|
|
16
|
+
import { GaodeMapStyleConfig, MapboxMapStyleConfig } from "../constants";
|
|
17
|
+
import { createL7Icon } from "../utils/icon";
|
|
18
|
+
import SelectControl from "./baseControl/selectControl";
|
|
19
|
+
export { MapTheme };
|
|
20
|
+
|
|
21
|
+
var MapTheme = /*#__PURE__*/function (_SelectControl) {
|
|
22
|
+
_inherits(MapTheme, _SelectControl);
|
|
23
|
+
|
|
24
|
+
var _super = _createSuper(MapTheme);
|
|
25
|
+
|
|
26
|
+
function MapTheme() {
|
|
27
|
+
var _this;
|
|
28
|
+
|
|
29
|
+
_classCallCheck(this, MapTheme);
|
|
30
|
+
|
|
31
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
32
|
+
args[_key] = arguments[_key];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
36
|
+
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "onMapThemeChange", function () {
|
|
38
|
+
_this.mapsService.setMapStyle(_this.selectValue[0]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return _this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
_createClass(MapTheme, [{
|
|
45
|
+
key: "getDefault",
|
|
46
|
+
value: function getDefault(option) {
|
|
47
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(MapTheme.prototype), "getDefault", this).call(this, option)), {}, {
|
|
48
|
+
title: '地图样式',
|
|
49
|
+
btnIcon: createL7Icon('l7-icon-color'),
|
|
50
|
+
options: []
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
key: "getStyleOptions",
|
|
55
|
+
value: function getStyleOptions() {
|
|
56
|
+
var mapStyleConfig = this.mapsService.getType() === 'mapbox' ? MapboxMapStyleConfig : GaodeMapStyleConfig;
|
|
57
|
+
return Object.entries(this.mapsService.getMapStyleConfig()).filter(function (_ref) {
|
|
58
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
59
|
+
key = _ref2[0],
|
|
60
|
+
value = _ref2[1];
|
|
61
|
+
|
|
62
|
+
return typeof value === 'string' && key !== 'blank';
|
|
63
|
+
}).map(function (_ref3) {
|
|
64
|
+
var _mapStyleConfig$key;
|
|
65
|
+
|
|
66
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
67
|
+
key = _ref4[0],
|
|
68
|
+
value = _ref4[1];
|
|
69
|
+
|
|
70
|
+
// @ts-ignore
|
|
71
|
+
var _ref5 = (_mapStyleConfig$key = mapStyleConfig[key]) !== null && _mapStyleConfig$key !== void 0 ? _mapStyleConfig$key : {},
|
|
72
|
+
text = _ref5.text,
|
|
73
|
+
img = _ref5.img;
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
text: text !== null && text !== void 0 ? text : key,
|
|
77
|
+
value: value,
|
|
78
|
+
img: img,
|
|
79
|
+
key: key
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
key: "getMapStyle",
|
|
85
|
+
value: function getMapStyle() {
|
|
86
|
+
return this.mapsService.getMapStyle();
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "onAdd",
|
|
90
|
+
value: function onAdd() {
|
|
91
|
+
var _this$controlOption$o,
|
|
92
|
+
_this2 = this;
|
|
93
|
+
|
|
94
|
+
if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
|
|
95
|
+
this.controlOption.options = this.getStyleOptions();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (this.controlOption.defaultValue) {
|
|
99
|
+
var _this$controlOption$o2, _this$controlOption$o3;
|
|
100
|
+
|
|
101
|
+
var defaultValue = this.controlOption.defaultValue;
|
|
102
|
+
this.controlOption.defaultValue = (_this$controlOption$o2 = (_this$controlOption$o3 = this.controlOption.options.find(function (item) {
|
|
103
|
+
return item.key === defaultValue;
|
|
104
|
+
})) === null || _this$controlOption$o3 === void 0 ? void 0 : _this$controlOption$o3.value) !== null && _this$controlOption$o2 !== void 0 ? _this$controlOption$o2 : defaultValue;
|
|
105
|
+
} else {
|
|
106
|
+
var defaultStyle = this.getMapStyle();
|
|
107
|
+
|
|
108
|
+
if (defaultStyle) {
|
|
109
|
+
this.controlOption.defaultValue = defaultStyle;
|
|
110
|
+
} else {
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
this.mapsService.map.once('styledata', function () {
|
|
113
|
+
var mapboxStyle = _this2.mapsService.getMapStyle();
|
|
114
|
+
|
|
115
|
+
_this2.controlOption.defaultValue = mapboxStyle;
|
|
116
|
+
|
|
117
|
+
_this2.setSelectValue(mapboxStyle, false);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.on('selectChange', this.onMapThemeChange);
|
|
123
|
+
return _get(_getPrototypeOf(MapTheme.prototype), "onAdd", this).call(this);
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "getIsMultiple",
|
|
127
|
+
value: function getIsMultiple() {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}]);
|
|
131
|
+
|
|
132
|
+
return MapTheme;
|
|
133
|
+
}(SelectControl);
|
|
134
|
+
|
|
135
|
+
export { MapTheme as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Position } from '@antv/l7-core';
|
|
2
|
+
import Control, { IControlOption } from './baseControl/control';
|
|
3
|
+
export interface IMouseLocationControlOption extends IControlOption {
|
|
4
|
+
transform: (position: Position) => Position;
|
|
5
|
+
}
|
|
6
|
+
export { MouseLocation };
|
|
7
|
+
export default class MouseLocation extends Control<IMouseLocationControlOption> {
|
|
8
|
+
protected location: Position;
|
|
9
|
+
getLocation(): Position;
|
|
10
|
+
getDefault(option?: Partial<IMouseLocationControlOption>): IMouseLocationControlOption;
|
|
11
|
+
onAdd(): HTMLElement;
|
|
12
|
+
onRemove(): void;
|
|
13
|
+
protected onMouseMove: (e: any) => void;
|
|
14
|
+
protected insertLocation2HTML(position: Position): void;
|
|
15
|
+
}
|