@antv/l7-component 2.25.6 → 2.25.7
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/package.json +5 -5
- package/es/assets/iconfont/iconfont.d.ts +0 -21
- package/es/assets/iconfont/iconfont.js +0 -61
- package/es/constants/index.d.ts +0 -60
- package/es/constants/index.js +0 -60
- package/es/control/baseControl/buttonControl.d.ts +0 -60
- package/es/control/baseControl/buttonControl.js +0 -142
- package/es/control/baseControl/control.d.ts +0 -112
- package/es/control/baseControl/control.js +0 -256
- package/es/control/baseControl/index.d.ts +0 -4
- package/es/control/baseControl/index.js +0 -4
- package/es/control/baseControl/popperControl.d.ts +0 -28
- package/es/control/baseControl/popperControl.js +0 -92
- package/es/control/baseControl/selectControl.d.ts +0 -53
- package/es/control/baseControl/selectControl.js +0 -173
- package/es/control/exportImage.d.ts +0 -19
- package/es/control/exportImage.js +0 -73
- package/es/control/fullscreen.d.ts +0 -20
- package/es/control/fullscreen.js +0 -88
- package/es/control/geoLocate.d.ts +0 -17
- package/es/control/geoLocate.js +0 -60
- package/es/control/layerSwitch.d.ts +0 -27
- package/es/control/layerSwitch.js +0 -155
- package/es/control/logo.d.ts +0 -14
- package/es/control/logo.js +0 -49
- package/es/control/mapTheme.d.ts +0 -11
- package/es/control/mapTheme.js +0 -69
- package/es/control/mouseLocation.d.ts +0 -16
- package/es/control/mouseLocation.js +0 -52
- package/es/control/scale.d.ts +0 -35
- package/es/control/scale.js +0 -121
- package/es/control/swipe.d.ts +0 -66
- package/es/control/swipe.js +0 -392
- package/es/control/zoom.d.ts +0 -39
- package/es/control/zoom.js +0 -100
- package/es/css/button.less +0 -77
- package/es/css/control.less +0 -82
- package/es/css/index.css +0 -653
- package/es/css/index.less +0 -13
- package/es/css/l7.less +0 -69
- package/es/css/layerPopup.less +0 -9
- package/es/css/logo.less +0 -21
- package/es/css/mouseLocation.less +0 -9
- package/es/css/popper.less +0 -74
- package/es/css/popup.less +0 -176
- package/es/css/scale.less +0 -37
- package/es/css/select.less +0 -96
- package/es/css/swipe.less +0 -80
- package/es/css/variables.less +0 -29
- package/es/css/zoom.less +0 -34
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +0 -1
- package/es/images/logo.png +0 -0
- package/es/images/quanping.svg +0 -12
- package/es/index.d.ts +0 -19
- package/es/index.js +0 -708
- package/es/interface.d.ts +0 -29
- package/es/interface.js +0 -1
- package/es/marker-layer.d.ts +0 -46
- package/es/marker-layer.js +0 -509
- package/es/marker.d.ts +0 -66
- package/es/marker.js +0 -495
- package/es/popup/layerPopup.d.ts +0 -105
- package/es/popup/layerPopup.js +0 -341
- package/es/popup/popup.d.ts +0 -147
- package/es/popup/popup.js +0 -587
- package/es/utils/anchor.d.ts +0 -22
- package/es/utils/anchor.js +0 -31
- package/es/utils/eventManager.d.ts +0 -42
- package/es/utils/eventManager.js +0 -84
- package/es/utils/icon.d.ts +0 -1
- package/es/utils/icon.js +0 -12
- package/es/utils/popper.d.ts +0 -76
- package/es/utils/popper.js +0 -257
- package/es/utils/screenfull.d.ts +0 -2
- package/es/utils/screenfull.js +0 -106
- package/lib/assets/iconfont/iconfont.d.ts +0 -21
- package/lib/assets/iconfont/iconfont.js +0 -68
- package/lib/constants/index.d.ts +0 -60
- package/lib/constants/index.js +0 -66
- package/lib/control/baseControl/buttonControl.d.ts +0 -60
- package/lib/control/baseControl/buttonControl.js +0 -149
- package/lib/control/baseControl/control.d.ts +0 -112
- package/lib/control/baseControl/control.js +0 -269
- package/lib/control/baseControl/index.d.ts +0 -4
- package/lib/control/baseControl/index.js +0 -39
- package/lib/control/baseControl/popperControl.d.ts +0 -28
- package/lib/control/baseControl/popperControl.js +0 -99
- package/lib/control/baseControl/selectControl.d.ts +0 -53
- package/lib/control/baseControl/selectControl.js +0 -180
- package/lib/control/exportImage.d.ts +0 -19
- package/lib/control/exportImage.js +0 -80
- package/lib/control/fullscreen.d.ts +0 -20
- package/lib/control/fullscreen.js +0 -95
- package/lib/control/geoLocate.d.ts +0 -17
- package/lib/control/geoLocate.js +0 -67
- package/lib/control/layerSwitch.d.ts +0 -27
- package/lib/control/layerSwitch.js +0 -162
- package/lib/control/logo.d.ts +0 -14
- package/lib/control/logo.js +0 -55
- package/lib/control/mapTheme.d.ts +0 -11
- package/lib/control/mapTheme.js +0 -76
- package/lib/control/mouseLocation.d.ts +0 -16
- package/lib/control/mouseLocation.js +0 -59
- package/lib/control/scale.d.ts +0 -35
- package/lib/control/scale.js +0 -128
- package/lib/control/swipe.d.ts +0 -66
- package/lib/control/swipe.js +0 -399
- package/lib/control/zoom.d.ts +0 -39
- package/lib/control/zoom.js +0 -107
- package/lib/css/button.less +0 -77
- package/lib/css/control.less +0 -82
- package/lib/css/index.css +0 -653
- package/lib/css/index.less +0 -13
- package/lib/css/l7.less +0 -69
- package/lib/css/layerPopup.less +0 -9
- package/lib/css/logo.less +0 -21
- package/lib/css/mouseLocation.less +0 -9
- package/lib/css/popper.less +0 -74
- package/lib/css/popup.less +0 -176
- package/lib/css/scale.less +0 -37
- package/lib/css/select.less +0 -96
- package/lib/css/swipe.less +0 -80
- package/lib/css/variables.less +0 -29
- package/lib/css/zoom.less +0 -34
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +0 -1
- package/lib/images/logo.png +0 -0
- package/lib/images/quanping.svg +0 -12
- package/lib/index.d.ts +0 -19
- package/lib/index.js +0 -835
- package/lib/interface.d.ts +0 -29
- package/lib/interface.js +0 -5
- package/lib/marker-layer.d.ts +0 -46
- package/lib/marker-layer.js +0 -518
- package/lib/marker.d.ts +0 -66
- package/lib/marker.js +0 -502
- package/lib/popup/layerPopup.d.ts +0 -105
- package/lib/popup/layerPopup.js +0 -348
- package/lib/popup/popup.d.ts +0 -147
- package/lib/popup/popup.js +0 -594
- package/lib/utils/anchor.d.ts +0 -22
- package/lib/utils/anchor.js +0 -38
- package/lib/utils/eventManager.d.ts +0 -42
- package/lib/utils/eventManager.js +0 -92
- package/lib/utils/icon.d.ts +0 -1
- package/lib/utils/icon.js +0 -19
- package/lib/utils/popper.d.ts +0 -76
- package/lib/utils/popper.js +0 -264
- package/lib/utils/screenfull.d.ts +0 -2
- package/lib/utils/screenfull.js +0 -112
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.ExportImage = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _icon = require("../utils/icon");
|
|
12
|
-
var _buttonControl = _interopRequireDefault(require("./baseControl/buttonControl"));
|
|
13
|
-
class ExportImage extends _buttonControl.default {
|
|
14
|
-
constructor(...args) {
|
|
15
|
-
var _this;
|
|
16
|
-
super(...args);
|
|
17
|
-
_this = this;
|
|
18
|
-
(0, _defineProperty2.default)(this, "onClick", /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
|
|
19
|
-
const {
|
|
20
|
-
onExport
|
|
21
|
-
} = _this.controlOption;
|
|
22
|
-
onExport === null || onExport === void 0 || onExport(yield _this.getImage());
|
|
23
|
-
}));
|
|
24
|
-
/**
|
|
25
|
-
* 将多张图片合并为一张图片
|
|
26
|
-
* @protected
|
|
27
|
-
* @param base64List
|
|
28
|
-
*/
|
|
29
|
-
(0, _defineProperty2.default)(this, "mergeImage", /*#__PURE__*/(0, _asyncToGenerator2.default)(function* (...base64List) {
|
|
30
|
-
var _this$mapsService$get, _this$mapsService$get2;
|
|
31
|
-
const {
|
|
32
|
-
imageType
|
|
33
|
-
} = _this.controlOption;
|
|
34
|
-
const {
|
|
35
|
-
width = 0,
|
|
36
|
-
height = 0
|
|
37
|
-
} = (_this$mapsService$get = (_this$mapsService$get2 = _this.mapsService.getContainer()) === null || _this$mapsService$get2 === void 0 ? void 0 : _this$mapsService$get2.getBoundingClientRect()) !== null && _this$mapsService$get !== void 0 ? _this$mapsService$get : {};
|
|
38
|
-
const canvas = document.createElement('canvas');
|
|
39
|
-
canvas.width = width;
|
|
40
|
-
canvas.height = height;
|
|
41
|
-
const context = canvas.getContext('2d');
|
|
42
|
-
const imgList = yield Promise.all(base64List.map(base64 => {
|
|
43
|
-
return new Promise(resolve => {
|
|
44
|
-
const img = new Image();
|
|
45
|
-
img.onload = () => {
|
|
46
|
-
resolve(img);
|
|
47
|
-
};
|
|
48
|
-
img.src = base64;
|
|
49
|
-
});
|
|
50
|
-
}));
|
|
51
|
-
imgList.forEach(img => {
|
|
52
|
-
context === null || context === void 0 || context.drawImage(img, 0, 0, width, height);
|
|
53
|
-
});
|
|
54
|
-
return canvas.toDataURL(`image/${imageType}`);
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
onAdd() {
|
|
58
|
-
const button = super.onAdd();
|
|
59
|
-
button.addEventListener('click', this.onClick);
|
|
60
|
-
return button;
|
|
61
|
-
}
|
|
62
|
-
getDefault(option) {
|
|
63
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, super.getDefault(option)), {}, {
|
|
64
|
-
title: '导出图片',
|
|
65
|
-
btnIcon: (0, _icon.createL7Icon)('l7-icon-export-picture'),
|
|
66
|
-
imageType: 'png'
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
getImage() {
|
|
70
|
-
var _this2 = this;
|
|
71
|
-
return (0, _asyncToGenerator2.default)(function* () {
|
|
72
|
-
const mapImage = yield _this2.mapsService.exportMap('png');
|
|
73
|
-
const layerImage = yield _this2.scene.exportPng('png');
|
|
74
|
-
return _this2.mergeImage(
|
|
75
|
-
// 在 Map 底图模式下 mapImage 为 undefined
|
|
76
|
-
...[mapImage, layerImage].filter(base64 => base64));
|
|
77
|
-
})();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.default = exports.ExportImage = ExportImage;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { IButtonControlOption } from './baseControl/buttonControl';
|
|
2
|
-
import ButtonControl from './baseControl/buttonControl';
|
|
3
|
-
export interface IFullscreenControlOption extends IButtonControlOption {
|
|
4
|
-
exitBtnText: IButtonControlOption['btnText'];
|
|
5
|
-
exitBtnIcon: IButtonControlOption['btnIcon'];
|
|
6
|
-
exitTitle: IButtonControlOption['title'];
|
|
7
|
-
}
|
|
8
|
-
export { Fullscreen };
|
|
9
|
-
export default class Fullscreen extends ButtonControl<IFullscreenControlOption> {
|
|
10
|
-
protected isFullscreen: boolean;
|
|
11
|
-
protected mapContainer: HTMLElement;
|
|
12
|
-
constructor(option?: Partial<IFullscreenControlOption>);
|
|
13
|
-
setOptions(newOptions: Partial<IFullscreenControlOption>): void;
|
|
14
|
-
onAdd(): HTMLElement;
|
|
15
|
-
onRemove(): void;
|
|
16
|
-
getDefault(option?: Partial<IFullscreenControlOption>): IFullscreenControlOption;
|
|
17
|
-
toggleFullscreen: () => Promise<void>;
|
|
18
|
-
protected onClick: () => void;
|
|
19
|
-
protected onFullscreenChange: () => void;
|
|
20
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.Fullscreen = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
12
|
-
var _icon = require("../utils/icon");
|
|
13
|
-
var _screenfull = _interopRequireDefault(require("../utils/screenfull"));
|
|
14
|
-
var _buttonControl = _interopRequireDefault(require("./baseControl/buttonControl"));
|
|
15
|
-
class Fullscreen extends _buttonControl.default {
|
|
16
|
-
constructor(option) {
|
|
17
|
-
var _this;
|
|
18
|
-
super(option);
|
|
19
|
-
_this = this;
|
|
20
|
-
(0, _defineProperty2.default)(this, "isFullscreen", false);
|
|
21
|
-
(0, _defineProperty2.default)(this, "mapContainer", void 0);
|
|
22
|
-
(0, _defineProperty2.default)(this, "toggleFullscreen", /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
|
|
23
|
-
if (_screenfull.default.isEnabled) {
|
|
24
|
-
yield _screenfull.default.toggle(_this.mapContainer);
|
|
25
|
-
}
|
|
26
|
-
}));
|
|
27
|
-
(0, _defineProperty2.default)(this, "onClick", () => {
|
|
28
|
-
this.toggleFullscreen();
|
|
29
|
-
});
|
|
30
|
-
(0, _defineProperty2.default)(this, "onFullscreenChange", () => {
|
|
31
|
-
this.isFullscreen = !!document.fullscreenElement;
|
|
32
|
-
const {
|
|
33
|
-
btnText,
|
|
34
|
-
btnIcon,
|
|
35
|
-
title,
|
|
36
|
-
exitBtnText,
|
|
37
|
-
exitBtnIcon,
|
|
38
|
-
exitTitle
|
|
39
|
-
} = this.controlOption;
|
|
40
|
-
if (this.isFullscreen) {
|
|
41
|
-
this.setBtnTitle(exitTitle);
|
|
42
|
-
this.setBtnText(exitBtnText);
|
|
43
|
-
this.setBtnIcon(exitBtnIcon);
|
|
44
|
-
} else {
|
|
45
|
-
this.setBtnTitle(title);
|
|
46
|
-
this.setBtnText(btnText);
|
|
47
|
-
this.setBtnIcon(btnIcon);
|
|
48
|
-
}
|
|
49
|
-
this.emit('fullscreenChange', this.isFullscreen);
|
|
50
|
-
});
|
|
51
|
-
if (!_screenfull.default.isEnabled) {
|
|
52
|
-
console.warn('当前浏览器环境不支持对地图全屏化');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
setOptions(newOptions) {
|
|
56
|
-
const {
|
|
57
|
-
exitBtnText,
|
|
58
|
-
exitBtnIcon,
|
|
59
|
-
exitTitle
|
|
60
|
-
} = newOptions;
|
|
61
|
-
if (this.isFullscreen) {
|
|
62
|
-
if (this.checkUpdateOption(newOptions, ['exitBtnIcon'])) {
|
|
63
|
-
this.setBtnIcon(exitBtnIcon);
|
|
64
|
-
}
|
|
65
|
-
if (this.checkUpdateOption(newOptions, ['exitBtnText'])) {
|
|
66
|
-
this.setBtnText(exitBtnText);
|
|
67
|
-
}
|
|
68
|
-
if (this.checkUpdateOption(newOptions, ['exitTitle'])) {
|
|
69
|
-
this.setBtnTitle(exitTitle);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
super.setOptions(newOptions);
|
|
73
|
-
}
|
|
74
|
-
onAdd() {
|
|
75
|
-
const button = super.onAdd();
|
|
76
|
-
button.addEventListener('click', this.onClick);
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
78
|
-
this.mapContainer = _l7Utils.DOM.getContainer(this.scene.getSceneConfig().id);
|
|
79
|
-
this.mapContainer.addEventListener('fullscreenchange', this.onFullscreenChange);
|
|
80
|
-
return button;
|
|
81
|
-
}
|
|
82
|
-
onRemove() {
|
|
83
|
-
super.onRemove();
|
|
84
|
-
this.mapContainer.removeEventListener('fullscreenchange', this.onFullscreenChange);
|
|
85
|
-
}
|
|
86
|
-
getDefault(option) {
|
|
87
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, super.getDefault(option)), {}, {
|
|
88
|
-
title: '全屏',
|
|
89
|
-
btnIcon: (0, _icon.createL7Icon)('l7-icon-fullscreen'),
|
|
90
|
-
exitTitle: '退出全屏',
|
|
91
|
-
exitBtnIcon: (0, _icon.createL7Icon)('l7-icon-exit-fullscreen')
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.default = exports.Fullscreen = Fullscreen;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Point } from '@antv/l7-core';
|
|
2
|
-
import type { IButtonControlOption } from './baseControl/buttonControl';
|
|
3
|
-
import ButtonControl from './baseControl/buttonControl';
|
|
4
|
-
export interface IGeoLocateOption extends IButtonControlOption {
|
|
5
|
-
transform: (position: Point) => Point | Promise<Point>;
|
|
6
|
-
}
|
|
7
|
-
export { GeoLocate };
|
|
8
|
-
export default class GeoLocate extends ButtonControl<IGeoLocateOption> {
|
|
9
|
-
constructor(option?: Partial<IGeoLocateOption>);
|
|
10
|
-
getDefault(option?: Partial<IGeoLocateOption>): IGeoLocateOption;
|
|
11
|
-
onAdd(): HTMLElement;
|
|
12
|
-
/**
|
|
13
|
-
* 通过浏览器 API 获取当前所在经纬度
|
|
14
|
-
*/
|
|
15
|
-
getGeoLocation: () => Promise<Point>;
|
|
16
|
-
onClick: () => Promise<void>;
|
|
17
|
-
}
|
package/lib/control/geoLocate.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.GeoLocate = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _icon = require("../utils/icon");
|
|
12
|
-
var _buttonControl = _interopRequireDefault(require("./baseControl/buttonControl"));
|
|
13
|
-
class GeoLocate extends _buttonControl.default {
|
|
14
|
-
constructor(option) {
|
|
15
|
-
var _this;
|
|
16
|
-
super(option);
|
|
17
|
-
_this = this;
|
|
18
|
-
/**
|
|
19
|
-
* 通过浏览器 API 获取当前所在经纬度
|
|
20
|
-
*/
|
|
21
|
-
(0, _defineProperty2.default)(this, "getGeoLocation", () => {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
window.navigator.geolocation.getCurrentPosition(({
|
|
24
|
-
coords
|
|
25
|
-
}) => {
|
|
26
|
-
const {
|
|
27
|
-
longitude,
|
|
28
|
-
latitude
|
|
29
|
-
} = coords !== null && coords !== void 0 ? coords : {};
|
|
30
|
-
if (!isNaN(longitude) && !isNaN(latitude)) {
|
|
31
|
-
resolve([longitude, latitude]);
|
|
32
|
-
} else {
|
|
33
|
-
reject();
|
|
34
|
-
}
|
|
35
|
-
}, e => {
|
|
36
|
-
reject(e);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
(0, _defineProperty2.default)(this, "onClick", /*#__PURE__*/(0, _asyncToGenerator2.default)(function* () {
|
|
41
|
-
if (!window.navigator.geolocation) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const {
|
|
45
|
-
transform
|
|
46
|
-
} = _this.controlOption;
|
|
47
|
-
const position = yield _this.getGeoLocation();
|
|
48
|
-
const currentZoom = _this.mapsService.getZoom();
|
|
49
|
-
_this.mapsService.setZoomAndCenter(currentZoom > 15 ? currentZoom : 15, transform ? yield transform(position) : position);
|
|
50
|
-
}));
|
|
51
|
-
if (!window.navigator.geolocation) {
|
|
52
|
-
console.warn('当前浏览器环境不支持获取地理定位');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
getDefault(option) {
|
|
56
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, super.getDefault(option)), {}, {
|
|
57
|
-
title: '定位',
|
|
58
|
-
btnIcon: (0, _icon.createL7Icon)('l7-icon-reposition')
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
onAdd() {
|
|
62
|
-
const button = super.onAdd();
|
|
63
|
-
button.addEventListener('click', this.onClick);
|
|
64
|
-
return button;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.default = exports.GeoLocate = GeoLocate;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { ILayer } from '@antv/l7-core';
|
|
2
|
-
import type { ControlOptionItem, ISelectControlOption } from './baseControl/selectControl';
|
|
3
|
-
import SelectControl from './baseControl/selectControl';
|
|
4
|
-
export type LayerSwitchItem = {
|
|
5
|
-
layer: ILayer;
|
|
6
|
-
name?: string;
|
|
7
|
-
img?: string;
|
|
8
|
-
};
|
|
9
|
-
export interface ILayerSwitchOption extends ISelectControlOption {
|
|
10
|
-
layers: Array<ILayer | string | LayerSwitchItem>;
|
|
11
|
-
multiple: boolean;
|
|
12
|
-
}
|
|
13
|
-
export { LayerSwitch };
|
|
14
|
-
export default class LayerSwitch extends SelectControl<ILayerSwitchOption> {
|
|
15
|
-
protected get layers(): ILayer[];
|
|
16
|
-
getDefault(option?: Partial<ILayerSwitchOption>): ILayerSwitchOption;
|
|
17
|
-
getLayerVisible(): string[];
|
|
18
|
-
getLayerOptions(): ControlOptionItem[];
|
|
19
|
-
setOptions(option: Partial<ILayerSwitchOption>): void;
|
|
20
|
-
private handleSingleSelection;
|
|
21
|
-
onAdd(): HTMLElement;
|
|
22
|
-
onRemove(): void;
|
|
23
|
-
protected onLayerChange: () => void;
|
|
24
|
-
protected onLayerVisibleChane: () => void;
|
|
25
|
-
protected onSelectChange: () => void;
|
|
26
|
-
protected getIsMultiple(): boolean;
|
|
27
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.LayerSwitch = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _icon = require("../utils/icon");
|
|
11
|
-
var _selectControl = _interopRequireDefault(require("./baseControl/selectControl"));
|
|
12
|
-
function isLayerSwitchItem(obj) {
|
|
13
|
-
return Object.keys(obj !== null && obj !== void 0 ? obj : {}).every(key => ['layer', 'name', 'img'].includes(key));
|
|
14
|
-
}
|
|
15
|
-
class LayerSwitch extends _selectControl.default {
|
|
16
|
-
constructor(...args) {
|
|
17
|
-
super(...args);
|
|
18
|
-
(0, _defineProperty2.default)(this, "onLayerChange", () => {
|
|
19
|
-
var _this$controlOption$l;
|
|
20
|
-
if ((_this$controlOption$l = this.controlOption.layers) !== null && _this$controlOption$l !== void 0 && _this$controlOption$l.length) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
this.selectValue = this.getLayerVisible();
|
|
24
|
-
this.setOptions({
|
|
25
|
-
options: this.getLayerOptions()
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
(0, _defineProperty2.default)(this, "onLayerVisibleChane", () => {
|
|
29
|
-
this.setSelectValue(this.getLayerVisible());
|
|
30
|
-
});
|
|
31
|
-
(0, _defineProperty2.default)(this, "onSelectChange", () => {
|
|
32
|
-
this.layers.forEach(layer => {
|
|
33
|
-
const needShow = this.selectValue.includes(layer.name);
|
|
34
|
-
const isShow = layer.isVisible();
|
|
35
|
-
if (needShow && !isShow) {
|
|
36
|
-
layer.show();
|
|
37
|
-
}
|
|
38
|
-
if (!needShow && isShow) {
|
|
39
|
-
layer.hide();
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
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);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (typeof layer === 'string') {
|
|
60
|
-
const targetLayer = layerService.getLayer(layer) || layerService.getLayerByName(layer);
|
|
61
|
-
if (targetLayer) {
|
|
62
|
-
layerInstances.push(targetLayer);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return layerInstances;
|
|
67
|
-
}
|
|
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)) {
|
|
90
|
-
return {
|
|
91
|
-
text: layer.name || layer.layer.name,
|
|
92
|
-
value: layer.layer.name,
|
|
93
|
-
img: isAllImg ? layer.img : undefined
|
|
94
|
-
};
|
|
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
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
text: layer.name,
|
|
104
|
-
value: layer.name
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
}
|
|
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) {
|
|
119
|
-
if (this.controlOption.multiple === false) {
|
|
120
|
-
this.handleSingleSelection();
|
|
121
|
-
}
|
|
122
|
-
this.selectValue = this.getLayerVisible();
|
|
123
|
-
this.controlOption.options = this.getLayerOptions();
|
|
124
|
-
this.popper.setContent(this.getPopperContent(this.controlOption.options));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// TODO: 单选模式下,目前默认展示第一项,通过用户提供defaultValue展示默认选项的属性待开发
|
|
129
|
-
// 如果是单选模式,则只显示第一个图层
|
|
130
|
-
handleSingleSelection() {
|
|
131
|
-
this.layers.forEach((layer, index) => {
|
|
132
|
-
if (index === 0) {
|
|
133
|
-
layer.show();
|
|
134
|
-
} else {
|
|
135
|
-
layer.hide();
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
onAdd() {
|
|
140
|
-
var _this$controlOption$o;
|
|
141
|
-
if (this.controlOption.multiple === false) {
|
|
142
|
-
this.handleSingleSelection();
|
|
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
|
-
if (!this.controlOption.defaultValue) {
|
|
148
|
-
this.controlOption.defaultValue = this.getLayerVisible();
|
|
149
|
-
}
|
|
150
|
-
this.on('selectChange', this.onSelectChange);
|
|
151
|
-
this.layerService.on('layerChange', this.onLayerChange);
|
|
152
|
-
return super.onAdd();
|
|
153
|
-
}
|
|
154
|
-
onRemove() {
|
|
155
|
-
this.off('selectChange', this.onSelectChange);
|
|
156
|
-
this.layerService.off('layerChange', this.onLayerChange);
|
|
157
|
-
}
|
|
158
|
-
getIsMultiple() {
|
|
159
|
-
return this.controlOption.multiple;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
exports.default = exports.LayerSwitch = LayerSwitch;
|
package/lib/control/logo.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.Logo = void 0;
|
|
7
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
8
|
-
var _baseControl = require("./baseControl");
|
|
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
|
-
};
|
|
17
|
-
}
|
|
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);
|
|
31
|
-
}
|
|
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);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.default = exports.Logo = Logo;
|
|
@@ -1,11 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.MapTheme = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _constants = require("../constants");
|
|
11
|
-
var _icon = require("../utils/icon");
|
|
12
|
-
var _selectControl = _interopRequireDefault(require("./baseControl/selectControl"));
|
|
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]);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
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();
|
|
51
|
-
}
|
|
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;
|
|
60
|
-
} else {
|
|
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
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
this.on('selectChange', this.onMapThemeChange);
|
|
70
|
-
return super.onAdd();
|
|
71
|
-
}
|
|
72
|
-
getIsMultiple() {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
exports.default = exports.MapTheme = MapTheme;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Position } from '@antv/l7-core';
|
|
2
|
-
import type { IControlOption } from './baseControl/control';
|
|
3
|
-
import Control from './baseControl/control';
|
|
4
|
-
export interface IMouseLocationControlOption extends IControlOption {
|
|
5
|
-
transform: (position: Position) => Position;
|
|
6
|
-
}
|
|
7
|
-
export { MouseLocation };
|
|
8
|
-
export default class MouseLocation extends Control<IMouseLocationControlOption> {
|
|
9
|
-
protected location: Position;
|
|
10
|
-
getLocation(): Position;
|
|
11
|
-
getDefault(option?: Partial<IMouseLocationControlOption>): IMouseLocationControlOption;
|
|
12
|
-
onAdd(): HTMLElement;
|
|
13
|
-
onRemove(): void;
|
|
14
|
-
protected onMouseMove: (e: any) => void;
|
|
15
|
-
protected insertLocation2HTML(position: Position): void;
|
|
16
|
-
}
|