@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,83 +1,51 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
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
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
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; } }
|
|
13
3
|
import { PositionType } from '@antv/l7-core';
|
|
14
4
|
import { DOM } from '@antv/l7-utils';
|
|
15
5
|
import Control from "./baseControl/control";
|
|
16
6
|
export { MouseLocation };
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_defineProperty(_assertThisInitialized(_this), "location", [0, 0]);
|
|
28
|
-
_defineProperty(_assertThisInitialized(_this), "onMouseMove", function (e) {
|
|
29
|
-
var position = _this.location;
|
|
30
|
-
var lngLat = e.lngLat || e.lnglat;
|
|
31
|
-
var transform = _this.controlOption.transform;
|
|
7
|
+
export default class MouseLocation extends Control {
|
|
8
|
+
constructor(...args) {
|
|
9
|
+
super(...args);
|
|
10
|
+
_defineProperty(this, "location", [0, 0]);
|
|
11
|
+
_defineProperty(this, "onMouseMove", e => {
|
|
12
|
+
let position = this.location;
|
|
13
|
+
const lngLat = e.lngLat || e.lnglat;
|
|
14
|
+
const {
|
|
15
|
+
transform
|
|
16
|
+
} = this.controlOption;
|
|
32
17
|
if (lngLat) {
|
|
33
18
|
position = [lngLat.lng, lngLat.lat];
|
|
34
19
|
}
|
|
35
|
-
|
|
20
|
+
this.location = position;
|
|
36
21
|
if (transform) {
|
|
37
22
|
position = transform(position);
|
|
38
23
|
}
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
this.insertLocation2HTML(position);
|
|
25
|
+
this.emit('locationChange', position);
|
|
41
26
|
});
|
|
42
|
-
return _this;
|
|
43
27
|
}
|
|
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
|
-
return container;
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "onRemove",
|
|
72
|
-
value: function onRemove() {
|
|
73
|
-
this.mapsService.off('mousemove', this.onMouseMove);
|
|
74
|
-
}
|
|
75
|
-
}, {
|
|
76
|
-
key: "insertLocation2HTML",
|
|
77
|
-
value: function insertLocation2HTML(position) {
|
|
78
|
-
this.container.innerText = position.join(', ');
|
|
79
|
-
}
|
|
80
|
-
}]);
|
|
81
|
-
return MouseLocation;
|
|
82
|
-
}(Control);
|
|
83
|
-
export { MouseLocation as default };
|
|
28
|
+
getLocation() {
|
|
29
|
+
return this.location;
|
|
30
|
+
}
|
|
31
|
+
getDefault(option) {
|
|
32
|
+
return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
|
|
33
|
+
position: PositionType.BOTTOMLEFT,
|
|
34
|
+
transform: ([lng, lat]) => {
|
|
35
|
+
return [+(+lng).toFixed(6), +(+lat).toFixed(6)];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
onAdd() {
|
|
40
|
+
const container = DOM.create('div', 'l7-control-mouse-location');
|
|
41
|
+
container.innerHTML = ' ';
|
|
42
|
+
this.mapsService.on('mousemove', this.onMouseMove);
|
|
43
|
+
return container;
|
|
44
|
+
}
|
|
45
|
+
onRemove() {
|
|
46
|
+
this.mapsService.off('mousemove', this.onMouseMove);
|
|
47
|
+
}
|
|
48
|
+
insertLocation2HTML(position) {
|
|
49
|
+
this.container.innerText = position.join(', ');
|
|
50
|
+
}
|
|
51
|
+
}
|
package/es/control/scale.js
CHANGED
|
@@ -1,149 +1,121 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
5
|
-
import _get from "@babel/runtime/helpers/esm/get";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
8
|
-
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
9
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
|
-
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); }; }
|
|
11
|
-
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; } }
|
|
12
3
|
import { DOM, lnglatDistance } from '@antv/l7-utils';
|
|
13
4
|
import { Control, PositionType } from "./baseControl";
|
|
14
5
|
export { Scale };
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
31
|
-
var maxMeters = lnglatDistance([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
32
|
-
_this.updateScales(maxMeters);
|
|
6
|
+
export default class Scale extends Control {
|
|
7
|
+
constructor(...args) {
|
|
8
|
+
super(...args);
|
|
9
|
+
_defineProperty(this, "mScale", void 0);
|
|
10
|
+
_defineProperty(this, "iScale", void 0);
|
|
11
|
+
_defineProperty(this, "update", () => {
|
|
12
|
+
const mapsService = this.mapsService;
|
|
13
|
+
const {
|
|
14
|
+
maxWidth
|
|
15
|
+
} = this.controlOption;
|
|
16
|
+
const y = mapsService.getSize()[1] / 2;
|
|
17
|
+
const p1 = mapsService.containerToLngLat([0, y]);
|
|
18
|
+
const p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
19
|
+
const maxMeters = lnglatDistance([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
20
|
+
this.updateScales(maxMeters);
|
|
33
21
|
});
|
|
34
|
-
return _this;
|
|
35
22
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
value: function setOptions(newOption) {
|
|
70
|
-
_get(_getPrototypeOf(Scale.prototype), "setOptions", this).call(this, newOption);
|
|
71
|
-
if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
|
|
72
|
-
this.resetScaleLines(this.container);
|
|
73
|
-
}
|
|
23
|
+
getDefault(option) {
|
|
24
|
+
return _objectSpread(_objectSpread({}, super.getDefault(option)), {}, {
|
|
25
|
+
name: 'scale',
|
|
26
|
+
position: PositionType.BOTTOMLEFT,
|
|
27
|
+
maxWidth: 100,
|
|
28
|
+
metric: true,
|
|
29
|
+
updateWhenIdle: false,
|
|
30
|
+
imperial: false,
|
|
31
|
+
lockWidth: true
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
onAdd() {
|
|
35
|
+
const className = 'l7-control-scale';
|
|
36
|
+
const container = DOM.create('div', className);
|
|
37
|
+
this.resetScaleLines(container);
|
|
38
|
+
const {
|
|
39
|
+
updateWhenIdle
|
|
40
|
+
} = this.controlOption;
|
|
41
|
+
this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
42
|
+
this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
43
|
+
return container;
|
|
44
|
+
}
|
|
45
|
+
onRemove() {
|
|
46
|
+
const {
|
|
47
|
+
updateWhenIdle
|
|
48
|
+
} = this.controlOption;
|
|
49
|
+
this.mapsService.off(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
50
|
+
this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
51
|
+
}
|
|
52
|
+
setOptions(newOption) {
|
|
53
|
+
super.setOptions(newOption);
|
|
54
|
+
if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
|
|
55
|
+
this.resetScaleLines(this.container);
|
|
74
56
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
if (imperial && maxMeters) {
|
|
85
|
-
this.updateImperial(maxMeters);
|
|
86
|
-
}
|
|
57
|
+
}
|
|
58
|
+
updateScales(maxMeters) {
|
|
59
|
+
const {
|
|
60
|
+
metric,
|
|
61
|
+
imperial
|
|
62
|
+
} = this.controlOption;
|
|
63
|
+
if (metric && maxMeters) {
|
|
64
|
+
this.updateMetric(maxMeters);
|
|
87
65
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
value: function resetScaleLines(container) {
|
|
91
|
-
DOM.clearChildren(container);
|
|
92
|
-
var _this$controlOption2 = this.controlOption,
|
|
93
|
-
metric = _this$controlOption2.metric,
|
|
94
|
-
imperial = _this$controlOption2.imperial,
|
|
95
|
-
maxWidth = _this$controlOption2.maxWidth,
|
|
96
|
-
lockWidth = _this$controlOption2.lockWidth;
|
|
97
|
-
if (lockWidth) {
|
|
98
|
-
DOM.addStyle(container, "width: ".concat(maxWidth, "px"));
|
|
99
|
-
}
|
|
100
|
-
if (metric) {
|
|
101
|
-
this.mScale = DOM.create('div', 'l7-control-scale-line', container);
|
|
102
|
-
}
|
|
103
|
-
if (imperial) {
|
|
104
|
-
this.iScale = DOM.create('div', 'l7-control-scale-line', container);
|
|
105
|
-
}
|
|
106
|
-
this.update();
|
|
66
|
+
if (imperial && maxMeters) {
|
|
67
|
+
this.updateImperial(maxMeters);
|
|
107
68
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
69
|
+
}
|
|
70
|
+
resetScaleLines(container) {
|
|
71
|
+
DOM.clearChildren(container);
|
|
72
|
+
const {
|
|
73
|
+
metric,
|
|
74
|
+
imperial,
|
|
75
|
+
maxWidth,
|
|
76
|
+
lockWidth
|
|
77
|
+
} = this.controlOption;
|
|
78
|
+
if (lockWidth) {
|
|
79
|
+
DOM.addStyle(container, `width: ${maxWidth}px`);
|
|
114
80
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
value: function getRoundNum(num) {
|
|
118
|
-
var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
|
|
119
|
-
var d = num / pow10;
|
|
120
|
-
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
121
|
-
return pow10 * d;
|
|
81
|
+
if (metric) {
|
|
82
|
+
this.mScale = DOM.create('div', 'l7-control-scale-line', container);
|
|
122
83
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
value: function updateMetric(maxMeters) {
|
|
126
|
-
var meters = this.getRoundNum(maxMeters);
|
|
127
|
-
var label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
|
|
128
|
-
this.updateScale(this.mScale, label, meters / maxMeters);
|
|
84
|
+
if (imperial) {
|
|
85
|
+
this.iScale = DOM.create('div', 'l7-control-scale-line', container);
|
|
129
86
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
87
|
+
this.update();
|
|
88
|
+
}
|
|
89
|
+
updateScale(scale, text, ratio) {
|
|
90
|
+
const {
|
|
91
|
+
maxWidth
|
|
92
|
+
} = this.controlOption;
|
|
93
|
+
scale.style.width = Math.round(maxWidth * ratio) + 'px';
|
|
94
|
+
scale.innerHTML = text;
|
|
95
|
+
}
|
|
96
|
+
getRoundNum(num) {
|
|
97
|
+
const pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
|
|
98
|
+
let d = num / pow10;
|
|
99
|
+
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
100
|
+
return pow10 * d;
|
|
101
|
+
}
|
|
102
|
+
updateMetric(maxMeters) {
|
|
103
|
+
const meters = this.getRoundNum(maxMeters);
|
|
104
|
+
const label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
|
|
105
|
+
this.updateScale(this.mScale, label, meters / maxMeters);
|
|
106
|
+
}
|
|
107
|
+
updateImperial(maxMeters) {
|
|
108
|
+
const maxFeet = maxMeters * 3.2808399;
|
|
109
|
+
let maxMiles;
|
|
110
|
+
let miles;
|
|
111
|
+
let feet;
|
|
112
|
+
if (maxFeet > 5280) {
|
|
113
|
+
maxMiles = maxFeet / 5280;
|
|
114
|
+
miles = this.getRoundNum(maxMiles);
|
|
115
|
+
this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
|
|
116
|
+
} else {
|
|
117
|
+
feet = this.getRoundNum(maxFeet);
|
|
118
|
+
this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
|
|
145
119
|
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
}(Control);
|
|
149
|
-
export { Scale as default };
|
|
120
|
+
}
|
|
121
|
+
}
|