@antv/l7-component 2.9.37 → 2.10.0
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 +53 -0
- package/es/constants/index.d.ts +60 -0
- package/es/constants/index.js +60 -0
- package/es/control/baseControl/buttonControl.d.ts +59 -0
- package/es/control/baseControl/buttonControl.js +191 -0
- package/es/control/baseControl/control.d.ts +113 -0
- package/es/control/baseControl/control.js +313 -0
- package/es/control/baseControl/index.d.ts +4 -0
- package/es/control/baseControl/index.js +4 -0
- package/es/control/baseControl/popperControl.d.ts +26 -0
- package/es/control/baseControl/popperControl.js +131 -0
- package/es/control/baseControl/selectControl.d.ts +46 -0
- package/es/control/baseControl/selectControl.js +232 -0
- package/es/control/exportImage.d.ts +18 -0
- package/es/control/exportImage.js +163 -0
- package/es/control/fullscreen.d.ts +19 -0
- package/es/control/fullscreen.js +151 -0
- package/es/control/geoLocate.d.ts +16 -0
- package/es/control/geoLocate.js +139 -0
- package/es/control/layerSwitch.d.ts +19 -0
- package/es/control/layerSwitch.js +172 -0
- package/es/control/logo.d.ts +10 -6
- package/es/control/logo.js +41 -11
- package/es/control/mapTheme.d.ts +10 -0
- package/es/control/mapTheme.js +135 -0
- package/es/control/mouseLocation.d.ts +15 -0
- package/es/control/mouseLocation.js +104 -0
- package/es/control/scale.d.ts +20 -10
- package/es/control/scale.js +77 -53
- package/es/control/zoom.d.ts +21 -10
- package/es/control/zoom.js +76 -49
- package/es/css/button.less +70 -0
- package/es/css/control.less +71 -0
- package/es/css/index.css +567 -0
- package/es/css/index.less +12 -0
- package/es/css/l7.less +60 -0
- package/es/css/layerPopup.less +8 -0
- package/es/css/logo.less +18 -0
- package/es/css/mouseLocation.less +9 -0
- package/es/css/popper.less +64 -0
- package/es/css/popup.less +169 -0
- package/es/css/scale.less +34 -0
- package/es/css/select.less +86 -0
- package/es/css/variables.less +28 -0
- package/es/css/zoom.less +21 -0
- package/es/images/logo.png +0 -0
- package/es/images/quanping.svg +12 -0
- package/es/index.d.ts +15 -8
- package/es/index.js +15 -9
- package/es/interface.d.ts +1 -20
- package/es/popup/layerPopup.d.ts +78 -0
- package/es/popup/layerPopup.js +308 -0
- package/es/popup/popup.d.ts +147 -0
- package/es/popup/popup.js +636 -0
- package/es/utils/icon.d.ts +1 -0
- package/es/utils/icon.js +9 -0
- package/es/utils/popper.d.ts +75 -0
- package/es/utils/popper.js +286 -0
- package/es/utils/screenfull.d.ts +2 -0
- package/es/utils/screenfull.js +157 -0
- package/lib/assets/iconfont/iconfont.js +55 -0
- package/lib/constants/index.js +68 -0
- package/lib/control/baseControl/buttonControl.js +207 -0
- package/lib/control/baseControl/control.js +340 -0
- package/lib/control/baseControl/index.js +57 -0
- package/lib/control/baseControl/popperControl.js +142 -0
- package/lib/control/baseControl/selectControl.js +253 -0
- package/lib/control/exportImage.js +177 -0
- package/lib/control/fullscreen.js +164 -0
- package/lib/control/geoLocate.js +154 -0
- package/lib/control/layerSwitch.js +183 -0
- package/lib/control/logo.js +50 -23
- package/lib/control/mapTheme.js +151 -0
- package/lib/control/mouseLocation.js +120 -0
- package/lib/control/scale.js +82 -62
- package/lib/control/zoom.js +78 -59
- package/lib/css/button.less +70 -0
- package/lib/css/control.less +71 -0
- package/lib/css/index.css +567 -0
- package/lib/css/index.less +12 -0
- package/lib/css/l7.less +60 -0
- package/lib/css/layerPopup.less +8 -0
- package/lib/css/logo.less +18 -0
- package/lib/css/mouseLocation.less +9 -0
- package/lib/css/popper.less +64 -0
- package/lib/css/popup.less +169 -0
- package/lib/css/scale.less +34 -0
- package/lib/css/select.less +86 -0
- package/lib/css/variables.less +28 -0
- package/lib/css/zoom.less +21 -0
- package/lib/images/logo.png +0 -0
- package/lib/images/quanping.svg +12 -0
- package/lib/index.js +165 -50
- package/lib/popup/layerPopup.js +317 -0
- package/lib/popup/popup.js +651 -0
- package/lib/utils/icon.js +18 -0
- package/lib/utils/popper.js +297 -0
- package/lib/utils/screenfull.js +167 -0
- package/package.json +8 -5
- package/es/control/BaseControl.d.ts +0 -27
- package/es/control/BaseControl.js +0 -134
- package/es/control/layer.d.ts +0 -38
- package/es/control/layer.js +0 -340
- package/es/css/l7.css +0 -502
- package/es/popup.d.ts +0 -35
- package/es/popup.js +0 -300
- package/lib/control/BaseControl.js +0 -160
- package/lib/control/layer.js +0 -362
- package/lib/css/l7.css +0 -502
- package/lib/popup.js +0 -317
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
6
|
+
import _get from "@babel/runtime/helpers/get";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
9
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
|
+
|
|
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
|
+
|
|
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
|
+
|
|
16
|
+
import { PositionType } from '@antv/l7-core';
|
|
17
|
+
import { DOM } from '@antv/l7-utils';
|
|
18
|
+
import Control from "./baseControl/control";
|
|
19
|
+
export { MouseLocation };
|
|
20
|
+
|
|
21
|
+
var MouseLocation = /*#__PURE__*/function (_Control) {
|
|
22
|
+
_inherits(MouseLocation, _Control);
|
|
23
|
+
|
|
24
|
+
var _super = _createSuper(MouseLocation);
|
|
25
|
+
|
|
26
|
+
function MouseLocation() {
|
|
27
|
+
var _this;
|
|
28
|
+
|
|
29
|
+
_classCallCheck(this, MouseLocation);
|
|
30
|
+
|
|
31
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
32
|
+
args[_key] = arguments[_key];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
36
|
+
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "location", [0, 0]);
|
|
38
|
+
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "onMouseMove", function (e) {
|
|
40
|
+
var position = _this.location;
|
|
41
|
+
var lngLat = e.lngLat || e.lnglat;
|
|
42
|
+
var transform = _this.controlOption.transform;
|
|
43
|
+
|
|
44
|
+
if (lngLat) {
|
|
45
|
+
position = [lngLat.lng, lngLat.lat];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_this.location = position;
|
|
49
|
+
|
|
50
|
+
if (transform) {
|
|
51
|
+
position = transform(position);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_this.insertLocation2HTML(position);
|
|
55
|
+
|
|
56
|
+
_this.emit('locationChange', position);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return _this;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
_createClass(MouseLocation, [{
|
|
63
|
+
key: "getLocation",
|
|
64
|
+
value: function getLocation() {
|
|
65
|
+
return this.location;
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "getDefault",
|
|
69
|
+
value: function getDefault(option) {
|
|
70
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(MouseLocation.prototype), "getDefault", this).call(this, option)), {}, {
|
|
71
|
+
position: PositionType.BOTTOMLEFT,
|
|
72
|
+
transform: function transform(_ref) {
|
|
73
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
74
|
+
lng = _ref2[0],
|
|
75
|
+
lat = _ref2[1];
|
|
76
|
+
|
|
77
|
+
return [+(+lng).toFixed(6), +(+lat).toFixed(6)];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "onAdd",
|
|
83
|
+
value: function onAdd() {
|
|
84
|
+
var container = DOM.create('div', 'l7-control-mouse-location');
|
|
85
|
+
container.innerHTML = ' ';
|
|
86
|
+
this.mapsService.on('mousemove', this.onMouseMove);
|
|
87
|
+
return container;
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "onRemove",
|
|
91
|
+
value: function onRemove() {
|
|
92
|
+
this.mapsService.off('mousemove', this.onMouseMove);
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "insertLocation2HTML",
|
|
96
|
+
value: function insertLocation2HTML(position) {
|
|
97
|
+
this.container.innerText = position.join(', ');
|
|
98
|
+
}
|
|
99
|
+
}]);
|
|
100
|
+
|
|
101
|
+
return MouseLocation;
|
|
102
|
+
}(Control);
|
|
103
|
+
|
|
104
|
+
export { MouseLocation as default };
|
package/es/control/scale.d.ts
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Control, IControlOption, PositionType } from './baseControl';
|
|
2
|
+
export interface IScaleControlOption extends IControlOption {
|
|
3
|
+
lockWidth: boolean;
|
|
4
|
+
maxWidth: number;
|
|
5
|
+
metric: boolean;
|
|
6
|
+
updateWhenIdle: boolean;
|
|
7
|
+
imperial: boolean;
|
|
8
|
+
}
|
|
9
|
+
export { Scale };
|
|
10
|
+
export default class Scale extends Control<IScaleControlOption> {
|
|
4
11
|
private mScale;
|
|
5
12
|
private iScale;
|
|
6
|
-
|
|
7
|
-
|
|
13
|
+
getDefault(option: Partial<IScaleControlOption>): {
|
|
14
|
+
name: string;
|
|
8
15
|
position: PositionType;
|
|
9
16
|
maxWidth: number;
|
|
10
17
|
metric: boolean;
|
|
11
18
|
updateWhenIdle: boolean;
|
|
12
19
|
imperial: boolean;
|
|
13
|
-
|
|
20
|
+
lockWidth: boolean;
|
|
21
|
+
className?: string | undefined;
|
|
22
|
+
style?: string | undefined;
|
|
14
23
|
};
|
|
15
24
|
onAdd(): any;
|
|
16
25
|
onRemove(): void;
|
|
17
|
-
|
|
26
|
+
setOptions(newOption: Partial<IScaleControlOption>): void;
|
|
27
|
+
update: () => void;
|
|
18
28
|
updateScales(maxMeters: number): void;
|
|
19
|
-
private
|
|
20
|
-
private updateImperial;
|
|
29
|
+
private resetScaleLines;
|
|
21
30
|
private updateScale;
|
|
22
31
|
private getRoundNum;
|
|
23
|
-
private
|
|
32
|
+
private updateMetric;
|
|
33
|
+
private updateImperial;
|
|
24
34
|
}
|
package/es/control/scale.js
CHANGED
|
@@ -1,56 +1,73 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
+
import _get from "@babel/runtime/helpers/get";
|
|
4
6
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
10
|
|
|
8
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); }; }
|
|
9
12
|
|
|
10
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; } }
|
|
11
14
|
|
|
12
|
-
import {
|
|
13
|
-
import Control,
|
|
15
|
+
import { DOM, lnglatDistance } from '@antv/l7-utils';
|
|
16
|
+
import { Control, PositionType } from "./baseControl";
|
|
17
|
+
export { Scale };
|
|
14
18
|
|
|
15
19
|
var Scale = /*#__PURE__*/function (_Control) {
|
|
16
20
|
_inherits(Scale, _Control);
|
|
17
21
|
|
|
18
22
|
var _super = _createSuper(Scale);
|
|
19
23
|
|
|
20
|
-
function Scale(
|
|
24
|
+
function Scale() {
|
|
21
25
|
var _this;
|
|
22
26
|
|
|
23
27
|
_classCallCheck(this, Scale);
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
|
+
args[_key] = arguments[_key];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
34
|
+
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "update", function () {
|
|
36
|
+
var mapsService = _this.mapsService;
|
|
37
|
+
var maxWidth = _this.controlOption.maxWidth;
|
|
38
|
+
var y = mapsService.getSize()[1] / 2;
|
|
39
|
+
var p1 = mapsService.containerToLngLat([0, y]);
|
|
40
|
+
var p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
41
|
+
var maxMeters = lnglatDistance([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
42
|
+
|
|
43
|
+
_this.updateScales(maxMeters);
|
|
44
|
+
});
|
|
45
|
+
|
|
27
46
|
return _this;
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
_createClass(Scale, [{
|
|
31
50
|
key: "getDefault",
|
|
32
|
-
value: function getDefault() {
|
|
33
|
-
return {
|
|
51
|
+
value: function getDefault(option) {
|
|
52
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(Scale.prototype), "getDefault", this).call(this, option)), {}, {
|
|
53
|
+
name: 'scale',
|
|
34
54
|
position: PositionType.BOTTOMLEFT,
|
|
35
55
|
maxWidth: 100,
|
|
36
56
|
metric: true,
|
|
37
57
|
updateWhenIdle: false,
|
|
38
58
|
imperial: false,
|
|
39
|
-
|
|
40
|
-
};
|
|
59
|
+
lockWidth: true
|
|
60
|
+
});
|
|
41
61
|
}
|
|
42
62
|
}, {
|
|
43
63
|
key: "onAdd",
|
|
44
64
|
value: function onAdd() {
|
|
45
65
|
var className = 'l7-control-scale';
|
|
46
66
|
var container = DOM.create('div', className);
|
|
47
|
-
this.
|
|
48
|
-
var updateWhenIdle = this.controlOption.updateWhenIdle;
|
|
49
|
-
// 高德zoomchange
|
|
50
|
-
|
|
67
|
+
this.resetScaleLines(container);
|
|
68
|
+
var updateWhenIdle = this.controlOption.updateWhenIdle;
|
|
51
69
|
this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
52
70
|
this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
53
|
-
this.update();
|
|
54
71
|
return container;
|
|
55
72
|
}
|
|
56
73
|
}, {
|
|
@@ -61,15 +78,13 @@ var Scale = /*#__PURE__*/function (_Control) {
|
|
|
61
78
|
this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
62
79
|
}
|
|
63
80
|
}, {
|
|
64
|
-
key: "
|
|
65
|
-
value: function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var maxMeters = lnglatDistance([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
72
|
-
this.updateScales(maxMeters);
|
|
81
|
+
key: "setOptions",
|
|
82
|
+
value: function setOptions(newOption) {
|
|
83
|
+
_get(_getPrototypeOf(Scale.prototype), "setOptions", this).call(this, newOption);
|
|
84
|
+
|
|
85
|
+
if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
|
|
86
|
+
this.resetScaleLines(this.container);
|
|
87
|
+
}
|
|
73
88
|
}
|
|
74
89
|
}, {
|
|
75
90
|
key: "updateScales",
|
|
@@ -86,6 +101,45 @@ var Scale = /*#__PURE__*/function (_Control) {
|
|
|
86
101
|
this.updateImperial(maxMeters);
|
|
87
102
|
}
|
|
88
103
|
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "resetScaleLines",
|
|
106
|
+
value: function resetScaleLines(container) {
|
|
107
|
+
DOM.clearChildren(container);
|
|
108
|
+
var _this$controlOption2 = this.controlOption,
|
|
109
|
+
metric = _this$controlOption2.metric,
|
|
110
|
+
imperial = _this$controlOption2.imperial,
|
|
111
|
+
maxWidth = _this$controlOption2.maxWidth,
|
|
112
|
+
lockWidth = _this$controlOption2.lockWidth;
|
|
113
|
+
|
|
114
|
+
if (lockWidth) {
|
|
115
|
+
DOM.addStyle(container, "width: ".concat(maxWidth, "px"));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (metric) {
|
|
119
|
+
this.mScale = DOM.create('div', 'l7-control-scale-line', container);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (imperial) {
|
|
123
|
+
this.iScale = DOM.create('div', 'l7-control-scale-line', container);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
this.update();
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "updateScale",
|
|
130
|
+
value: function updateScale(scale, text, ratio) {
|
|
131
|
+
var maxWidth = this.controlOption.maxWidth;
|
|
132
|
+
scale.style.width = Math.round(maxWidth * ratio) + 'px';
|
|
133
|
+
scale.innerHTML = text;
|
|
134
|
+
}
|
|
135
|
+
}, {
|
|
136
|
+
key: "getRoundNum",
|
|
137
|
+
value: function getRoundNum(num) {
|
|
138
|
+
var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
|
|
139
|
+
var d = num / pow10;
|
|
140
|
+
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
141
|
+
return pow10 * d;
|
|
142
|
+
}
|
|
89
143
|
}, {
|
|
90
144
|
key: "updateMetric",
|
|
91
145
|
value: function updateMetric(maxMeters) {
|
|
@@ -110,36 +164,6 @@ var Scale = /*#__PURE__*/function (_Control) {
|
|
|
110
164
|
this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
|
|
111
165
|
}
|
|
112
166
|
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "updateScale",
|
|
115
|
-
value: function updateScale(scale, text, ratio) {
|
|
116
|
-
var maxWidth = this.controlOption.maxWidth;
|
|
117
|
-
scale.style.width = Math.round(maxWidth * ratio) + 'px';
|
|
118
|
-
scale.innerHTML = text;
|
|
119
|
-
}
|
|
120
|
-
}, {
|
|
121
|
-
key: "getRoundNum",
|
|
122
|
-
value: function getRoundNum(num) {
|
|
123
|
-
var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
|
|
124
|
-
var d = num / pow10;
|
|
125
|
-
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
126
|
-
return pow10 * d;
|
|
127
|
-
}
|
|
128
|
-
}, {
|
|
129
|
-
key: "addScales",
|
|
130
|
-
value: function addScales(className, container) {
|
|
131
|
-
var _this$controlOption2 = this.controlOption,
|
|
132
|
-
metric = _this$controlOption2.metric,
|
|
133
|
-
imperial = _this$controlOption2.imperial;
|
|
134
|
-
|
|
135
|
-
if (metric) {
|
|
136
|
-
this.mScale = DOM.create('div', className, container);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (imperial) {
|
|
140
|
-
this.iScale = DOM.create('div', className, container);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
167
|
}]);
|
|
144
168
|
|
|
145
169
|
return Scale;
|
package/es/control/zoom.d.ts
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { PositionType } from '@antv/l7-core';
|
|
2
|
+
import { ELType } from '@antv/l7-utils/src/dom';
|
|
3
|
+
import { Control, IControlOption } from './baseControl';
|
|
4
|
+
export interface IZoomControlOption extends IControlOption {
|
|
5
|
+
zoomInText: ELType | string;
|
|
6
|
+
zoomInTitle: string;
|
|
7
|
+
zoomOutText: ELType | string;
|
|
8
|
+
zoomOutTitle: string;
|
|
9
|
+
}
|
|
10
|
+
export { Zoom };
|
|
11
|
+
export default class Zoom extends Control<IZoomControlOption> {
|
|
4
12
|
private disabled;
|
|
5
13
|
private zoomInButton;
|
|
6
14
|
private zoomOutButton;
|
|
7
|
-
|
|
8
|
-
getDefault(): {
|
|
15
|
+
getDefault(option: Partial<IZoomControlOption>): {
|
|
9
16
|
position: PositionType;
|
|
10
|
-
|
|
17
|
+
name: string;
|
|
18
|
+
zoomInText: SVGSVGElement;
|
|
11
19
|
zoomInTitle: string;
|
|
12
|
-
zoomOutText:
|
|
20
|
+
zoomOutText: SVGSVGElement;
|
|
13
21
|
zoomOutTitle: string;
|
|
14
|
-
|
|
22
|
+
className?: string | undefined;
|
|
23
|
+
style?: string | undefined;
|
|
15
24
|
};
|
|
25
|
+
setOptions(newOptions: Partial<IZoomControlOption>): void;
|
|
16
26
|
onAdd(): HTMLElement;
|
|
17
27
|
onRemove(): void;
|
|
18
28
|
disable(): this;
|
|
19
29
|
enable(): this;
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
zoomIn: () => void;
|
|
31
|
+
zoomOut: () => void;
|
|
32
|
+
private resetButtonGroup;
|
|
22
33
|
private createButton;
|
|
23
34
|
private updateDisabled;
|
|
24
35
|
}
|
package/es/control/zoom.js
CHANGED
|
@@ -1,54 +1,98 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
+
import _get from "@babel/runtime/helpers/get";
|
|
4
6
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
10
|
|
|
8
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); }; }
|
|
9
12
|
|
|
10
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; } }
|
|
11
14
|
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
15
|
+
import { PositionType } from '@antv/l7-core';
|
|
16
|
+
import { DOM } from '@antv/l7-utils';
|
|
17
|
+
import { createL7Icon } from "../utils/icon";
|
|
18
|
+
import { Control } from "./baseControl";
|
|
19
|
+
export { Zoom };
|
|
14
20
|
|
|
15
21
|
var Zoom = /*#__PURE__*/function (_Control) {
|
|
16
22
|
_inherits(Zoom, _Control);
|
|
17
23
|
|
|
18
24
|
var _super = _createSuper(Zoom);
|
|
19
25
|
|
|
20
|
-
function Zoom(
|
|
26
|
+
function Zoom() {
|
|
21
27
|
var _this;
|
|
22
28
|
|
|
23
29
|
_classCallCheck(this, Zoom);
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
32
|
+
args[_key] = arguments[_key];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
36
|
+
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "zoomIn", function () {
|
|
38
|
+
if (!_this.disabled && _this.mapsService.getZoom() < _this.mapsService.getMaxZoom()) {
|
|
39
|
+
_this.mapsService.zoomIn();
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "zoomOut", function () {
|
|
44
|
+
if (!_this.disabled && _this.mapsService.getZoom() > _this.mapsService.getMinZoom()) {
|
|
45
|
+
_this.mapsService.zoomOut();
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "updateDisabled", function () {
|
|
50
|
+
var mapsService = _this.mapsService;
|
|
51
|
+
|
|
52
|
+
_this.zoomInButton.removeAttribute('disabled');
|
|
53
|
+
|
|
54
|
+
_this.zoomOutButton.removeAttribute('disabled');
|
|
55
|
+
|
|
56
|
+
if (_this.disabled || mapsService.getZoom() <= mapsService.getMinZoom()) {
|
|
57
|
+
_this.zoomOutButton.setAttribute('disabled', 'true');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (_this.disabled || mapsService.getZoom() >= mapsService.getMaxZoom()) {
|
|
61
|
+
_this.zoomInButton.setAttribute('disabled', 'true');
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
27
65
|
return _this;
|
|
28
66
|
}
|
|
29
67
|
|
|
30
68
|
_createClass(Zoom, [{
|
|
31
69
|
key: "getDefault",
|
|
32
|
-
value: function getDefault() {
|
|
33
|
-
return {
|
|
34
|
-
position: PositionType.
|
|
35
|
-
|
|
70
|
+
value: function getDefault(option) {
|
|
71
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(Zoom.prototype), "getDefault", this).call(this, option)), {}, {
|
|
72
|
+
position: PositionType.BOTTOMRIGHT,
|
|
73
|
+
name: 'zoom',
|
|
74
|
+
zoomInText: createL7Icon('l7-icon-enlarge'),
|
|
36
75
|
zoomInTitle: 'Zoom in',
|
|
37
|
-
zoomOutText: '
|
|
38
|
-
zoomOutTitle: 'Zoom out'
|
|
39
|
-
|
|
40
|
-
|
|
76
|
+
zoomOutText: createL7Icon('l7-icon-narrow'),
|
|
77
|
+
zoomOutTitle: 'Zoom out'
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "setOptions",
|
|
82
|
+
value: function setOptions(newOptions) {
|
|
83
|
+
_get(_getPrototypeOf(Zoom.prototype), "setOptions", this).call(this, newOptions);
|
|
84
|
+
|
|
85
|
+
if (this.checkUpdateOption(newOptions, ['zoomInText', 'zoomInTitle', 'zoomOutText', 'zoomOutTitle'])) {
|
|
86
|
+
this.resetButtonGroup(this.container);
|
|
87
|
+
}
|
|
41
88
|
}
|
|
42
89
|
}, {
|
|
43
90
|
key: "onAdd",
|
|
44
91
|
value: function onAdd() {
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
this.zoomInButton = this.createButton(this.controlOption.zoomInText, this.controlOption.zoomInTitle, zoomName + '-in', container, this.zoomIn);
|
|
48
|
-
this.zoomOutButton = this.createButton(this.controlOption.zoomOutText, this.controlOption.zoomOutTitle, zoomName + '-out', container, this.zoomOut);
|
|
92
|
+
var container = DOM.create('div', 'l7-control-zoom');
|
|
93
|
+
this.resetButtonGroup(container);
|
|
49
94
|
this.mapsService.on('zoomend', this.updateDisabled);
|
|
50
95
|
this.mapsService.on('zoomchange', this.updateDisabled);
|
|
51
|
-
this.updateDisabled();
|
|
52
96
|
return container;
|
|
53
97
|
}
|
|
54
98
|
}, {
|
|
@@ -72,45 +116,28 @@ var Zoom = /*#__PURE__*/function (_Control) {
|
|
|
72
116
|
return this;
|
|
73
117
|
}
|
|
74
118
|
}, {
|
|
75
|
-
key: "
|
|
76
|
-
value: function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, {
|
|
82
|
-
key: "zoomOut",
|
|
83
|
-
value: function zoomOut() {
|
|
84
|
-
if (!this.disabled && this.mapsService.getZoom() > this.mapsService.getMinZoom()) {
|
|
85
|
-
this.mapsService.zoomOut();
|
|
86
|
-
}
|
|
119
|
+
key: "resetButtonGroup",
|
|
120
|
+
value: function resetButtonGroup(container) {
|
|
121
|
+
DOM.clearChildren(container);
|
|
122
|
+
this.zoomInButton = this.createButton(this.controlOption.zoomInText, this.controlOption.zoomInTitle, 'l7-button-control', container, this.zoomIn);
|
|
123
|
+
this.zoomOutButton = this.createButton(this.controlOption.zoomOutText, this.controlOption.zoomOutTitle, 'l7-button-control', container, this.zoomOut);
|
|
124
|
+
this.updateDisabled();
|
|
87
125
|
}
|
|
88
126
|
}, {
|
|
89
127
|
key: "createButton",
|
|
90
128
|
value: function createButton(html, tile, className, container, fn) {
|
|
91
|
-
var link = DOM.create('
|
|
92
|
-
|
|
129
|
+
var link = DOM.create('button', className, container);
|
|
130
|
+
|
|
131
|
+
if (typeof html === 'string') {
|
|
132
|
+
link.innerHTML = html;
|
|
133
|
+
} else {
|
|
134
|
+
link.append(html);
|
|
135
|
+
}
|
|
136
|
+
|
|
93
137
|
link.title = tile;
|
|
94
|
-
link.href = 'javascript:void(0)';
|
|
95
138
|
link.addEventListener('click', fn);
|
|
96
139
|
return link;
|
|
97
140
|
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "updateDisabled",
|
|
100
|
-
value: function updateDisabled() {
|
|
101
|
-
var mapsService = this.mapsService;
|
|
102
|
-
var className = 'l7-disabled';
|
|
103
|
-
DOM.removeClass(this.zoomInButton, className);
|
|
104
|
-
DOM.removeClass(this.zoomOutButton, className);
|
|
105
|
-
|
|
106
|
-
if (this.disabled || mapsService.getZoom() <= mapsService.getMinZoom()) {
|
|
107
|
-
DOM.addClass(this.zoomOutButton, className);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (this.disabled || mapsService.getZoom() >= mapsService.getMaxZoom()) {
|
|
111
|
-
DOM.addClass(this.zoomInButton, className);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
141
|
}]);
|
|
115
142
|
|
|
116
143
|
return Zoom;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@import 'variables.less';
|
|
2
|
+
|
|
3
|
+
.l7-button-control {
|
|
4
|
+
min-width: @l7-btn-control-size;
|
|
5
|
+
height: @l7-btn-control-size;
|
|
6
|
+
background-color: @l7-control-bg-color;
|
|
7
|
+
border-width: 0;
|
|
8
|
+
border-radius: @l7-btn-control-border-radius;
|
|
9
|
+
outline: 0;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
transition: all 0.2s;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
align-items: center;
|
|
15
|
+
padding: 0 ((@l7-btn-control-size - @l7-btn-icon-size) / 2);
|
|
16
|
+
box-shadow: @l7-control-shadow;
|
|
17
|
+
line-height: 16px;
|
|
18
|
+
|
|
19
|
+
.l7-iconfont {
|
|
20
|
+
fill: @l7-control-font-color;
|
|
21
|
+
color: @l7-control-font-color;
|
|
22
|
+
width: @l7-btn-icon-size;
|
|
23
|
+
height: @l7-btn-icon-size;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.l7-button-control--row {
|
|
27
|
+
padding: 0 16px 0 13px;
|
|
28
|
+
|
|
29
|
+
* + .l7-button-control__text {
|
|
30
|
+
margin-left: 8px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.l7-button-control--column {
|
|
35
|
+
height: @l7-btn-column-height;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
.l7-iconfont {
|
|
38
|
+
margin-top: 3px;
|
|
39
|
+
}
|
|
40
|
+
.l7-button-control__text {
|
|
41
|
+
margin-top: 3px;
|
|
42
|
+
font-size: 10px;
|
|
43
|
+
transform: scale(0.83333);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
&:not(:disabled) {
|
|
48
|
+
&:hover {
|
|
49
|
+
background-color: @l7-btn-control-bg-hover-color;
|
|
50
|
+
}
|
|
51
|
+
&:active {
|
|
52
|
+
background-color: @l7-btn-control-bg-active-color;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
&:disabled {
|
|
56
|
+
background-color: @l7-btn-control-disabled-bg-color;
|
|
57
|
+
color: @l7-btn-control-disabled-font-color;
|
|
58
|
+
cursor: not-allowed;
|
|
59
|
+
.l7-iconfont {
|
|
60
|
+
fill: @l7-btn-control-disabled-font-color;
|
|
61
|
+
color: @l7-btn-control-disabled-font-color;
|
|
62
|
+
}
|
|
63
|
+
&:hover {
|
|
64
|
+
background-color: @l7-btn-control-disabled-bg-color;
|
|
65
|
+
}
|
|
66
|
+
&:active {
|
|
67
|
+
background-color: @l7-btn-control-disabled-bg-color;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|