@antv/l7-component 2.9.32-alpha.4 → 2.9.32-alpha.5
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/control/baseControl/buttonControl.d.ts +1 -1
- package/es/control/baseControl/control.d.ts +4 -5
- package/es/control/baseControl/control.js +18 -5
- package/es/control/baseControl/popperControl.d.ts +1 -1
- package/es/control/baseControl/selectControl.d.ts +2 -2
- package/es/control/baseControl/selectControl.js +5 -0
- package/es/control/zoom.d.ts +3 -2
- package/lib/assets/iconfont/iconfont.js +46 -30
- package/lib/constants/index.js +34 -56
- package/lib/control/baseControl/buttonControl.js +194 -105
- package/lib/control/baseControl/control.js +317 -156
- package/lib/control/baseControl/index.js +57 -22
- package/lib/control/baseControl/popperControl.js +136 -102
- package/lib/control/baseControl/selectControl.js +230 -130
- package/lib/control/exportImage.js +175 -81
- package/lib/control/fullscreen.js +157 -102
- package/lib/control/geoLocate.js +143 -67
- package/lib/control/layerControl.js +162 -116
- package/lib/control/logo.js +101 -70
- package/lib/control/mapTheme.js +144 -85
- package/lib/control/mouseLocation.js +112 -71
- package/lib/control/scale.js +180 -127
- package/lib/control/zoom.js +154 -111
- package/lib/index.js +251 -48
- package/lib/interface.js +4 -16
- package/lib/marker-layer.js +367 -249
- package/lib/marker.js +419 -277
- package/lib/popup/layerPopup.js +305 -188
- package/lib/popup/popup.js +602 -339
- package/lib/utils/anchor.js +37 -55
- package/lib/utils/icon.js +13 -32
- package/lib/utils/popper.js +268 -180
- package/lib/utils/screenfull.js +110 -103
- package/package.json +5 -5
package/lib/control/scale.js
CHANGED
|
@@ -1,136 +1,189 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/control/scale.ts
|
|
20
|
-
var scale_exports = {};
|
|
21
|
-
__export(scale_exports, {
|
|
22
|
-
Scale: () => Scale,
|
|
23
|
-
default: () => Scale
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
24
7
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
this.mapsService.off(updateWhenIdle ? "moveend" : "mapmove", this.update);
|
|
66
|
-
}
|
|
67
|
-
setOptions(newOption) {
|
|
68
|
-
super.setOptions(newOption);
|
|
69
|
-
if (this.checkUpdateOption(newOption, [
|
|
70
|
-
"lockWidth",
|
|
71
|
-
"maxWidth",
|
|
72
|
-
"metric",
|
|
73
|
-
"updateWhenIdle",
|
|
74
|
-
"imperial"
|
|
75
|
-
])) {
|
|
76
|
-
this.resetScaleLines(this.container);
|
|
8
|
+
exports.default = exports.Scale = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
24
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
26
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
+
|
|
28
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
29
|
+
|
|
30
|
+
var _baseControl = require("./baseControl");
|
|
31
|
+
|
|
32
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
33
|
+
|
|
34
|
+
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; } }
|
|
35
|
+
|
|
36
|
+
var Scale = /*#__PURE__*/function (_Control) {
|
|
37
|
+
(0, _inherits2.default)(Scale, _Control);
|
|
38
|
+
|
|
39
|
+
var _super = _createSuper(Scale);
|
|
40
|
+
|
|
41
|
+
function Scale() {
|
|
42
|
+
var _this;
|
|
43
|
+
|
|
44
|
+
(0, _classCallCheck2.default)(this, Scale);
|
|
45
|
+
|
|
46
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
47
|
+
args[_key] = arguments[_key];
|
|
77
48
|
}
|
|
49
|
+
|
|
50
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
51
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "update", function () {
|
|
52
|
+
var mapsService = _this.mapsService;
|
|
53
|
+
var maxWidth = _this.controlOption.maxWidth;
|
|
54
|
+
var y = mapsService.getSize()[1] / 2;
|
|
55
|
+
var p1 = mapsService.containerToLngLat([0, y]);
|
|
56
|
+
var p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
57
|
+
var maxMeters = (0, _l7Utils.lnglatDistance)([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
58
|
+
|
|
59
|
+
_this.updateScales(maxMeters);
|
|
60
|
+
});
|
|
61
|
+
return _this;
|
|
78
62
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
|
|
64
|
+
(0, _createClass2.default)(Scale, [{
|
|
65
|
+
key: "getDefault",
|
|
66
|
+
value: function getDefault(option) {
|
|
67
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(Scale.prototype), "getDefault", this).call(this, option)), {}, {
|
|
68
|
+
name: 'scale',
|
|
69
|
+
position: _baseControl.PositionType.BOTTOMLEFT,
|
|
70
|
+
maxWidth: 100,
|
|
71
|
+
metric: true,
|
|
72
|
+
updateWhenIdle: false,
|
|
73
|
+
imperial: false,
|
|
74
|
+
lockWidth: true
|
|
75
|
+
});
|
|
83
76
|
}
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
}, {
|
|
78
|
+
key: "onAdd",
|
|
79
|
+
value: function onAdd() {
|
|
80
|
+
var className = 'l7-control-scale';
|
|
81
|
+
|
|
82
|
+
var container = _l7Utils.DOM.create('div', className);
|
|
83
|
+
|
|
84
|
+
this.resetScaleLines(container);
|
|
85
|
+
var updateWhenIdle = this.controlOption.updateWhenIdle;
|
|
86
|
+
this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
87
|
+
this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
88
|
+
return container;
|
|
86
89
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
}, {
|
|
91
|
+
key: "onRemove",
|
|
92
|
+
value: function onRemove() {
|
|
93
|
+
var updateWhenIdle = this.controlOption.updateWhenIdle;
|
|
94
|
+
this.mapsService.off(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
95
|
+
this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
93
96
|
}
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
}, {
|
|
98
|
+
key: "setOptions",
|
|
99
|
+
value: function setOptions(newOption) {
|
|
100
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(Scale.prototype), "setOptions", this).call(this, newOption);
|
|
101
|
+
|
|
102
|
+
if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
|
|
103
|
+
this.resetScaleLines(this.container);
|
|
104
|
+
}
|
|
96
105
|
}
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
}, {
|
|
107
|
+
key: "updateScales",
|
|
108
|
+
value: function updateScales(maxMeters) {
|
|
109
|
+
var _this$controlOption = this.controlOption,
|
|
110
|
+
metric = _this$controlOption.metric,
|
|
111
|
+
imperial = _this$controlOption.imperial;
|
|
112
|
+
|
|
113
|
+
if (metric && maxMeters) {
|
|
114
|
+
this.updateMetric(maxMeters);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (imperial && maxMeters) {
|
|
118
|
+
this.updateImperial(maxMeters);
|
|
119
|
+
}
|
|
99
120
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
maxMiles = maxFeet / 5280;
|
|
125
|
-
miles = this.getRoundNum(maxMiles);
|
|
126
|
-
this.updateScale(this.iScale, miles + " mi", miles / maxMiles);
|
|
127
|
-
} else {
|
|
128
|
-
feet = this.getRoundNum(maxFeet);
|
|
129
|
-
this.updateScale(this.iScale, feet + " ft", feet / maxFeet);
|
|
121
|
+
}, {
|
|
122
|
+
key: "resetScaleLines",
|
|
123
|
+
value: function resetScaleLines(container) {
|
|
124
|
+
_l7Utils.DOM.clearChildren(container);
|
|
125
|
+
|
|
126
|
+
var _this$controlOption2 = this.controlOption,
|
|
127
|
+
metric = _this$controlOption2.metric,
|
|
128
|
+
imperial = _this$controlOption2.imperial,
|
|
129
|
+
maxWidth = _this$controlOption2.maxWidth,
|
|
130
|
+
lockWidth = _this$controlOption2.lockWidth;
|
|
131
|
+
|
|
132
|
+
if (lockWidth) {
|
|
133
|
+
_l7Utils.DOM.addStyle(container, "width: ".concat(maxWidth, "px"));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (metric) {
|
|
137
|
+
this.mScale = _l7Utils.DOM.create('div', 'l7-control-scale-line', container);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (imperial) {
|
|
141
|
+
this.iScale = _l7Utils.DOM.create('div', 'l7-control-scale-line', container);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
this.update();
|
|
130
145
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
146
|
+
}, {
|
|
147
|
+
key: "updateScale",
|
|
148
|
+
value: function updateScale(scale, text, ratio) {
|
|
149
|
+
var maxWidth = this.controlOption.maxWidth;
|
|
150
|
+
scale.style.width = Math.round(maxWidth * ratio) + 'px';
|
|
151
|
+
scale.innerHTML = text;
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "getRoundNum",
|
|
155
|
+
value: function getRoundNum(num) {
|
|
156
|
+
var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
|
|
157
|
+
var d = num / pow10;
|
|
158
|
+
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
159
|
+
return pow10 * d;
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "updateMetric",
|
|
163
|
+
value: function updateMetric(maxMeters) {
|
|
164
|
+
var meters = this.getRoundNum(maxMeters);
|
|
165
|
+
var label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
|
|
166
|
+
this.updateScale(this.mScale, label, meters / maxMeters);
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "updateImperial",
|
|
170
|
+
value: function updateImperial(maxMeters) {
|
|
171
|
+
var maxFeet = maxMeters * 3.2808399;
|
|
172
|
+
var maxMiles;
|
|
173
|
+
var miles;
|
|
174
|
+
var feet;
|
|
175
|
+
|
|
176
|
+
if (maxFeet > 5280) {
|
|
177
|
+
maxMiles = maxFeet / 5280;
|
|
178
|
+
miles = this.getRoundNum(maxMiles);
|
|
179
|
+
this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
|
|
180
|
+
} else {
|
|
181
|
+
feet = this.getRoundNum(maxFeet);
|
|
182
|
+
this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}]);
|
|
186
|
+
return Scale;
|
|
187
|
+
}(_baseControl.Control);
|
|
188
|
+
|
|
189
|
+
exports.default = exports.Scale = Scale;
|
package/lib/control/zoom.js
CHANGED
|
@@ -1,119 +1,162 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/control/zoom.ts
|
|
20
|
-
var zoom_exports = {};
|
|
21
|
-
__export(zoom_exports, {
|
|
22
|
-
Zoom: () => Zoom,
|
|
23
|
-
default: () => Zoom
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
24
7
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
8
|
+
exports.default = exports.Zoom = void 0;
|
|
9
|
+
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
24
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
26
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
+
|
|
28
|
+
var _l7Core = require("@antv/l7-core");
|
|
29
|
+
|
|
30
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
31
|
+
|
|
32
|
+
var _icon = require("../utils/icon");
|
|
33
|
+
|
|
34
|
+
var _baseControl = require("./baseControl");
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
37
|
+
|
|
38
|
+
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; } }
|
|
39
|
+
|
|
40
|
+
var Zoom = /*#__PURE__*/function (_Control) {
|
|
41
|
+
(0, _inherits2.default)(Zoom, _Control);
|
|
42
|
+
|
|
43
|
+
var _super = _createSuper(Zoom);
|
|
44
|
+
|
|
45
|
+
function Zoom() {
|
|
46
|
+
var _this;
|
|
47
|
+
|
|
48
|
+
(0, _classCallCheck2.default)(this, Zoom);
|
|
49
|
+
|
|
50
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
|
+
args[_key] = arguments[_key];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
55
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "zoomIn", function () {
|
|
56
|
+
if (!_this.disabled && _this.mapsService.getZoom() < _this.mapsService.getMaxZoom()) {
|
|
57
|
+
_this.mapsService.zoomIn();
|
|
36
58
|
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
if (!
|
|
40
|
-
|
|
59
|
+
});
|
|
60
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "zoomOut", function () {
|
|
61
|
+
if (!_this.disabled && _this.mapsService.getZoom() > _this.mapsService.getMinZoom()) {
|
|
62
|
+
_this.mapsService.zoomOut();
|
|
41
63
|
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
64
|
+
});
|
|
65
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateDisabled", function () {
|
|
66
|
+
var mapsService = _this.mapsService;
|
|
67
|
+
|
|
68
|
+
_this.zoomInButton.removeAttribute('disabled');
|
|
69
|
+
|
|
70
|
+
_this.zoomOutButton.removeAttribute('disabled');
|
|
71
|
+
|
|
72
|
+
if (_this.disabled || mapsService.getZoom() <= mapsService.getMinZoom()) {
|
|
73
|
+
_this.zoomOutButton.setAttribute('disabled', 'true');
|
|
49
74
|
}
|
|
50
|
-
|
|
51
|
-
|
|
75
|
+
|
|
76
|
+
if (_this.disabled || mapsService.getZoom() >= mapsService.getMaxZoom()) {
|
|
77
|
+
_this.zoomInButton.setAttribute('disabled', 'true');
|
|
52
78
|
}
|
|
53
|
-
};
|
|
79
|
+
});
|
|
80
|
+
return _this;
|
|
54
81
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
super.setOptions(newOptions);
|
|
68
|
-
if (this.checkUpdateOption(newOptions, [
|
|
69
|
-
"zoomInText",
|
|
70
|
-
"zoomInTitle",
|
|
71
|
-
"zoomOutText",
|
|
72
|
-
"zoomOutTitle"
|
|
73
|
-
])) {
|
|
74
|
-
this.resetButtonGroup(this.container);
|
|
82
|
+
|
|
83
|
+
(0, _createClass2.default)(Zoom, [{
|
|
84
|
+
key: "getDefault",
|
|
85
|
+
value: function getDefault(option) {
|
|
86
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(Zoom.prototype), "getDefault", this).call(this, option)), {}, {
|
|
87
|
+
position: _l7Core.PositionType.BOTTOMRIGHT,
|
|
88
|
+
name: 'zoom',
|
|
89
|
+
zoomInText: (0, _icon.createL7Icon)('l7-icon-enlarge'),
|
|
90
|
+
zoomInTitle: 'Zoom in',
|
|
91
|
+
zoomOutText: (0, _icon.createL7Icon)('l7-icon-narrow'),
|
|
92
|
+
zoomOutTitle: 'Zoom out'
|
|
93
|
+
});
|
|
75
94
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
onRemove() {
|
|
85
|
-
this.mapsService.off("zoomend", this.updateDisabled);
|
|
86
|
-
this.mapsService.off("zoomchange", this.updateDisabled);
|
|
87
|
-
}
|
|
88
|
-
disable() {
|
|
89
|
-
this.disabled = true;
|
|
90
|
-
this.updateDisabled();
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
enable() {
|
|
94
|
-
this.disabled = false;
|
|
95
|
-
this.updateDisabled();
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
resetButtonGroup(container) {
|
|
99
|
-
import_l7_utils.DOM.clearChildren(container);
|
|
100
|
-
this.zoomInButton = this.createButton(this.controlOption.zoomInText, this.controlOption.zoomInTitle, "l7-button-control", container, this.zoomIn);
|
|
101
|
-
this.zoomOutButton = this.createButton(this.controlOption.zoomOutText, this.controlOption.zoomOutTitle, "l7-button-control", container, this.zoomOut);
|
|
102
|
-
this.updateDisabled();
|
|
103
|
-
}
|
|
104
|
-
createButton(html, tile, className, container, fn) {
|
|
105
|
-
const link = import_l7_utils.DOM.create("button", className, container);
|
|
106
|
-
if (typeof html === "string") {
|
|
107
|
-
link.innerHTML = html;
|
|
108
|
-
} else {
|
|
109
|
-
link.append(html);
|
|
95
|
+
}, {
|
|
96
|
+
key: "setOptions",
|
|
97
|
+
value: function setOptions(newOptions) {
|
|
98
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(Zoom.prototype), "setOptions", this).call(this, newOptions);
|
|
99
|
+
|
|
100
|
+
if (this.checkUpdateOption(newOptions, ['zoomInText', 'zoomInTitle', 'zoomOutText', 'zoomOutTitle'])) {
|
|
101
|
+
this.resetButtonGroup(this.container);
|
|
102
|
+
}
|
|
110
103
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
104
|
+
}, {
|
|
105
|
+
key: "onAdd",
|
|
106
|
+
value: function onAdd() {
|
|
107
|
+
var container = _l7Utils.DOM.create('div', 'l7-control-zoom');
|
|
108
|
+
|
|
109
|
+
this.resetButtonGroup(container);
|
|
110
|
+
this.mapsService.on('zoomend', this.updateDisabled);
|
|
111
|
+
this.mapsService.on('zoomchange', this.updateDisabled);
|
|
112
|
+
return container;
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "onRemove",
|
|
116
|
+
value: function onRemove() {
|
|
117
|
+
this.mapsService.off('zoomend', this.updateDisabled);
|
|
118
|
+
this.mapsService.off('zoomchange', this.updateDisabled);
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "disable",
|
|
122
|
+
value: function disable() {
|
|
123
|
+
this.disabled = true;
|
|
124
|
+
this.updateDisabled();
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "enable",
|
|
129
|
+
value: function enable() {
|
|
130
|
+
this.disabled = false;
|
|
131
|
+
this.updateDisabled();
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "resetButtonGroup",
|
|
136
|
+
value: function resetButtonGroup(container) {
|
|
137
|
+
_l7Utils.DOM.clearChildren(container);
|
|
138
|
+
|
|
139
|
+
this.zoomInButton = this.createButton(this.controlOption.zoomInText, this.controlOption.zoomInTitle, 'l7-button-control', container, this.zoomIn);
|
|
140
|
+
this.zoomOutButton = this.createButton(this.controlOption.zoomOutText, this.controlOption.zoomOutTitle, 'l7-button-control', container, this.zoomOut);
|
|
141
|
+
this.updateDisabled();
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "createButton",
|
|
145
|
+
value: function createButton(html, tile, className, container, fn) {
|
|
146
|
+
var link = _l7Utils.DOM.create('button', className, container);
|
|
147
|
+
|
|
148
|
+
if (typeof html === 'string') {
|
|
149
|
+
link.innerHTML = html;
|
|
150
|
+
} else {
|
|
151
|
+
link.append(html);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
link.title = tile;
|
|
155
|
+
link.addEventListener('click', fn);
|
|
156
|
+
return link;
|
|
157
|
+
}
|
|
158
|
+
}]);
|
|
159
|
+
return Zoom;
|
|
160
|
+
}(_baseControl.Control);
|
|
161
|
+
|
|
162
|
+
exports.default = exports.Zoom = Zoom;
|