@antv/l7-component 2.16.0 → 2.16.1
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 +17 -10
- package/es/control/baseControl/buttonControl.js +42 -9
- package/es/control/baseControl/control.js +54 -25
- package/es/control/baseControl/popperControl.js +24 -10
- package/es/control/baseControl/selectControl.js +45 -6
- package/es/control/exportImage.js +116 -76
- package/es/control/fullscreen.js +53 -20
- package/es/control/geoLocate.js +66 -36
- package/es/control/layerSwitch.js +31 -0
- package/es/control/logo.js +14 -2
- package/es/control/mapTheme.js +32 -7
- package/es/control/mouseLocation.js +23 -2
- package/es/control/scale.js +29 -6
- package/es/control/zoom.js +23 -0
- package/es/index.js +12 -2
- package/es/marker-layer.js +75 -41
- package/es/marker.js +83 -29
- package/es/popup/layerPopup.js +82 -31
- package/es/popup/popup.js +127 -48
- package/es/utils/anchor.js +7 -3
- package/es/utils/popper.js +64 -15
- package/es/utils/screenfull.js +52 -23
- package/lib/assets/iconfont/iconfont.js +17 -10
- package/lib/control/baseControl/buttonControl.js +52 -9
- package/lib/control/baseControl/control.js +69 -25
- package/lib/control/baseControl/index.js +8 -0
- package/lib/control/baseControl/popperControl.js +29 -10
- package/lib/control/baseControl/selectControl.js +60 -6
- package/lib/control/exportImage.js +125 -76
- package/lib/control/fullscreen.js +60 -20
- package/lib/control/geoLocate.js +75 -36
- package/lib/control/layerSwitch.js +36 -0
- package/lib/control/logo.js +26 -2
- package/lib/control/mapTheme.js +42 -7
- package/lib/control/mouseLocation.js +33 -2
- package/lib/control/scale.js +40 -6
- package/lib/control/zoom.js +33 -0
- package/lib/index.js +41 -0
- package/lib/marker-layer.js +86 -39
- package/lib/marker.js +91 -29
- package/lib/popup/layerPopup.js +94 -29
- package/lib/popup/popup.js +139 -48
- package/lib/utils/anchor.js +9 -4
- package/lib/utils/icon.js +2 -0
- package/lib/utils/popper.js +71 -14
- package/lib/utils/screenfull.js +54 -23
- package/package.json +6 -6
package/lib/control/mapTheme.js
CHANGED
|
@@ -1,40 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = exports.MapTheme = void 0;
|
|
9
|
+
|
|
8
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
9
12
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
+
|
|
10
14
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
11
16
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
12
18
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
19
|
+
|
|
13
20
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
21
|
+
|
|
14
22
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
+
|
|
15
24
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
25
|
+
|
|
16
26
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
27
|
+
|
|
17
28
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
29
|
+
|
|
18
30
|
var _constants = require("../constants");
|
|
31
|
+
|
|
19
32
|
var _icon = require("../utils/icon");
|
|
33
|
+
|
|
20
34
|
var _selectControl = _interopRequireDefault(require("./baseControl/selectControl"));
|
|
35
|
+
|
|
21
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
|
+
|
|
22
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
|
+
|
|
23
40
|
var MapTheme = /*#__PURE__*/function (_SelectControl) {
|
|
24
41
|
(0, _inherits2.default)(MapTheme, _SelectControl);
|
|
42
|
+
|
|
25
43
|
var _super = _createSuper(MapTheme);
|
|
44
|
+
|
|
26
45
|
function MapTheme() {
|
|
27
46
|
var _this;
|
|
47
|
+
|
|
28
48
|
(0, _classCallCheck2.default)(this, MapTheme);
|
|
49
|
+
|
|
29
50
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
51
|
args[_key] = arguments[_key];
|
|
31
52
|
}
|
|
53
|
+
|
|
32
54
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
33
55
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMapThemeChange", function () {
|
|
34
56
|
_this.mapsService.setMapStyle(_this.selectValue[0]);
|
|
35
57
|
});
|
|
36
58
|
return _this;
|
|
37
59
|
}
|
|
60
|
+
|
|
38
61
|
(0, _createClass2.default)(MapTheme, [{
|
|
39
62
|
key: "getDefault",
|
|
40
63
|
value: function getDefault(option) {
|
|
@@ -50,18 +73,22 @@ var MapTheme = /*#__PURE__*/function (_SelectControl) {
|
|
|
50
73
|
var mapStyleConfig = this.mapsService.getType() === 'mapbox' ? _constants.MapboxMapStyleConfig : _constants.GaodeMapStyleConfig;
|
|
51
74
|
return Object.entries(this.mapsService.getMapStyleConfig()).filter(function (_ref) {
|
|
52
75
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
53
|
-
|
|
54
|
-
|
|
76
|
+
key = _ref2[0],
|
|
77
|
+
value = _ref2[1];
|
|
78
|
+
|
|
55
79
|
return typeof value === 'string' && key !== 'blank';
|
|
56
80
|
}).map(function (_ref3) {
|
|
57
81
|
var _mapStyleConfig$key;
|
|
82
|
+
|
|
58
83
|
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
59
|
-
|
|
60
|
-
|
|
84
|
+
key = _ref4[0],
|
|
85
|
+
value = _ref4[1];
|
|
86
|
+
|
|
61
87
|
// @ts-ignore
|
|
62
88
|
var _ref5 = (_mapStyleConfig$key = mapStyleConfig[key]) !== null && _mapStyleConfig$key !== void 0 ? _mapStyleConfig$key : {},
|
|
63
|
-
|
|
64
|
-
|
|
89
|
+
text = _ref5.text,
|
|
90
|
+
img = _ref5.img;
|
|
91
|
+
|
|
65
92
|
return {
|
|
66
93
|
text: text !== null && text !== void 0 ? text : key,
|
|
67
94
|
value: value,
|
|
@@ -79,29 +106,36 @@ var MapTheme = /*#__PURE__*/function (_SelectControl) {
|
|
|
79
106
|
key: "onAdd",
|
|
80
107
|
value: function onAdd() {
|
|
81
108
|
var _this$controlOption$o,
|
|
82
|
-
|
|
109
|
+
_this2 = this;
|
|
110
|
+
|
|
83
111
|
if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
|
|
84
112
|
this.controlOption.options = this.getStyleOptions();
|
|
85
113
|
}
|
|
114
|
+
|
|
86
115
|
if (this.controlOption.defaultValue) {
|
|
87
116
|
var _this$controlOption$o2, _this$controlOption$o3;
|
|
117
|
+
|
|
88
118
|
var defaultValue = this.controlOption.defaultValue;
|
|
89
119
|
this.controlOption.defaultValue = (_this$controlOption$o2 = (_this$controlOption$o3 = this.controlOption.options.find(function (item) {
|
|
90
120
|
return item.key === defaultValue;
|
|
91
121
|
})) === null || _this$controlOption$o3 === void 0 ? void 0 : _this$controlOption$o3.value) !== null && _this$controlOption$o2 !== void 0 ? _this$controlOption$o2 : defaultValue;
|
|
92
122
|
} else {
|
|
93
123
|
var defaultStyle = this.getMapStyle();
|
|
124
|
+
|
|
94
125
|
if (defaultStyle) {
|
|
95
126
|
this.controlOption.defaultValue = defaultStyle;
|
|
96
127
|
} else {
|
|
97
128
|
// @ts-ignore
|
|
98
129
|
this.mapsService.map.once('styledata', function () {
|
|
99
130
|
var mapboxStyle = _this2.mapsService.getMapStyle();
|
|
131
|
+
|
|
100
132
|
_this2.controlOption.defaultValue = mapboxStyle;
|
|
133
|
+
|
|
101
134
|
_this2.setSelectValue(mapboxStyle, false);
|
|
102
135
|
});
|
|
103
136
|
}
|
|
104
137
|
}
|
|
138
|
+
|
|
105
139
|
this.on('selectChange', this.onMapThemeChange);
|
|
106
140
|
return (0, _get2.default)((0, _getPrototypeOf2.default)(MapTheme.prototype), "onAdd", this).call(this);
|
|
107
141
|
}
|
|
@@ -113,4 +147,5 @@ var MapTheme = /*#__PURE__*/function (_SelectControl) {
|
|
|
113
147
|
}]);
|
|
114
148
|
return MapTheme;
|
|
115
149
|
}(_selectControl.default);
|
|
150
|
+
|
|
116
151
|
exports.default = exports.MapTheme = MapTheme;
|
|
@@ -1,52 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = exports.MouseLocation = void 0;
|
|
9
|
+
|
|
8
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
9
12
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
+
|
|
10
14
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
11
16
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
12
18
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
19
|
+
|
|
13
20
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
21
|
+
|
|
14
22
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
23
|
+
|
|
15
24
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
25
|
+
|
|
16
26
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
27
|
+
|
|
17
28
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
29
|
+
|
|
18
30
|
var _l7Core = require("@antv/l7-core");
|
|
31
|
+
|
|
19
32
|
var _l7Utils = require("@antv/l7-utils");
|
|
33
|
+
|
|
20
34
|
var _control = _interopRequireDefault(require("./baseControl/control"));
|
|
35
|
+
|
|
21
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
|
+
|
|
22
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
|
+
|
|
23
40
|
var MouseLocation = /*#__PURE__*/function (_Control) {
|
|
24
41
|
(0, _inherits2.default)(MouseLocation, _Control);
|
|
42
|
+
|
|
25
43
|
var _super = _createSuper(MouseLocation);
|
|
44
|
+
|
|
26
45
|
function MouseLocation() {
|
|
27
46
|
var _this;
|
|
47
|
+
|
|
28
48
|
(0, _classCallCheck2.default)(this, MouseLocation);
|
|
49
|
+
|
|
29
50
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
51
|
args[_key] = arguments[_key];
|
|
31
52
|
}
|
|
53
|
+
|
|
32
54
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
33
55
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "location", [0, 0]);
|
|
34
56
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMouseMove", function (e) {
|
|
35
57
|
var position = _this.location;
|
|
36
58
|
var lngLat = e.lngLat || e.lnglat;
|
|
37
59
|
var transform = _this.controlOption.transform;
|
|
60
|
+
|
|
38
61
|
if (lngLat) {
|
|
39
62
|
position = [lngLat.lng, lngLat.lat];
|
|
40
63
|
}
|
|
64
|
+
|
|
41
65
|
_this.location = position;
|
|
66
|
+
|
|
42
67
|
if (transform) {
|
|
43
68
|
position = transform(position);
|
|
44
69
|
}
|
|
70
|
+
|
|
45
71
|
_this.insertLocation2HTML(position);
|
|
72
|
+
|
|
46
73
|
_this.emit('locationChange', position);
|
|
47
74
|
});
|
|
48
75
|
return _this;
|
|
49
76
|
}
|
|
77
|
+
|
|
50
78
|
(0, _createClass2.default)(MouseLocation, [{
|
|
51
79
|
key: "getLocation",
|
|
52
80
|
value: function getLocation() {
|
|
@@ -59,8 +87,9 @@ var MouseLocation = /*#__PURE__*/function (_Control) {
|
|
|
59
87
|
position: _l7Core.PositionType.BOTTOMLEFT,
|
|
60
88
|
transform: function transform(_ref) {
|
|
61
89
|
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
62
|
-
|
|
63
|
-
|
|
90
|
+
lng = _ref2[0],
|
|
91
|
+
lat = _ref2[1];
|
|
92
|
+
|
|
64
93
|
return [+(+lng).toFixed(6), +(+lat).toFixed(6)];
|
|
65
94
|
}
|
|
66
95
|
});
|
|
@@ -69,6 +98,7 @@ var MouseLocation = /*#__PURE__*/function (_Control) {
|
|
|
69
98
|
key: "onAdd",
|
|
70
99
|
value: function onAdd() {
|
|
71
100
|
var container = _l7Utils.DOM.create('div', 'l7-control-mouse-location');
|
|
101
|
+
|
|
72
102
|
container.innerHTML = ' ';
|
|
73
103
|
this.mapsService.on('mousemove', this.onMouseMove);
|
|
74
104
|
return container;
|
|
@@ -86,4 +116,5 @@ var MouseLocation = /*#__PURE__*/function (_Control) {
|
|
|
86
116
|
}]);
|
|
87
117
|
return MouseLocation;
|
|
88
118
|
}(_control.default);
|
|
119
|
+
|
|
89
120
|
exports.default = exports.MouseLocation = MouseLocation;
|
package/lib/control/scale.js
CHANGED
|
@@ -1,32 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = exports.Scale = void 0;
|
|
9
|
+
|
|
8
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
9
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
10
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
11
16
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
12
18
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
19
|
+
|
|
13
20
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
14
22
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
15
24
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
16
26
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
+
|
|
17
28
|
var _l7Utils = require("@antv/l7-utils");
|
|
29
|
+
|
|
18
30
|
var _baseControl = require("./baseControl");
|
|
31
|
+
|
|
19
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
|
+
|
|
20
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
|
+
|
|
21
36
|
var Scale = /*#__PURE__*/function (_Control) {
|
|
22
37
|
(0, _inherits2.default)(Scale, _Control);
|
|
38
|
+
|
|
23
39
|
var _super = _createSuper(Scale);
|
|
40
|
+
|
|
24
41
|
function Scale() {
|
|
25
42
|
var _this;
|
|
43
|
+
|
|
26
44
|
(0, _classCallCheck2.default)(this, Scale);
|
|
45
|
+
|
|
27
46
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
28
47
|
args[_key] = arguments[_key];
|
|
29
48
|
}
|
|
49
|
+
|
|
30
50
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
31
51
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "update", function () {
|
|
32
52
|
var mapsService = _this.mapsService;
|
|
@@ -35,10 +55,12 @@ var Scale = /*#__PURE__*/function (_Control) {
|
|
|
35
55
|
var p1 = mapsService.containerToLngLat([0, y]);
|
|
36
56
|
var p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
37
57
|
var maxMeters = (0, _l7Utils.lnglatDistance)([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
58
|
+
|
|
38
59
|
_this.updateScales(maxMeters);
|
|
39
60
|
});
|
|
40
61
|
return _this;
|
|
41
62
|
}
|
|
63
|
+
|
|
42
64
|
(0, _createClass2.default)(Scale, [{
|
|
43
65
|
key: "getDefault",
|
|
44
66
|
value: function getDefault(option) {
|
|
@@ -56,7 +78,9 @@ var Scale = /*#__PURE__*/function (_Control) {
|
|
|
56
78
|
key: "onAdd",
|
|
57
79
|
value: function onAdd() {
|
|
58
80
|
var className = 'l7-control-scale';
|
|
81
|
+
|
|
59
82
|
var container = _l7Utils.DOM.create('div', className);
|
|
83
|
+
|
|
60
84
|
this.resetScaleLines(container);
|
|
61
85
|
var updateWhenIdle = this.controlOption.updateWhenIdle;
|
|
62
86
|
this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
@@ -74,6 +98,7 @@ var Scale = /*#__PURE__*/function (_Control) {
|
|
|
74
98
|
key: "setOptions",
|
|
75
99
|
value: function setOptions(newOption) {
|
|
76
100
|
(0, _get2.default)((0, _getPrototypeOf2.default)(Scale.prototype), "setOptions", this).call(this, newOption);
|
|
101
|
+
|
|
77
102
|
if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
|
|
78
103
|
this.resetScaleLines(this.container);
|
|
79
104
|
}
|
|
@@ -82,11 +107,13 @@ var Scale = /*#__PURE__*/function (_Control) {
|
|
|
82
107
|
key: "updateScales",
|
|
83
108
|
value: function updateScales(maxMeters) {
|
|
84
109
|
var _this$controlOption = this.controlOption,
|
|
85
|
-
|
|
86
|
-
|
|
110
|
+
metric = _this$controlOption.metric,
|
|
111
|
+
imperial = _this$controlOption.imperial;
|
|
112
|
+
|
|
87
113
|
if (metric && maxMeters) {
|
|
88
114
|
this.updateMetric(maxMeters);
|
|
89
115
|
}
|
|
116
|
+
|
|
90
117
|
if (imperial && maxMeters) {
|
|
91
118
|
this.updateImperial(maxMeters);
|
|
92
119
|
}
|
|
@@ -95,20 +122,25 @@ var Scale = /*#__PURE__*/function (_Control) {
|
|
|
95
122
|
key: "resetScaleLines",
|
|
96
123
|
value: function resetScaleLines(container) {
|
|
97
124
|
_l7Utils.DOM.clearChildren(container);
|
|
125
|
+
|
|
98
126
|
var _this$controlOption2 = this.controlOption,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
127
|
+
metric = _this$controlOption2.metric,
|
|
128
|
+
imperial = _this$controlOption2.imperial,
|
|
129
|
+
maxWidth = _this$controlOption2.maxWidth,
|
|
130
|
+
lockWidth = _this$controlOption2.lockWidth;
|
|
131
|
+
|
|
103
132
|
if (lockWidth) {
|
|
104
133
|
_l7Utils.DOM.addStyle(container, "width: ".concat(maxWidth, "px"));
|
|
105
134
|
}
|
|
135
|
+
|
|
106
136
|
if (metric) {
|
|
107
137
|
this.mScale = _l7Utils.DOM.create('div', 'l7-control-scale-line', container);
|
|
108
138
|
}
|
|
139
|
+
|
|
109
140
|
if (imperial) {
|
|
110
141
|
this.iScale = _l7Utils.DOM.create('div', 'l7-control-scale-line', container);
|
|
111
142
|
}
|
|
143
|
+
|
|
112
144
|
this.update();
|
|
113
145
|
}
|
|
114
146
|
}, {
|
|
@@ -140,6 +172,7 @@ var Scale = /*#__PURE__*/function (_Control) {
|
|
|
140
172
|
var maxMiles;
|
|
141
173
|
var miles;
|
|
142
174
|
var feet;
|
|
175
|
+
|
|
143
176
|
if (maxFeet > 5280) {
|
|
144
177
|
maxMiles = maxFeet / 5280;
|
|
145
178
|
miles = this.getRoundNum(maxMiles);
|
|
@@ -152,4 +185,5 @@ var Scale = /*#__PURE__*/function (_Control) {
|
|
|
152
185
|
}]);
|
|
153
186
|
return Scale;
|
|
154
187
|
}(_baseControl.Control);
|
|
188
|
+
|
|
155
189
|
exports.default = exports.Scale = Scale;
|
package/lib/control/zoom.js
CHANGED
|
@@ -1,34 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = exports.Zoom = void 0;
|
|
9
|
+
|
|
8
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
+
|
|
9
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
10
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
11
16
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
12
18
|
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
19
|
+
|
|
13
20
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
14
22
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
15
24
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
16
26
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
+
|
|
17
28
|
var _l7Core = require("@antv/l7-core");
|
|
29
|
+
|
|
18
30
|
var _l7Utils = require("@antv/l7-utils");
|
|
31
|
+
|
|
19
32
|
var _icon = require("../utils/icon");
|
|
33
|
+
|
|
20
34
|
var _baseControl = require("./baseControl");
|
|
35
|
+
|
|
21
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
|
+
|
|
22
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
|
+
|
|
23
40
|
var Zoom = /*#__PURE__*/function (_Control) {
|
|
24
41
|
(0, _inherits2.default)(Zoom, _Control);
|
|
42
|
+
|
|
25
43
|
var _super = _createSuper(Zoom);
|
|
44
|
+
|
|
26
45
|
function Zoom() {
|
|
27
46
|
var _this;
|
|
47
|
+
|
|
28
48
|
(0, _classCallCheck2.default)(this, Zoom);
|
|
49
|
+
|
|
29
50
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
51
|
args[_key] = arguments[_key];
|
|
31
52
|
}
|
|
53
|
+
|
|
32
54
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
33
55
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "zoomIn", function () {
|
|
34
56
|
if (!_this.disabled && _this.mapsService.getZoom() < _this.mapsService.getMaxZoom()) {
|
|
@@ -42,17 +64,22 @@ var Zoom = /*#__PURE__*/function (_Control) {
|
|
|
42
64
|
});
|
|
43
65
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateDisabled", function () {
|
|
44
66
|
var mapsService = _this.mapsService;
|
|
67
|
+
|
|
45
68
|
_this.zoomInButton.removeAttribute('disabled');
|
|
69
|
+
|
|
46
70
|
_this.zoomOutButton.removeAttribute('disabled');
|
|
71
|
+
|
|
47
72
|
if (_this.disabled || mapsService.getZoom() <= mapsService.getMinZoom()) {
|
|
48
73
|
_this.zoomOutButton.setAttribute('disabled', 'true');
|
|
49
74
|
}
|
|
75
|
+
|
|
50
76
|
if (_this.disabled || mapsService.getZoom() >= mapsService.getMaxZoom()) {
|
|
51
77
|
_this.zoomInButton.setAttribute('disabled', 'true');
|
|
52
78
|
}
|
|
53
79
|
});
|
|
54
80
|
return _this;
|
|
55
81
|
}
|
|
82
|
+
|
|
56
83
|
(0, _createClass2.default)(Zoom, [{
|
|
57
84
|
key: "getDefault",
|
|
58
85
|
value: function getDefault(option) {
|
|
@@ -69,6 +96,7 @@ var Zoom = /*#__PURE__*/function (_Control) {
|
|
|
69
96
|
key: "setOptions",
|
|
70
97
|
value: function setOptions(newOptions) {
|
|
71
98
|
(0, _get2.default)((0, _getPrototypeOf2.default)(Zoom.prototype), "setOptions", this).call(this, newOptions);
|
|
99
|
+
|
|
72
100
|
if (this.checkUpdateOption(newOptions, ['zoomInText', 'zoomInTitle', 'zoomOutText', 'zoomOutTitle'])) {
|
|
73
101
|
this.resetButtonGroup(this.container);
|
|
74
102
|
}
|
|
@@ -77,6 +105,7 @@ var Zoom = /*#__PURE__*/function (_Control) {
|
|
|
77
105
|
key: "onAdd",
|
|
78
106
|
value: function onAdd() {
|
|
79
107
|
var container = _l7Utils.DOM.create('div', 'l7-control-zoom');
|
|
108
|
+
|
|
80
109
|
this.resetButtonGroup(container);
|
|
81
110
|
this.mapsService.on('zoomend', this.updateDisabled);
|
|
82
111
|
this.mapsService.on('zoomchange', this.updateDisabled);
|
|
@@ -106,6 +135,7 @@ var Zoom = /*#__PURE__*/function (_Control) {
|
|
|
106
135
|
key: "resetButtonGroup",
|
|
107
136
|
value: function resetButtonGroup(container) {
|
|
108
137
|
_l7Utils.DOM.clearChildren(container);
|
|
138
|
+
|
|
109
139
|
this.zoomInButton = this.createButton(this.controlOption.zoomInText, this.controlOption.zoomInTitle, 'l7-button-control', container, this.zoomIn);
|
|
110
140
|
this.zoomOutButton = this.createButton(this.controlOption.zoomOutText, this.controlOption.zoomOutTitle, 'l7-button-control', container, this.zoomOut);
|
|
111
141
|
this.updateDisabled();
|
|
@@ -114,11 +144,13 @@ var Zoom = /*#__PURE__*/function (_Control) {
|
|
|
114
144
|
key: "createButton",
|
|
115
145
|
value: function createButton(html, tile, className, container, fn) {
|
|
116
146
|
var link = _l7Utils.DOM.create('button', className, container);
|
|
147
|
+
|
|
117
148
|
if (typeof html === 'string') {
|
|
118
149
|
link.innerHTML = html;
|
|
119
150
|
} else {
|
|
120
151
|
link.append(html);
|
|
121
152
|
}
|
|
153
|
+
|
|
122
154
|
link.title = tile;
|
|
123
155
|
link.addEventListener('click', fn);
|
|
124
156
|
return link;
|
|
@@ -126,4 +158,5 @@ var Zoom = /*#__PURE__*/function (_Control) {
|
|
|
126
158
|
}]);
|
|
127
159
|
return Zoom;
|
|
128
160
|
}(_baseControl.Control);
|
|
161
|
+
|
|
129
162
|
exports.default = exports.Zoom = Zoom;
|