@antv/l7-component 2.21.0 → 2.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/assets/iconfont/iconfont.js +6 -6
- package/es/constants/index.js +2 -2
- package/es/control/baseControl/buttonControl.js +109 -144
- package/es/control/baseControl/control.js +212 -258
- package/es/control/baseControl/popperControl.js +67 -95
- package/es/control/baseControl/selectControl.js +132 -178
- package/es/control/exportImage.js +59 -142
- package/es/control/fullscreen.js +69 -100
- package/es/control/geoLocate.js +37 -84
- package/es/control/layerSwitch.js +111 -154
- package/es/control/logo.js +43 -69
- package/es/control/mapTheme.js +57 -98
- package/es/control/mouseLocation.js +37 -69
- package/es/control/scale.js +107 -135
- package/es/control/swipe.js +297 -393
- package/es/control/zoom.js +80 -112
- package/es/css/index.css +10 -7
- package/es/index.js +667 -1
- package/es/marker-layer.js +274 -326
- package/es/marker.d.ts +0 -2
- package/es/marker.js +394 -453
- package/es/popup/layerPopup.js +277 -321
- package/es/popup/popup.js +422 -482
- package/es/utils/anchor.js +6 -6
- package/es/utils/icon.js +4 -4
- package/es/utils/popper.js +180 -196
- package/es/utils/screenfull.js +29 -51
- package/lib/assets/iconfont/iconfont.js +6 -6
- package/lib/constants/index.d.ts +60 -0
- package/lib/constants/index.js +2 -2
- package/lib/control/baseControl/buttonControl.d.ts +60 -0
- package/lib/control/baseControl/buttonControl.js +110 -143
- package/lib/control/baseControl/control.d.ts +112 -0
- package/lib/control/baseControl/control.js +213 -257
- package/lib/control/baseControl/index.d.ts +4 -0
- package/lib/control/baseControl/index.js +5 -5
- package/lib/control/baseControl/popperControl.d.ts +28 -0
- package/lib/control/baseControl/popperControl.js +68 -94
- package/lib/control/baseControl/selectControl.d.ts +53 -0
- package/lib/control/baseControl/selectControl.js +133 -177
- package/lib/control/exportImage.d.ts +19 -0
- package/lib/control/exportImage.js +60 -141
- package/lib/control/fullscreen.d.ts +20 -0
- package/lib/control/fullscreen.js +70 -99
- package/lib/control/geoLocate.d.ts +17 -0
- package/lib/control/geoLocate.js +38 -83
- package/lib/control/layerSwitch.d.ts +27 -0
- package/lib/control/layerSwitch.js +112 -153
- package/lib/control/logo.d.ts +14 -0
- package/lib/control/logo.js +44 -69
- package/lib/control/mapTheme.d.ts +11 -0
- package/lib/control/mapTheme.js +58 -97
- package/lib/control/mouseLocation.d.ts +16 -0
- package/lib/control/mouseLocation.js +38 -68
- package/lib/control/scale.d.ts +35 -0
- package/lib/control/scale.js +108 -134
- package/lib/control/swipe.d.ts +66 -0
- package/lib/control/swipe.js +298 -392
- package/lib/control/zoom.d.ts +39 -0
- package/lib/control/zoom.js +81 -111
- package/lib/css/index.css +10 -7
- package/lib/index.d.ts +19 -0
- package/lib/index.js +683 -17
- package/lib/interface.d.ts +18 -0
- package/lib/marker-layer.d.ts +55 -0
- package/lib/marker-layer.js +276 -324
- package/lib/marker.d.ts +58 -0
- package/lib/marker.js +395 -452
- package/lib/popup/layerPopup.d.ts +99 -0
- package/lib/popup/layerPopup.js +278 -320
- package/lib/popup/popup.d.ts +142 -0
- package/lib/popup/popup.js +423 -481
- package/lib/utils/anchor.d.ts +22 -0
- package/lib/utils/anchor.js +6 -6
- package/lib/utils/icon.d.ts +1 -0
- package/lib/utils/icon.js +6 -5
- package/lib/utils/popper.d.ts +76 -0
- package/lib/utils/popper.js +184 -196
- package/lib/utils/screenfull.d.ts +2 -0
- package/lib/utils/screenfull.js +29 -52
- package/package.json +16 -20
- package/CHANGELOG.md +0 -325
- package/LICENSE.md +0 -21
|
@@ -1,156 +1,73 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
7
|
-
import _get from "@babel/runtime/helpers/esm/get";
|
|
8
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
9
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
10
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
11
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
12
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
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
|
-
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
4
|
import { createL7Icon } from "../utils/icon";
|
|
16
5
|
import ButtonControl from "./baseControl/buttonControl";
|
|
17
6
|
export { ExportImage };
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _super = _createSuper(ExportImage);
|
|
21
|
-
function ExportImage() {
|
|
7
|
+
export default class ExportImage extends ButtonControl {
|
|
8
|
+
constructor(...args) {
|
|
22
9
|
var _this;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
while (1) switch (_context.prev = _context.next) {
|
|
32
|
-
case 0:
|
|
33
|
-
onExport = _this.controlOption.onExport;
|
|
34
|
-
_context.t0 = onExport === null || onExport === void 0;
|
|
35
|
-
if (_context.t0) {
|
|
36
|
-
_context.next = 8;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
_context.t1 = onExport;
|
|
40
|
-
_context.next = 6;
|
|
41
|
-
return _this.getImage();
|
|
42
|
-
case 6:
|
|
43
|
-
_context.t2 = _context.sent;
|
|
44
|
-
(0, _context.t1)(_context.t2);
|
|
45
|
-
case 8:
|
|
46
|
-
case "end":
|
|
47
|
-
return _context.stop();
|
|
48
|
-
}
|
|
49
|
-
}, _callee);
|
|
50
|
-
})));
|
|
10
|
+
super(...args);
|
|
11
|
+
_this = this;
|
|
12
|
+
_defineProperty(this, "onClick", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
13
|
+
const {
|
|
14
|
+
onExport
|
|
15
|
+
} = _this.controlOption;
|
|
16
|
+
onExport === null || onExport === void 0 || onExport(yield _this.getImage());
|
|
17
|
+
}));
|
|
51
18
|
/**
|
|
52
19
|
* 将多张图片合并为一张图片
|
|
53
20
|
* @protected
|
|
54
21
|
* @param base64List
|
|
55
22
|
*/
|
|
56
|
-
_defineProperty(
|
|
23
|
+
_defineProperty(this, "mergeImage", /*#__PURE__*/_asyncToGenerator(function* (...base64List) {
|
|
57
24
|
var _this$mapsService$get, _this$mapsService$get2;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
height
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
canvas.width = width;
|
|
78
|
-
canvas.height = height;
|
|
79
|
-
context = canvas.getContext('2d');
|
|
80
|
-
for (_len2 = _args2.length, base64List = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
81
|
-
base64List[_key2] = _args2[_key2];
|
|
82
|
-
}
|
|
83
|
-
_context2.next = 9;
|
|
84
|
-
return Promise.all(base64List.map(function (base64) {
|
|
85
|
-
return new Promise(function (resolve) {
|
|
86
|
-
var img = new Image();
|
|
87
|
-
img.onload = function () {
|
|
88
|
-
resolve(img);
|
|
89
|
-
};
|
|
90
|
-
img.src = base64;
|
|
91
|
-
});
|
|
92
|
-
}));
|
|
93
|
-
case 9:
|
|
94
|
-
imgList = _context2.sent;
|
|
95
|
-
imgList.forEach(function (img) {
|
|
96
|
-
context === null || context === void 0 || context.drawImage(img, 0, 0, width, height);
|
|
97
|
-
});
|
|
98
|
-
return _context2.abrupt("return", canvas.toDataURL("image/".concat(imageType)));
|
|
99
|
-
case 12:
|
|
100
|
-
case "end":
|
|
101
|
-
return _context2.stop();
|
|
102
|
-
}
|
|
103
|
-
}, _callee2);
|
|
104
|
-
})));
|
|
105
|
-
return _this;
|
|
106
|
-
}
|
|
107
|
-
_createClass(ExportImage, [{
|
|
108
|
-
key: "onAdd",
|
|
109
|
-
value: function onAdd() {
|
|
110
|
-
var button = _get(_getPrototypeOf(ExportImage.prototype), "onAdd", this).call(this);
|
|
111
|
-
button.addEventListener('click', this.onClick);
|
|
112
|
-
return button;
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
key: "getDefault",
|
|
116
|
-
value: function getDefault(option) {
|
|
117
|
-
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(ExportImage.prototype), "getDefault", this).call(this, option)), {}, {
|
|
118
|
-
title: '导出图片',
|
|
119
|
-
btnIcon: createL7Icon('l7-icon-export-picture'),
|
|
120
|
-
imageType: 'png'
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}, {
|
|
124
|
-
key: "getImage",
|
|
125
|
-
value: function () {
|
|
126
|
-
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
127
|
-
var mapImage, layerImage;
|
|
128
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
129
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
130
|
-
case 0:
|
|
131
|
-
_context3.next = 2;
|
|
132
|
-
return this.mapsService.exportMap('png');
|
|
133
|
-
case 2:
|
|
134
|
-
mapImage = _context3.sent;
|
|
135
|
-
_context3.next = 5;
|
|
136
|
-
return this.scene.exportPng('png');
|
|
137
|
-
case 5:
|
|
138
|
-
layerImage = _context3.sent;
|
|
139
|
-
return _context3.abrupt("return", this.mergeImage.apply(this, _toConsumableArray([mapImage, layerImage].filter(function (base64) {
|
|
140
|
-
return base64;
|
|
141
|
-
}))));
|
|
142
|
-
case 7:
|
|
143
|
-
case "end":
|
|
144
|
-
return _context3.stop();
|
|
145
|
-
}
|
|
146
|
-
}, _callee3, this);
|
|
25
|
+
const {
|
|
26
|
+
imageType
|
|
27
|
+
} = _this.controlOption;
|
|
28
|
+
const {
|
|
29
|
+
width = 0,
|
|
30
|
+
height = 0
|
|
31
|
+
} = (_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 : {};
|
|
32
|
+
const canvas = document.createElement('canvas');
|
|
33
|
+
canvas.width = width;
|
|
34
|
+
canvas.height = height;
|
|
35
|
+
const context = canvas.getContext('2d');
|
|
36
|
+
const imgList = yield Promise.all(base64List.map(base64 => {
|
|
37
|
+
return new Promise(resolve => {
|
|
38
|
+
const img = new Image();
|
|
39
|
+
img.onload = () => {
|
|
40
|
+
resolve(img);
|
|
41
|
+
};
|
|
42
|
+
img.src = base64;
|
|
43
|
+
});
|
|
147
44
|
}));
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
return
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
45
|
+
imgList.forEach(img => {
|
|
46
|
+
context === null || context === void 0 || context.drawImage(img, 0, 0, width, height);
|
|
47
|
+
});
|
|
48
|
+
return canvas.toDataURL(`image/${imageType}`);
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
onAdd() {
|
|
52
|
+
const button = super.onAdd();
|
|
53
|
+
button.addEventListener('click', this.onClick);
|
|
54
|
+
return button;
|
|
55
|
+
}
|
|
56
|
+
getDefault(option) {
|
|
57
|
+
return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
|
|
58
|
+
title: '导出图片',
|
|
59
|
+
btnIcon: createL7Icon('l7-icon-export-picture'),
|
|
60
|
+
imageType: 'png'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
getImage() {
|
|
64
|
+
var _this2 = this;
|
|
65
|
+
return _asyncToGenerator(function* () {
|
|
66
|
+
const mapImage = yield _this2.mapsService.exportMap('png');
|
|
67
|
+
const layerImage = yield _this2.scene.exportPng('png');
|
|
68
|
+
return _this2.mergeImage(
|
|
69
|
+
// 在 Map 底图模式下 mapImage 为 undefined
|
|
70
|
+
...[mapImage, layerImage].filter(base64 => base64));
|
|
71
|
+
})();
|
|
72
|
+
}
|
|
73
|
+
}
|
package/es/control/fullscreen.js
CHANGED
|
@@ -1,119 +1,88 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
-
import _get from "@babel/runtime/helpers/esm/get";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
9
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
10
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
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
|
-
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
4
|
import { DOM } from '@antv/l7-utils';
|
|
15
5
|
import { createL7Icon } from "../utils/icon";
|
|
16
6
|
import ScreenFull from "../utils/screenfull";
|
|
17
7
|
import ButtonControl from "./baseControl/buttonControl";
|
|
18
8
|
export { Fullscreen };
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _super = _createSuper(Fullscreen);
|
|
22
|
-
function Fullscreen(option) {
|
|
9
|
+
export default class Fullscreen extends ButtonControl {
|
|
10
|
+
constructor(option) {
|
|
23
11
|
var _this;
|
|
24
|
-
|
|
25
|
-
_this =
|
|
26
|
-
_defineProperty(
|
|
27
|
-
_defineProperty(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_context.next = 3;
|
|
36
|
-
return ScreenFull.toggle(_this.mapContainer);
|
|
37
|
-
case 3:
|
|
38
|
-
case "end":
|
|
39
|
-
return _context.stop();
|
|
40
|
-
}
|
|
41
|
-
}, _callee);
|
|
42
|
-
})));
|
|
43
|
-
_defineProperty(_assertThisInitialized(_this), "onClick", function () {
|
|
44
|
-
_this.toggleFullscreen();
|
|
12
|
+
super(option);
|
|
13
|
+
_this = this;
|
|
14
|
+
_defineProperty(this, "isFullscreen", false);
|
|
15
|
+
_defineProperty(this, "mapContainer", void 0);
|
|
16
|
+
_defineProperty(this, "toggleFullscreen", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
17
|
+
if (ScreenFull.isEnabled) {
|
|
18
|
+
yield ScreenFull.toggle(_this.mapContainer);
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
_defineProperty(this, "onClick", () => {
|
|
22
|
+
this.toggleFullscreen();
|
|
45
23
|
});
|
|
46
|
-
_defineProperty(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
btnText
|
|
50
|
-
btnIcon
|
|
51
|
-
title
|
|
52
|
-
exitBtnText
|
|
53
|
-
exitBtnIcon
|
|
54
|
-
exitTitle
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
24
|
+
_defineProperty(this, "onFullscreenChange", () => {
|
|
25
|
+
this.isFullscreen = !!document.fullscreenElement;
|
|
26
|
+
const {
|
|
27
|
+
btnText,
|
|
28
|
+
btnIcon,
|
|
29
|
+
title,
|
|
30
|
+
exitBtnText,
|
|
31
|
+
exitBtnIcon,
|
|
32
|
+
exitTitle
|
|
33
|
+
} = this.controlOption;
|
|
34
|
+
if (this.isFullscreen) {
|
|
35
|
+
this.setBtnTitle(exitTitle);
|
|
36
|
+
this.setBtnText(exitBtnText);
|
|
37
|
+
this.setBtnIcon(exitBtnIcon);
|
|
59
38
|
} else {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
39
|
+
this.setBtnTitle(title);
|
|
40
|
+
this.setBtnText(btnText);
|
|
41
|
+
this.setBtnIcon(btnIcon);
|
|
63
42
|
}
|
|
64
|
-
|
|
43
|
+
this.emit('fullscreenChange', this.isFullscreen);
|
|
65
44
|
});
|
|
66
45
|
if (!ScreenFull.isEnabled) {
|
|
67
46
|
console.warn('当前浏览器环境不支持对地图全屏化');
|
|
68
47
|
}
|
|
69
|
-
return _this;
|
|
70
48
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
49
|
+
setOptions(newOptions) {
|
|
50
|
+
const {
|
|
51
|
+
exitBtnText,
|
|
52
|
+
exitBtnIcon,
|
|
53
|
+
exitTitle
|
|
54
|
+
} = newOptions;
|
|
55
|
+
if (this.isFullscreen) {
|
|
56
|
+
if (this.checkUpdateOption(newOptions, ['exitBtnIcon'])) {
|
|
57
|
+
this.setBtnIcon(exitBtnIcon);
|
|
58
|
+
}
|
|
59
|
+
if (this.checkUpdateOption(newOptions, ['exitBtnText'])) {
|
|
60
|
+
this.setBtnText(exitBtnText);
|
|
61
|
+
}
|
|
62
|
+
if (this.checkUpdateOption(newOptions, ['exitTitle'])) {
|
|
63
|
+
this.setBtnTitle(exitTitle);
|
|
87
64
|
}
|
|
88
|
-
_get(_getPrototypeOf(Fullscreen.prototype), "setOptions", this).call(this, newOptions);
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
key: "onAdd",
|
|
92
|
-
value: function onAdd() {
|
|
93
|
-
var button = _get(_getPrototypeOf(Fullscreen.prototype), "onAdd", this).call(this);
|
|
94
|
-
button.addEventListener('click', this.onClick);
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
96
|
-
this.mapContainer = DOM.getContainer(this.scene.getSceneConfig().id);
|
|
97
|
-
this.mapContainer.addEventListener('fullscreenchange', this.onFullscreenChange);
|
|
98
|
-
return button;
|
|
99
|
-
}
|
|
100
|
-
}, {
|
|
101
|
-
key: "onRemove",
|
|
102
|
-
value: function onRemove() {
|
|
103
|
-
_get(_getPrototypeOf(Fullscreen.prototype), "onRemove", this).call(this);
|
|
104
|
-
this.mapContainer.removeEventListener('fullscreenchange', this.onFullscreenChange);
|
|
105
|
-
}
|
|
106
|
-
}, {
|
|
107
|
-
key: "getDefault",
|
|
108
|
-
value: function getDefault(option) {
|
|
109
|
-
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(Fullscreen.prototype), "getDefault", this).call(this, option)), {}, {
|
|
110
|
-
title: '全屏',
|
|
111
|
-
btnIcon: createL7Icon('l7-icon-fullscreen'),
|
|
112
|
-
exitTitle: '退出全屏',
|
|
113
|
-
exitBtnIcon: createL7Icon('l7-icon-exit-fullscreen')
|
|
114
|
-
});
|
|
115
65
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
66
|
+
super.setOptions(newOptions);
|
|
67
|
+
}
|
|
68
|
+
onAdd() {
|
|
69
|
+
const button = super.onAdd();
|
|
70
|
+
button.addEventListener('click', this.onClick);
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
72
|
+
this.mapContainer = DOM.getContainer(this.scene.getSceneConfig().id);
|
|
73
|
+
this.mapContainer.addEventListener('fullscreenchange', this.onFullscreenChange);
|
|
74
|
+
return button;
|
|
75
|
+
}
|
|
76
|
+
onRemove() {
|
|
77
|
+
super.onRemove();
|
|
78
|
+
this.mapContainer.removeEventListener('fullscreenchange', this.onFullscreenChange);
|
|
79
|
+
}
|
|
80
|
+
getDefault(option) {
|
|
81
|
+
return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
|
|
82
|
+
title: '全屏',
|
|
83
|
+
btnIcon: createL7Icon('l7-icon-fullscreen'),
|
|
84
|
+
exitTitle: '退出全屏',
|
|
85
|
+
exitBtnIcon: createL7Icon('l7-icon-exit-fullscreen')
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
package/es/control/geoLocate.js
CHANGED
|
@@ -1,107 +1,60 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
6
|
-
import _get from "@babel/runtime/helpers/esm/get";
|
|
7
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
9
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
10
3
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
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
|
-
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
4
|
import { createL7Icon } from "../utils/icon";
|
|
15
5
|
import ButtonControl from "./baseControl/buttonControl";
|
|
16
6
|
export { GeoLocate };
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _super = _createSuper(GeoLocate);
|
|
20
|
-
function GeoLocate(option) {
|
|
7
|
+
export default class GeoLocate extends ButtonControl {
|
|
8
|
+
constructor(option) {
|
|
21
9
|
var _this;
|
|
22
|
-
|
|
23
|
-
_this =
|
|
10
|
+
super(option);
|
|
11
|
+
_this = this;
|
|
24
12
|
/**
|
|
25
13
|
* 通过浏览器 API 获取当前所在经纬度
|
|
26
14
|
*/
|
|
27
|
-
_defineProperty(
|
|
28
|
-
return new Promise(
|
|
29
|
-
window.navigator.geolocation.getCurrentPosition(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
15
|
+
_defineProperty(this, "getGeoLocation", () => {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
window.navigator.geolocation.getCurrentPosition(({
|
|
18
|
+
coords
|
|
19
|
+
}) => {
|
|
20
|
+
const {
|
|
21
|
+
longitude,
|
|
22
|
+
latitude
|
|
23
|
+
} = coords !== null && coords !== void 0 ? coords : {};
|
|
34
24
|
if (!isNaN(longitude) && !isNaN(latitude)) {
|
|
35
25
|
resolve([longitude, latitude]);
|
|
36
26
|
} else {
|
|
37
27
|
reject();
|
|
38
28
|
}
|
|
39
|
-
},
|
|
29
|
+
}, e => {
|
|
40
30
|
reject(e);
|
|
41
31
|
});
|
|
42
32
|
});
|
|
43
33
|
});
|
|
44
|
-
_defineProperty(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
transform = _this.controlOption.transform;
|
|
56
|
-
_context.next = 5;
|
|
57
|
-
return _this.getGeoLocation();
|
|
58
|
-
case 5:
|
|
59
|
-
position = _context.sent;
|
|
60
|
-
currentZoom = _this.mapsService.getZoom();
|
|
61
|
-
_context.t0 = _this.mapsService;
|
|
62
|
-
_context.t1 = currentZoom > 15 ? currentZoom : 15;
|
|
63
|
-
if (!transform) {
|
|
64
|
-
_context.next = 15;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
_context.next = 12;
|
|
68
|
-
return transform(position);
|
|
69
|
-
case 12:
|
|
70
|
-
_context.t2 = _context.sent;
|
|
71
|
-
_context.next = 16;
|
|
72
|
-
break;
|
|
73
|
-
case 15:
|
|
74
|
-
_context.t2 = position;
|
|
75
|
-
case 16:
|
|
76
|
-
_context.t3 = _context.t2;
|
|
77
|
-
_context.t0.setZoomAndCenter.call(_context.t0, _context.t1, _context.t3);
|
|
78
|
-
case 18:
|
|
79
|
-
case "end":
|
|
80
|
-
return _context.stop();
|
|
81
|
-
}
|
|
82
|
-
}, _callee);
|
|
83
|
-
})));
|
|
34
|
+
_defineProperty(this, "onClick", /*#__PURE__*/_asyncToGenerator(function* () {
|
|
35
|
+
if (!window.navigator.geolocation) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const {
|
|
39
|
+
transform
|
|
40
|
+
} = _this.controlOption;
|
|
41
|
+
const position = yield _this.getGeoLocation();
|
|
42
|
+
const currentZoom = _this.mapsService.getZoom();
|
|
43
|
+
_this.mapsService.setZoomAndCenter(currentZoom > 15 ? currentZoom : 15, transform ? yield transform(position) : position);
|
|
44
|
+
}));
|
|
84
45
|
if (!window.navigator.geolocation) {
|
|
85
46
|
console.warn('当前浏览器环境不支持获取地理定位');
|
|
86
47
|
}
|
|
87
|
-
return _this;
|
|
88
48
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
button.addEventListener('click', this.onClick);
|
|
102
|
-
return button;
|
|
103
|
-
}
|
|
104
|
-
}]);
|
|
105
|
-
return GeoLocate;
|
|
106
|
-
}(ButtonControl);
|
|
107
|
-
export { GeoLocate as default };
|
|
49
|
+
getDefault(option) {
|
|
50
|
+
return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
|
|
51
|
+
title: '定位',
|
|
52
|
+
btnIcon: createL7Icon('l7-icon-reposition')
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
onAdd() {
|
|
56
|
+
const button = super.onAdd();
|
|
57
|
+
button.addEventListener('click', this.onClick);
|
|
58
|
+
return button;
|
|
59
|
+
}
|
|
60
|
+
}
|