@antv/l7-component 2.9.32-alpha.2 → 2.9.32-alpha.4
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 +107 -0
- package/es/control/baseControl/control.js +288 -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 +227 -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/layerControl.d.ts +21 -0
- package/es/control/layerControl.js +172 -0
- package/es/control/logo.d.ts +13 -0
- package/es/control/logo.js +87 -0
- 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 +34 -0
- package/es/control/scale.js +172 -0
- package/es/control/zoom.d.ts +34 -0
- package/es/control/zoom.js +146 -0
- 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/layers.png +0 -0
- package/es/images/layers.svg +1 -0
- package/es/images/logo.png +0 -0
- package/es/images/quanping.svg +12 -0
- package/es/index.d.ts +18 -0
- package/es/index.js +59 -0
- package/es/interface.d.ts +18 -0
- package/es/interface.js +1 -0
- package/es/marker-layer.d.ts +53 -0
- package/es/marker-layer.js +363 -0
- package/es/marker.d.ts +49 -0
- package/es/marker.js +434 -0
- 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/anchor.d.ts +22 -0
- package/es/utils/anchor.js +35 -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 +39 -0
- package/lib/constants/index.js +90 -0
- package/lib/control/baseControl/buttonControl.js +118 -0
- package/lib/control/baseControl/control.js +172 -0
- package/lib/control/baseControl/index.js +22 -0
- package/lib/control/baseControl/popperControl.js +108 -0
- package/lib/control/baseControl/selectControl.js +153 -0
- package/lib/control/exportImage.js +83 -0
- package/lib/control/fullscreen.js +109 -0
- package/lib/control/geoLocate.js +78 -0
- package/lib/control/layerControl.js +136 -0
- package/lib/control/logo.js +74 -0
- package/lib/control/mapTheme.js +92 -0
- package/lib/control/mouseLocation.js +79 -0
- package/lib/control/scale.js +136 -0
- package/lib/control/zoom.js +119 -0
- 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/layers.png +0 -0
- package/lib/images/layers.svg +1 -0
- package/lib/images/logo.png +0 -0
- package/lib/images/quanping.svg +12 -0
- package/lib/index.js +51 -0
- package/lib/interface.js +17 -0
- package/lib/marker-layer.js +263 -0
- package/lib/marker.js +307 -0
- package/lib/popup/layerPopup.js +200 -0
- package/lib/popup/popup.js +388 -0
- package/lib/utils/anchor.js +63 -0
- package/lib/utils/icon.js +37 -0
- package/lib/utils/popper.js +209 -0
- package/lib/utils/screenfull.js +160 -0
- package/package.json +5 -5
|
@@ -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 };
|
|
@@ -0,0 +1,34 @@
|
|
|
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> {
|
|
11
|
+
private mScale;
|
|
12
|
+
private iScale;
|
|
13
|
+
getDefault(option: Partial<IScaleControlOption>): {
|
|
14
|
+
name: string;
|
|
15
|
+
position: PositionType;
|
|
16
|
+
maxWidth: number;
|
|
17
|
+
metric: boolean;
|
|
18
|
+
updateWhenIdle: boolean;
|
|
19
|
+
imperial: boolean;
|
|
20
|
+
lockWidth: boolean;
|
|
21
|
+
className?: string | undefined;
|
|
22
|
+
style?: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
onAdd(): any;
|
|
25
|
+
onRemove(): void;
|
|
26
|
+
setOptions(newOption: Partial<IScaleControlOption>): void;
|
|
27
|
+
update: () => void;
|
|
28
|
+
updateScales(maxMeters: number): void;
|
|
29
|
+
private resetScaleLines;
|
|
30
|
+
private updateScale;
|
|
31
|
+
private getRoundNum;
|
|
32
|
+
private updateMetric;
|
|
33
|
+
private updateImperial;
|
|
34
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
+
import _get from "@babel/runtime/helpers/get";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
+
|
|
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
|
+
|
|
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
|
+
|
|
15
|
+
import { DOM, lnglatDistance } from '@antv/l7-utils';
|
|
16
|
+
import { Control, PositionType } from "./baseControl";
|
|
17
|
+
export { Scale };
|
|
18
|
+
|
|
19
|
+
var Scale = /*#__PURE__*/function (_Control) {
|
|
20
|
+
_inherits(Scale, _Control);
|
|
21
|
+
|
|
22
|
+
var _super = _createSuper(Scale);
|
|
23
|
+
|
|
24
|
+
function Scale() {
|
|
25
|
+
var _this;
|
|
26
|
+
|
|
27
|
+
_classCallCheck(this, Scale);
|
|
28
|
+
|
|
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
|
+
|
|
46
|
+
return _this;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
_createClass(Scale, [{
|
|
50
|
+
key: "getDefault",
|
|
51
|
+
value: function getDefault(option) {
|
|
52
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(Scale.prototype), "getDefault", this).call(this, option)), {}, {
|
|
53
|
+
name: 'scale',
|
|
54
|
+
position: PositionType.BOTTOMLEFT,
|
|
55
|
+
maxWidth: 100,
|
|
56
|
+
metric: true,
|
|
57
|
+
updateWhenIdle: false,
|
|
58
|
+
imperial: false,
|
|
59
|
+
lockWidth: true
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
key: "onAdd",
|
|
64
|
+
value: function onAdd() {
|
|
65
|
+
var className = 'l7-control-scale';
|
|
66
|
+
var container = DOM.create('div', className);
|
|
67
|
+
this.resetScaleLines(container);
|
|
68
|
+
var updateWhenIdle = this.controlOption.updateWhenIdle;
|
|
69
|
+
this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
70
|
+
this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
71
|
+
return container;
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "onRemove",
|
|
75
|
+
value: function onRemove() {
|
|
76
|
+
var updateWhenIdle = this.controlOption.updateWhenIdle;
|
|
77
|
+
this.mapsService.off(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
78
|
+
this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
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
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "updateScales",
|
|
91
|
+
value: function updateScales(maxMeters) {
|
|
92
|
+
var _this$controlOption = this.controlOption,
|
|
93
|
+
metric = _this$controlOption.metric,
|
|
94
|
+
imperial = _this$controlOption.imperial;
|
|
95
|
+
|
|
96
|
+
if (metric && maxMeters) {
|
|
97
|
+
this.updateMetric(maxMeters);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (imperial && maxMeters) {
|
|
101
|
+
this.updateImperial(maxMeters);
|
|
102
|
+
}
|
|
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
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "updateMetric",
|
|
145
|
+
value: function updateMetric(maxMeters) {
|
|
146
|
+
var meters = this.getRoundNum(maxMeters);
|
|
147
|
+
var label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
|
|
148
|
+
this.updateScale(this.mScale, label, meters / maxMeters);
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "updateImperial",
|
|
152
|
+
value: function updateImperial(maxMeters) {
|
|
153
|
+
var maxFeet = maxMeters * 3.2808399;
|
|
154
|
+
var maxMiles;
|
|
155
|
+
var miles;
|
|
156
|
+
var feet;
|
|
157
|
+
|
|
158
|
+
if (maxFeet > 5280) {
|
|
159
|
+
maxMiles = maxFeet / 5280;
|
|
160
|
+
miles = this.getRoundNum(maxMiles);
|
|
161
|
+
this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
|
|
162
|
+
} else {
|
|
163
|
+
feet = this.getRoundNum(maxFeet);
|
|
164
|
+
this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}]);
|
|
168
|
+
|
|
169
|
+
return Scale;
|
|
170
|
+
}(Control);
|
|
171
|
+
|
|
172
|
+
export { Scale as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PositionType } from '@antv/l7-core';
|
|
2
|
+
import { Control, IControlOption } from './baseControl';
|
|
3
|
+
export interface IZoomControlOption extends IControlOption {
|
|
4
|
+
zoomInText: Element | string;
|
|
5
|
+
zoomInTitle: string;
|
|
6
|
+
zoomOutText: Element | string;
|
|
7
|
+
zoomOutTitle: string;
|
|
8
|
+
}
|
|
9
|
+
export { Zoom };
|
|
10
|
+
export default class Zoom extends Control<IZoomControlOption> {
|
|
11
|
+
private disabled;
|
|
12
|
+
private zoomInButton;
|
|
13
|
+
private zoomOutButton;
|
|
14
|
+
getDefault(option: Partial<IZoomControlOption>): {
|
|
15
|
+
position: PositionType;
|
|
16
|
+
name: string;
|
|
17
|
+
zoomInText: SVGSVGElement;
|
|
18
|
+
zoomInTitle: string;
|
|
19
|
+
zoomOutText: SVGSVGElement;
|
|
20
|
+
zoomOutTitle: string;
|
|
21
|
+
className?: string | undefined;
|
|
22
|
+
style?: string | undefined;
|
|
23
|
+
};
|
|
24
|
+
setOptions(newOptions: Partial<IZoomControlOption>): void;
|
|
25
|
+
onAdd(): HTMLElement;
|
|
26
|
+
onRemove(): void;
|
|
27
|
+
disable(): this;
|
|
28
|
+
enable(): this;
|
|
29
|
+
zoomIn: () => void;
|
|
30
|
+
zoomOut: () => void;
|
|
31
|
+
private resetButtonGroup;
|
|
32
|
+
private createButton;
|
|
33
|
+
private updateDisabled;
|
|
34
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
+
import _get from "@babel/runtime/helpers/get";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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 };
|
|
20
|
+
|
|
21
|
+
var Zoom = /*#__PURE__*/function (_Control) {
|
|
22
|
+
_inherits(Zoom, _Control);
|
|
23
|
+
|
|
24
|
+
var _super = _createSuper(Zoom);
|
|
25
|
+
|
|
26
|
+
function Zoom() {
|
|
27
|
+
var _this;
|
|
28
|
+
|
|
29
|
+
_classCallCheck(this, Zoom);
|
|
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), "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
|
+
|
|
65
|
+
return _this;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_createClass(Zoom, [{
|
|
69
|
+
key: "getDefault",
|
|
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'),
|
|
75
|
+
zoomInTitle: 'Zoom in',
|
|
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
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "onAdd",
|
|
91
|
+
value: function onAdd() {
|
|
92
|
+
var container = DOM.create('div', 'l7-control-zoom');
|
|
93
|
+
this.resetButtonGroup(container);
|
|
94
|
+
this.mapsService.on('zoomend', this.updateDisabled);
|
|
95
|
+
this.mapsService.on('zoomchange', this.updateDisabled);
|
|
96
|
+
return container;
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "onRemove",
|
|
100
|
+
value: function onRemove() {
|
|
101
|
+
this.mapsService.off('zoomend', this.updateDisabled);
|
|
102
|
+
this.mapsService.off('zoomchange', this.updateDisabled);
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "disable",
|
|
106
|
+
value: function disable() {
|
|
107
|
+
this.disabled = true;
|
|
108
|
+
this.updateDisabled();
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "enable",
|
|
113
|
+
value: function enable() {
|
|
114
|
+
this.disabled = false;
|
|
115
|
+
this.updateDisabled();
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
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();
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "createButton",
|
|
128
|
+
value: function createButton(html, tile, className, container, fn) {
|
|
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
|
+
|
|
137
|
+
link.title = tile;
|
|
138
|
+
link.addEventListener('click', fn);
|
|
139
|
+
return link;
|
|
140
|
+
}
|
|
141
|
+
}]);
|
|
142
|
+
|
|
143
|
+
return Zoom;
|
|
144
|
+
}(Control);
|
|
145
|
+
|
|
146
|
+
export { Zoom as default };
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
@import 'variables.less';
|
|
2
|
+
|
|
3
|
+
.l7-control-container {
|
|
4
|
+
font: 12px/1.5 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
|
5
|
+
|
|
6
|
+
.l7-control {
|
|
7
|
+
position: relative;
|
|
8
|
+
z-index: 800;
|
|
9
|
+
float: left;
|
|
10
|
+
clear: both;
|
|
11
|
+
color: @l7-control-font-color;
|
|
12
|
+
font-size: @l7-control-font-size;
|
|
13
|
+
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
|
|
14
|
+
pointer-events: auto;
|
|
15
|
+
|
|
16
|
+
&.l7-control--hide {
|
|
17
|
+
display: none;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
each(@position-list,{
|
|
22
|
+
.l7-@{value} {
|
|
23
|
+
@{value}: 0;
|
|
24
|
+
display: flex;
|
|
25
|
+
position: absolute;
|
|
26
|
+
z-index: 1000;
|
|
27
|
+
pointer-events: none;
|
|
28
|
+
.l7-control:not(.l7-control--hide) {
|
|
29
|
+
margin-@{value}: @l7-control-space;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
.l7-center {
|
|
35
|
+
position: absolute;
|
|
36
|
+
display: flex;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
&.l7-top,
|
|
39
|
+
&.l7-bottom {
|
|
40
|
+
width: 100%;
|
|
41
|
+
}
|
|
42
|
+
&.l7-left,
|
|
43
|
+
&.l7-right {
|
|
44
|
+
height: 100%;
|
|
45
|
+
}
|
|
46
|
+
.l7-control {
|
|
47
|
+
margin-right: @l7-control-space;
|
|
48
|
+
margin-bottom: @l7-control-space;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.l7-row {
|
|
53
|
+
flex-direction: row;
|
|
54
|
+
&.l7-top {
|
|
55
|
+
align-items: flex-start;
|
|
56
|
+
}
|
|
57
|
+
&.l7-bottom {
|
|
58
|
+
align-items: flex-end;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.l7-column {
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
&.l7-left {
|
|
65
|
+
align-items: flex-start;
|
|
66
|
+
}
|
|
67
|
+
&.l7-right {
|
|
68
|
+
align-items: flex-end;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|