@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
|
@@ -5,157 +5,76 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.ExportImage = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
18
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
20
11
|
var _icon = require("../utils/icon");
|
|
21
12
|
var _buttonControl = _interopRequireDefault(require("./baseControl/buttonControl"));
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
var ExportImage = exports.default = exports.ExportImage = /*#__PURE__*/function (_ButtonControl) {
|
|
25
|
-
(0, _inherits2.default)(ExportImage, _ButtonControl);
|
|
26
|
-
var _super = _createSuper(ExportImage);
|
|
27
|
-
function ExportImage() {
|
|
13
|
+
class ExportImage extends _buttonControl.default {
|
|
14
|
+
constructor(...args) {
|
|
28
15
|
var _this;
|
|
29
|
-
(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
while (1) switch (_context.prev = _context.next) {
|
|
38
|
-
case 0:
|
|
39
|
-
onExport = _this.controlOption.onExport;
|
|
40
|
-
_context.t0 = onExport === null || onExport === void 0;
|
|
41
|
-
if (_context.t0) {
|
|
42
|
-
_context.next = 8;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
_context.t1 = onExport;
|
|
46
|
-
_context.next = 6;
|
|
47
|
-
return _this.getImage();
|
|
48
|
-
case 6:
|
|
49
|
-
_context.t2 = _context.sent;
|
|
50
|
-
(0, _context.t1)(_context.t2);
|
|
51
|
-
case 8:
|
|
52
|
-
case "end":
|
|
53
|
-
return _context.stop();
|
|
54
|
-
}
|
|
55
|
-
}, _callee);
|
|
56
|
-
})));
|
|
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
|
+
}));
|
|
57
24
|
/**
|
|
58
25
|
* 将多张图片合并为一张图片
|
|
59
26
|
* @protected
|
|
60
27
|
* @param base64List
|
|
61
28
|
*/
|
|
62
|
-
(0, _defineProperty2.default)(
|
|
29
|
+
(0, _defineProperty2.default)(this, "mergeImage", /*#__PURE__*/(0, _asyncToGenerator2.default)(function* (...base64List) {
|
|
63
30
|
var _this$mapsService$get, _this$mapsService$get2;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
height
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
canvas.width = width;
|
|
84
|
-
canvas.height = height;
|
|
85
|
-
context = canvas.getContext('2d');
|
|
86
|
-
for (_len2 = _args2.length, base64List = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
87
|
-
base64List[_key2] = _args2[_key2];
|
|
88
|
-
}
|
|
89
|
-
_context2.next = 9;
|
|
90
|
-
return Promise.all(base64List.map(function (base64) {
|
|
91
|
-
return new Promise(function (resolve) {
|
|
92
|
-
var img = new Image();
|
|
93
|
-
img.onload = function () {
|
|
94
|
-
resolve(img);
|
|
95
|
-
};
|
|
96
|
-
img.src = base64;
|
|
97
|
-
});
|
|
98
|
-
}));
|
|
99
|
-
case 9:
|
|
100
|
-
imgList = _context2.sent;
|
|
101
|
-
imgList.forEach(function (img) {
|
|
102
|
-
context === null || context === void 0 || context.drawImage(img, 0, 0, width, height);
|
|
103
|
-
});
|
|
104
|
-
return _context2.abrupt("return", canvas.toDataURL("image/".concat(imageType)));
|
|
105
|
-
case 12:
|
|
106
|
-
case "end":
|
|
107
|
-
return _context2.stop();
|
|
108
|
-
}
|
|
109
|
-
}, _callee2);
|
|
110
|
-
})));
|
|
111
|
-
return _this;
|
|
112
|
-
}
|
|
113
|
-
(0, _createClass2.default)(ExportImage, [{
|
|
114
|
-
key: "onAdd",
|
|
115
|
-
value: function onAdd() {
|
|
116
|
-
var button = (0, _get2.default)((0, _getPrototypeOf2.default)(ExportImage.prototype), "onAdd", this).call(this);
|
|
117
|
-
button.addEventListener('click', this.onClick);
|
|
118
|
-
return button;
|
|
119
|
-
}
|
|
120
|
-
}, {
|
|
121
|
-
key: "getDefault",
|
|
122
|
-
value: function getDefault(option) {
|
|
123
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(ExportImage.prototype), "getDefault", this).call(this, option)), {}, {
|
|
124
|
-
title: '导出图片',
|
|
125
|
-
btnIcon: (0, _icon.createL7Icon)('l7-icon-export-picture'),
|
|
126
|
-
imageType: 'png'
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "getImage",
|
|
131
|
-
value: function () {
|
|
132
|
-
var _getImage = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
133
|
-
var mapImage, layerImage;
|
|
134
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
135
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
136
|
-
case 0:
|
|
137
|
-
_context3.next = 2;
|
|
138
|
-
return this.mapsService.exportMap('png');
|
|
139
|
-
case 2:
|
|
140
|
-
mapImage = _context3.sent;
|
|
141
|
-
_context3.next = 5;
|
|
142
|
-
return this.scene.exportPng('png');
|
|
143
|
-
case 5:
|
|
144
|
-
layerImage = _context3.sent;
|
|
145
|
-
return _context3.abrupt("return", this.mergeImage.apply(this, (0, _toConsumableArray2.default)([mapImage, layerImage].filter(function (base64) {
|
|
146
|
-
return base64;
|
|
147
|
-
}))));
|
|
148
|
-
case 7:
|
|
149
|
-
case "end":
|
|
150
|
-
return _context3.stop();
|
|
151
|
-
}
|
|
152
|
-
}, _callee3, this);
|
|
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
|
+
});
|
|
153
50
|
}));
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
return
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
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;
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -5,120 +5,91 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.Fullscreen = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
14
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
15
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
18
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
11
|
var _l7Utils = require("@antv/l7-utils");
|
|
20
12
|
var _icon = require("../utils/icon");
|
|
21
13
|
var _screenfull = _interopRequireDefault(require("../utils/screenfull"));
|
|
22
14
|
var _buttonControl = _interopRequireDefault(require("./baseControl/buttonControl"));
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var Fullscreen = exports.default = exports.Fullscreen = /*#__PURE__*/function (_ButtonControl) {
|
|
26
|
-
(0, _inherits2.default)(Fullscreen, _ButtonControl);
|
|
27
|
-
var _super = _createSuper(Fullscreen);
|
|
28
|
-
function Fullscreen(option) {
|
|
15
|
+
class Fullscreen extends _buttonControl.default {
|
|
16
|
+
constructor(option) {
|
|
29
17
|
var _this;
|
|
30
|
-
(
|
|
31
|
-
_this =
|
|
32
|
-
(0, _defineProperty2.default)(
|
|
33
|
-
(0, _defineProperty2.default)(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
_context.next = 3;
|
|
42
|
-
return _screenfull.default.toggle(_this.mapContainer);
|
|
43
|
-
case 3:
|
|
44
|
-
case "end":
|
|
45
|
-
return _context.stop();
|
|
46
|
-
}
|
|
47
|
-
}, _callee);
|
|
48
|
-
})));
|
|
49
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClick", function () {
|
|
50
|
-
_this.toggleFullscreen();
|
|
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();
|
|
51
29
|
});
|
|
52
|
-
(0, _defineProperty2.default)(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
btnText
|
|
56
|
-
btnIcon
|
|
57
|
-
title
|
|
58
|
-
exitBtnText
|
|
59
|
-
exitBtnIcon
|
|
60
|
-
exitTitle
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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);
|
|
65
44
|
} else {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
45
|
+
this.setBtnTitle(title);
|
|
46
|
+
this.setBtnText(btnText);
|
|
47
|
+
this.setBtnIcon(btnIcon);
|
|
69
48
|
}
|
|
70
|
-
|
|
49
|
+
this.emit('fullscreenChange', this.isFullscreen);
|
|
71
50
|
});
|
|
72
51
|
if (!_screenfull.default.isEnabled) {
|
|
73
52
|
console.warn('当前浏览器环境不支持对地图全屏化');
|
|
74
53
|
}
|
|
75
|
-
return _this;
|
|
76
54
|
}
|
|
77
|
-
(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
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);
|
|
93
70
|
}
|
|
94
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(Fullscreen.prototype), "setOptions", this).call(this, newOptions);
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "onAdd",
|
|
98
|
-
value: function onAdd() {
|
|
99
|
-
var button = (0, _get2.default)((0, _getPrototypeOf2.default)(Fullscreen.prototype), "onAdd", this).call(this);
|
|
100
|
-
button.addEventListener('click', this.onClick);
|
|
101
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
102
|
-
this.mapContainer = _l7Utils.DOM.getContainer(this.scene.getSceneConfig().id);
|
|
103
|
-
this.mapContainer.addEventListener('fullscreenchange', this.onFullscreenChange);
|
|
104
|
-
return button;
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
key: "onRemove",
|
|
108
|
-
value: function onRemove() {
|
|
109
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(Fullscreen.prototype), "onRemove", this).call(this);
|
|
110
|
-
this.mapContainer.removeEventListener('fullscreenchange', this.onFullscreenChange);
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
key: "getDefault",
|
|
114
|
-
value: function getDefault(option) {
|
|
115
|
-
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(Fullscreen.prototype), "getDefault", this).call(this, option)), {}, {
|
|
116
|
-
title: '全屏',
|
|
117
|
-
btnIcon: (0, _icon.createL7Icon)('l7-icon-fullscreen'),
|
|
118
|
-
exitTitle: '退出全屏',
|
|
119
|
-
exitBtnIcon: (0, _icon.createL7Icon)('l7-icon-exit-fullscreen')
|
|
120
|
-
});
|
|
121
71
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
CHANGED
|
@@ -5,108 +5,63 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.GeoLocate = void 0;
|
|
8
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
14
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
15
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
18
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
11
|
var _icon = require("../utils/icon");
|
|
20
12
|
var _buttonControl = _interopRequireDefault(require("./baseControl/buttonControl"));
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var GeoLocate = exports.default = exports.GeoLocate = /*#__PURE__*/function (_ButtonControl) {
|
|
24
|
-
(0, _inherits2.default)(GeoLocate, _ButtonControl);
|
|
25
|
-
var _super = _createSuper(GeoLocate);
|
|
26
|
-
function GeoLocate(option) {
|
|
13
|
+
class GeoLocate extends _buttonControl.default {
|
|
14
|
+
constructor(option) {
|
|
27
15
|
var _this;
|
|
28
|
-
(
|
|
29
|
-
_this =
|
|
16
|
+
super(option);
|
|
17
|
+
_this = this;
|
|
30
18
|
/**
|
|
31
19
|
* 通过浏览器 API 获取当前所在经纬度
|
|
32
20
|
*/
|
|
33
|
-
(0, _defineProperty2.default)(
|
|
34
|
-
return new Promise(
|
|
35
|
-
window.navigator.geolocation.getCurrentPosition(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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 : {};
|
|
40
30
|
if (!isNaN(longitude) && !isNaN(latitude)) {
|
|
41
31
|
resolve([longitude, latitude]);
|
|
42
32
|
} else {
|
|
43
33
|
reject();
|
|
44
34
|
}
|
|
45
|
-
},
|
|
35
|
+
}, e => {
|
|
46
36
|
reject(e);
|
|
47
37
|
});
|
|
48
38
|
});
|
|
49
39
|
});
|
|
50
|
-
(0, _defineProperty2.default)(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
transform = _this.controlOption.transform;
|
|
62
|
-
_context.next = 5;
|
|
63
|
-
return _this.getGeoLocation();
|
|
64
|
-
case 5:
|
|
65
|
-
position = _context.sent;
|
|
66
|
-
currentZoom = _this.mapsService.getZoom();
|
|
67
|
-
_context.t0 = _this.mapsService;
|
|
68
|
-
_context.t1 = currentZoom > 15 ? currentZoom : 15;
|
|
69
|
-
if (!transform) {
|
|
70
|
-
_context.next = 15;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
_context.next = 12;
|
|
74
|
-
return transform(position);
|
|
75
|
-
case 12:
|
|
76
|
-
_context.t2 = _context.sent;
|
|
77
|
-
_context.next = 16;
|
|
78
|
-
break;
|
|
79
|
-
case 15:
|
|
80
|
-
_context.t2 = position;
|
|
81
|
-
case 16:
|
|
82
|
-
_context.t3 = _context.t2;
|
|
83
|
-
_context.t0.setZoomAndCenter.call(_context.t0, _context.t1, _context.t3);
|
|
84
|
-
case 18:
|
|
85
|
-
case "end":
|
|
86
|
-
return _context.stop();
|
|
87
|
-
}
|
|
88
|
-
}, _callee);
|
|
89
|
-
})));
|
|
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
|
+
}));
|
|
90
51
|
if (!window.navigator.geolocation) {
|
|
91
52
|
console.warn('当前浏览器环境不支持获取地理定位');
|
|
92
53
|
}
|
|
93
|
-
return _this;
|
|
94
54
|
}
|
|
95
|
-
(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return button;
|
|
109
|
-
}
|
|
110
|
-
}]);
|
|
111
|
-
return GeoLocate;
|
|
112
|
-
}(_buttonControl.default);
|
|
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;
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|