@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
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -5,84 +5,54 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.MouseLocation = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
13
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
16
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
17
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
10
|
var _l7Core = require("@antv/l7-core");
|
|
19
11
|
var _l7Utils = require("@antv/l7-utils");
|
|
20
12
|
var _control = _interopRequireDefault(require("./baseControl/control"));
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
33
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "location", [0, 0]);
|
|
34
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMouseMove", function (e) {
|
|
35
|
-
var position = _this.location;
|
|
36
|
-
var lngLat = e.lngLat || e.lnglat;
|
|
37
|
-
var transform = _this.controlOption.transform;
|
|
13
|
+
class MouseLocation extends _control.default {
|
|
14
|
+
constructor(...args) {
|
|
15
|
+
super(...args);
|
|
16
|
+
(0, _defineProperty2.default)(this, "location", [0, 0]);
|
|
17
|
+
(0, _defineProperty2.default)(this, "onMouseMove", e => {
|
|
18
|
+
let position = this.location;
|
|
19
|
+
const lngLat = e.lngLat || e.lnglat;
|
|
20
|
+
const {
|
|
21
|
+
transform
|
|
22
|
+
} = this.controlOption;
|
|
38
23
|
if (lngLat) {
|
|
39
24
|
position = [lngLat.lng, lngLat.lat];
|
|
40
25
|
}
|
|
41
|
-
|
|
26
|
+
this.location = position;
|
|
42
27
|
if (transform) {
|
|
43
28
|
position = transform(position);
|
|
44
29
|
}
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
this.insertLocation2HTML(position);
|
|
31
|
+
this.emit('locationChange', position);
|
|
47
32
|
});
|
|
48
|
-
return _this;
|
|
49
33
|
}
|
|
50
|
-
(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
}, {
|
|
77
|
-
key: "onRemove",
|
|
78
|
-
value: function onRemove() {
|
|
79
|
-
this.mapsService.off('mousemove', this.onMouseMove);
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "insertLocation2HTML",
|
|
83
|
-
value: function insertLocation2HTML(position) {
|
|
84
|
-
this.container.innerText = position.join(', ');
|
|
85
|
-
}
|
|
86
|
-
}]);
|
|
87
|
-
return MouseLocation;
|
|
88
|
-
}(_control.default);
|
|
34
|
+
getLocation() {
|
|
35
|
+
return this.location;
|
|
36
|
+
}
|
|
37
|
+
getDefault(option) {
|
|
38
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, super.getDefault(option)), {}, {
|
|
39
|
+
position: _l7Core.PositionType.BOTTOMLEFT,
|
|
40
|
+
transform: ([lng, lat]) => {
|
|
41
|
+
return [+(+lng).toFixed(6), +(+lat).toFixed(6)];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
onAdd() {
|
|
46
|
+
const container = _l7Utils.DOM.create('div', 'l7-control-mouse-location');
|
|
47
|
+
container.innerHTML = ' ';
|
|
48
|
+
this.mapsService.on('mousemove', this.onMouseMove);
|
|
49
|
+
return container;
|
|
50
|
+
}
|
|
51
|
+
onRemove() {
|
|
52
|
+
this.mapsService.off('mousemove', this.onMouseMove);
|
|
53
|
+
}
|
|
54
|
+
insertLocation2HTML(position) {
|
|
55
|
+
this.container.innerText = position.join(', ');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = exports.MouseLocation = MouseLocation;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { IControlOption } from './baseControl';
|
|
2
|
+
import { Control, PositionType } from './baseControl';
|
|
3
|
+
export interface IScaleControlOption extends IControlOption {
|
|
4
|
+
lockWidth: boolean;
|
|
5
|
+
maxWidth: number;
|
|
6
|
+
metric: boolean;
|
|
7
|
+
updateWhenIdle: boolean;
|
|
8
|
+
imperial: boolean;
|
|
9
|
+
}
|
|
10
|
+
export { Scale };
|
|
11
|
+
export default class Scale extends Control<IScaleControlOption> {
|
|
12
|
+
private mScale;
|
|
13
|
+
private iScale;
|
|
14
|
+
getDefault(option: Partial<IScaleControlOption>): {
|
|
15
|
+
name: string;
|
|
16
|
+
position: PositionType;
|
|
17
|
+
maxWidth: number;
|
|
18
|
+
metric: boolean;
|
|
19
|
+
updateWhenIdle: boolean;
|
|
20
|
+
imperial: boolean;
|
|
21
|
+
lockWidth: boolean;
|
|
22
|
+
className?: string | undefined;
|
|
23
|
+
style?: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
onAdd(): HTMLElement;
|
|
26
|
+
onRemove(): void;
|
|
27
|
+
setOptions(newOption: Partial<IScaleControlOption>): void;
|
|
28
|
+
update: () => void;
|
|
29
|
+
updateScales(maxMeters: number): void;
|
|
30
|
+
private resetScaleLines;
|
|
31
|
+
private updateScale;
|
|
32
|
+
private getRoundNum;
|
|
33
|
+
private updateMetric;
|
|
34
|
+
private updateImperial;
|
|
35
|
+
}
|
package/lib/control/scale.js
CHANGED
|
@@ -6,149 +6,123 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.Scale = void 0;
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
13
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
10
|
var _l7Utils = require("@antv/l7-utils");
|
|
18
11
|
var _baseControl = require("./baseControl");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var y = mapsService.getSize()[1] / 2;
|
|
35
|
-
var p1 = mapsService.containerToLngLat([0, y]);
|
|
36
|
-
var p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
37
|
-
var maxMeters = (0, _l7Utils.lnglatDistance)([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
38
|
-
_this.updateScales(maxMeters);
|
|
12
|
+
class Scale extends _baseControl.Control {
|
|
13
|
+
constructor(...args) {
|
|
14
|
+
super(...args);
|
|
15
|
+
(0, _defineProperty2.default)(this, "mScale", void 0);
|
|
16
|
+
(0, _defineProperty2.default)(this, "iScale", void 0);
|
|
17
|
+
(0, _defineProperty2.default)(this, "update", () => {
|
|
18
|
+
const mapsService = this.mapsService;
|
|
19
|
+
const {
|
|
20
|
+
maxWidth
|
|
21
|
+
} = this.controlOption;
|
|
22
|
+
const y = mapsService.getSize()[1] / 2;
|
|
23
|
+
const p1 = mapsService.containerToLngLat([0, y]);
|
|
24
|
+
const p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
25
|
+
const maxMeters = (0, _l7Utils.lnglatDistance)([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
26
|
+
this.updateScales(maxMeters);
|
|
39
27
|
});
|
|
40
|
-
return _this;
|
|
41
28
|
}
|
|
42
|
-
(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
value: function setOptions(newOption) {
|
|
76
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(Scale.prototype), "setOptions", this).call(this, newOption);
|
|
77
|
-
if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
|
|
78
|
-
this.resetScaleLines(this.container);
|
|
79
|
-
}
|
|
29
|
+
getDefault(option) {
|
|
30
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, super.getDefault(option)), {}, {
|
|
31
|
+
name: 'scale',
|
|
32
|
+
position: _baseControl.PositionType.BOTTOMLEFT,
|
|
33
|
+
maxWidth: 100,
|
|
34
|
+
metric: true,
|
|
35
|
+
updateWhenIdle: false,
|
|
36
|
+
imperial: false,
|
|
37
|
+
lockWidth: true
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
onAdd() {
|
|
41
|
+
const className = 'l7-control-scale';
|
|
42
|
+
const container = _l7Utils.DOM.create('div', className);
|
|
43
|
+
this.resetScaleLines(container);
|
|
44
|
+
const {
|
|
45
|
+
updateWhenIdle
|
|
46
|
+
} = this.controlOption;
|
|
47
|
+
this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
48
|
+
this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
49
|
+
return container;
|
|
50
|
+
}
|
|
51
|
+
onRemove() {
|
|
52
|
+
const {
|
|
53
|
+
updateWhenIdle
|
|
54
|
+
} = this.controlOption;
|
|
55
|
+
this.mapsService.off(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
56
|
+
this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
57
|
+
}
|
|
58
|
+
setOptions(newOption) {
|
|
59
|
+
super.setOptions(newOption);
|
|
60
|
+
if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
|
|
61
|
+
this.resetScaleLines(this.container);
|
|
80
62
|
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
if (imperial && maxMeters) {
|
|
91
|
-
this.updateImperial(maxMeters);
|
|
92
|
-
}
|
|
63
|
+
}
|
|
64
|
+
updateScales(maxMeters) {
|
|
65
|
+
const {
|
|
66
|
+
metric,
|
|
67
|
+
imperial
|
|
68
|
+
} = this.controlOption;
|
|
69
|
+
if (metric && maxMeters) {
|
|
70
|
+
this.updateMetric(maxMeters);
|
|
93
71
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
value: function resetScaleLines(container) {
|
|
97
|
-
_l7Utils.DOM.clearChildren(container);
|
|
98
|
-
var _this$controlOption2 = this.controlOption,
|
|
99
|
-
metric = _this$controlOption2.metric,
|
|
100
|
-
imperial = _this$controlOption2.imperial,
|
|
101
|
-
maxWidth = _this$controlOption2.maxWidth,
|
|
102
|
-
lockWidth = _this$controlOption2.lockWidth;
|
|
103
|
-
if (lockWidth) {
|
|
104
|
-
_l7Utils.DOM.addStyle(container, "width: ".concat(maxWidth, "px"));
|
|
105
|
-
}
|
|
106
|
-
if (metric) {
|
|
107
|
-
this.mScale = _l7Utils.DOM.create('div', 'l7-control-scale-line', container);
|
|
108
|
-
}
|
|
109
|
-
if (imperial) {
|
|
110
|
-
this.iScale = _l7Utils.DOM.create('div', 'l7-control-scale-line', container);
|
|
111
|
-
}
|
|
112
|
-
this.update();
|
|
72
|
+
if (imperial && maxMeters) {
|
|
73
|
+
this.updateImperial(maxMeters);
|
|
113
74
|
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
75
|
+
}
|
|
76
|
+
resetScaleLines(container) {
|
|
77
|
+
_l7Utils.DOM.clearChildren(container);
|
|
78
|
+
const {
|
|
79
|
+
metric,
|
|
80
|
+
imperial,
|
|
81
|
+
maxWidth,
|
|
82
|
+
lockWidth
|
|
83
|
+
} = this.controlOption;
|
|
84
|
+
if (lockWidth) {
|
|
85
|
+
_l7Utils.DOM.addStyle(container, `width: ${maxWidth}px`);
|
|
120
86
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
value: function getRoundNum(num) {
|
|
124
|
-
var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
|
|
125
|
-
var d = num / pow10;
|
|
126
|
-
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
127
|
-
return pow10 * d;
|
|
87
|
+
if (metric) {
|
|
88
|
+
this.mScale = _l7Utils.DOM.create('div', 'l7-control-scale-line', container);
|
|
128
89
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
value: function updateMetric(maxMeters) {
|
|
132
|
-
var meters = this.getRoundNum(maxMeters);
|
|
133
|
-
var label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
|
|
134
|
-
this.updateScale(this.mScale, label, meters / maxMeters);
|
|
90
|
+
if (imperial) {
|
|
91
|
+
this.iScale = _l7Utils.DOM.create('div', 'l7-control-scale-line', container);
|
|
135
92
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
93
|
+
this.update();
|
|
94
|
+
}
|
|
95
|
+
updateScale(scale, text, ratio) {
|
|
96
|
+
const {
|
|
97
|
+
maxWidth
|
|
98
|
+
} = this.controlOption;
|
|
99
|
+
scale.style.width = Math.round(maxWidth * ratio) + 'px';
|
|
100
|
+
scale.innerHTML = text;
|
|
101
|
+
}
|
|
102
|
+
getRoundNum(num) {
|
|
103
|
+
const pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
|
|
104
|
+
let d = num / pow10;
|
|
105
|
+
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
106
|
+
return pow10 * d;
|
|
107
|
+
}
|
|
108
|
+
updateMetric(maxMeters) {
|
|
109
|
+
const meters = this.getRoundNum(maxMeters);
|
|
110
|
+
const label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
|
|
111
|
+
this.updateScale(this.mScale, label, meters / maxMeters);
|
|
112
|
+
}
|
|
113
|
+
updateImperial(maxMeters) {
|
|
114
|
+
const maxFeet = maxMeters * 3.2808399;
|
|
115
|
+
let maxMiles;
|
|
116
|
+
let miles;
|
|
117
|
+
let feet;
|
|
118
|
+
if (maxFeet > 5280) {
|
|
119
|
+
maxMiles = maxFeet / 5280;
|
|
120
|
+
miles = this.getRoundNum(maxMiles);
|
|
121
|
+
this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
|
|
122
|
+
} else {
|
|
123
|
+
feet = this.getRoundNum(maxFeet);
|
|
124
|
+
this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
|
|
151
125
|
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.default = exports.Scale = Scale;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ILayer, L7Container } from '@antv/l7-core';
|
|
2
|
+
import type { IControlOption } from './baseControl';
|
|
3
|
+
import { Control } from './baseControl';
|
|
4
|
+
export interface ISwipeControlOption extends IControlOption {
|
|
5
|
+
/**
|
|
6
|
+
* 左侧的图层
|
|
7
|
+
*/
|
|
8
|
+
layers: ILayer[];
|
|
9
|
+
/**
|
|
10
|
+
* 右侧的图层
|
|
11
|
+
*/
|
|
12
|
+
rightLayers: ILayer[];
|
|
13
|
+
/**
|
|
14
|
+
* 设置卷帘的位置,值域为 0 到 1, 默认正中间为 0.5
|
|
15
|
+
*/
|
|
16
|
+
ratio?: number;
|
|
17
|
+
/**
|
|
18
|
+
* 卷帘方向设置('vertical' | 'horizontal'),默认 'vertical'
|
|
19
|
+
*/
|
|
20
|
+
orientation?: 'vertical' | 'horizontal';
|
|
21
|
+
}
|
|
22
|
+
export { Swipe };
|
|
23
|
+
export default class Swipe extends Control<ISwipeControlOption> {
|
|
24
|
+
/**
|
|
25
|
+
* 是否正在拖动卷帘
|
|
26
|
+
*/
|
|
27
|
+
private isMoving;
|
|
28
|
+
/**
|
|
29
|
+
* 掩膜图层实例
|
|
30
|
+
*/
|
|
31
|
+
private maskLayer;
|
|
32
|
+
getDefault(): ISwipeControlOption;
|
|
33
|
+
onAdd(): HTMLElement;
|
|
34
|
+
addTo(sceneContainer: L7Container): this;
|
|
35
|
+
onRemove(): void;
|
|
36
|
+
show(): void;
|
|
37
|
+
hide(): void;
|
|
38
|
+
setOptions(newOptions: Partial<ISwipeControlOption>): void;
|
|
39
|
+
private registerEvent;
|
|
40
|
+
private unRegisterEvent;
|
|
41
|
+
private setOrientationAndRatio;
|
|
42
|
+
private setLayers;
|
|
43
|
+
private addMaskToLayers;
|
|
44
|
+
private removeMaskFromLayers;
|
|
45
|
+
private move;
|
|
46
|
+
private getMaskGeoData;
|
|
47
|
+
private getMaskLayer;
|
|
48
|
+
private updateMask;
|
|
49
|
+
private getContainerDOMRect;
|
|
50
|
+
private getContainerSize;
|
|
51
|
+
private getBounds;
|
|
52
|
+
/**
|
|
53
|
+
* 添加要剪裁的图层
|
|
54
|
+
* @param layer 剪裁的图层
|
|
55
|
+
* @param addRight 是否添加图层到右侧, 默认添加到左侧.
|
|
56
|
+
*/
|
|
57
|
+
addLayer(layer: ILayer | ILayer[], addRight?: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* 移除剪裁的图层
|
|
60
|
+
*/
|
|
61
|
+
removeLayer(layer: ILayer | ILayer[]): void;
|
|
62
|
+
/**
|
|
63
|
+
* 清除所有图层
|
|
64
|
+
*/
|
|
65
|
+
removeLayers(): void;
|
|
66
|
+
}
|