@antv/l7-component 2.9.37-alpha.1 → 2.9.37-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/package.json +5 -5
  2. package/es/assets/iconfont/iconfont.js +0 -52
  3. package/es/constants/index.d.ts +0 -60
  4. package/es/constants/index.js +0 -60
  5. package/es/control/baseControl/buttonControl.d.ts +0 -59
  6. package/es/control/baseControl/buttonControl.js +0 -191
  7. package/es/control/baseControl/control.d.ts +0 -113
  8. package/es/control/baseControl/control.js +0 -301
  9. package/es/control/baseControl/index.d.ts +0 -4
  10. package/es/control/baseControl/index.js +0 -4
  11. package/es/control/baseControl/popperControl.d.ts +0 -26
  12. package/es/control/baseControl/popperControl.js +0 -131
  13. package/es/control/baseControl/selectControl.d.ts +0 -46
  14. package/es/control/baseControl/selectControl.js +0 -232
  15. package/es/control/exportImage.d.ts +0 -18
  16. package/es/control/exportImage.js +0 -163
  17. package/es/control/fullscreen.d.ts +0 -19
  18. package/es/control/fullscreen.js +0 -151
  19. package/es/control/geoLocate.d.ts +0 -16
  20. package/es/control/geoLocate.js +0 -139
  21. package/es/control/layerControl.d.ts +0 -21
  22. package/es/control/layerControl.js +0 -172
  23. package/es/control/logo.d.ts +0 -13
  24. package/es/control/logo.js +0 -87
  25. package/es/control/mapTheme.d.ts +0 -10
  26. package/es/control/mapTheme.js +0 -135
  27. package/es/control/mouseLocation.d.ts +0 -15
  28. package/es/control/mouseLocation.js +0 -104
  29. package/es/control/scale.d.ts +0 -34
  30. package/es/control/scale.js +0 -172
  31. package/es/control/zoom.d.ts +0 -35
  32. package/es/control/zoom.js +0 -146
  33. package/es/css/button.less +0 -70
  34. package/es/css/control.less +0 -71
  35. package/es/css/index.css +0 -567
  36. package/es/css/index.less +0 -12
  37. package/es/css/l7.less +0 -60
  38. package/es/css/layerPopup.less +0 -8
  39. package/es/css/logo.less +0 -18
  40. package/es/css/mouseLocation.less +0 -9
  41. package/es/css/popper.less +0 -64
  42. package/es/css/popup.less +0 -169
  43. package/es/css/scale.less +0 -34
  44. package/es/css/select.less +0 -86
  45. package/es/css/variables.less +0 -28
  46. package/es/css/zoom.less +0 -21
  47. package/es/images/layers.png +0 -0
  48. package/es/images/layers.svg +0 -1
  49. package/es/images/logo.png +0 -0
  50. package/es/images/quanping.svg +0 -12
  51. package/es/index.d.ts +0 -18
  52. package/es/index.js +0 -59
  53. package/es/interface.d.ts +0 -18
  54. package/es/interface.js +0 -1
  55. package/es/marker-layer.d.ts +0 -53
  56. package/es/marker-layer.js +0 -363
  57. package/es/marker.d.ts +0 -49
  58. package/es/marker.js +0 -434
  59. package/es/popup/layerPopup.d.ts +0 -78
  60. package/es/popup/layerPopup.js +0 -308
  61. package/es/popup/popup.d.ts +0 -147
  62. package/es/popup/popup.js +0 -636
  63. package/es/utils/anchor.d.ts +0 -22
  64. package/es/utils/anchor.js +0 -35
  65. package/es/utils/icon.d.ts +0 -1
  66. package/es/utils/icon.js +0 -9
  67. package/es/utils/popper.d.ts +0 -75
  68. package/es/utils/popper.js +0 -286
  69. package/es/utils/screenfull.d.ts +0 -2
  70. package/es/utils/screenfull.js +0 -157
  71. package/lib/assets/iconfont/iconfont.js +0 -54
  72. package/lib/constants/index.js +0 -68
  73. package/lib/control/baseControl/buttonControl.js +0 -207
  74. package/lib/control/baseControl/control.js +0 -327
  75. package/lib/control/baseControl/index.js +0 -57
  76. package/lib/control/baseControl/popperControl.js +0 -142
  77. package/lib/control/baseControl/selectControl.js +0 -253
  78. package/lib/control/exportImage.js +0 -177
  79. package/lib/control/fullscreen.js +0 -164
  80. package/lib/control/geoLocate.js +0 -154
  81. package/lib/control/layerControl.js +0 -182
  82. package/lib/control/logo.js +0 -105
  83. package/lib/control/mapTheme.js +0 -151
  84. package/lib/control/mouseLocation.js +0 -120
  85. package/lib/control/scale.js +0 -189
  86. package/lib/control/zoom.js +0 -162
  87. package/lib/css/button.less +0 -70
  88. package/lib/css/control.less +0 -71
  89. package/lib/css/index.css +0 -567
  90. package/lib/css/index.less +0 -12
  91. package/lib/css/l7.less +0 -60
  92. package/lib/css/layerPopup.less +0 -8
  93. package/lib/css/logo.less +0 -18
  94. package/lib/css/mouseLocation.less +0 -9
  95. package/lib/css/popper.less +0 -64
  96. package/lib/css/popup.less +0 -169
  97. package/lib/css/scale.less +0 -34
  98. package/lib/css/select.less +0 -86
  99. package/lib/css/variables.less +0 -28
  100. package/lib/css/zoom.less +0 -21
  101. package/lib/images/layers.png +0 -0
  102. package/lib/images/layers.svg +0 -1
  103. package/lib/images/logo.png +0 -0
  104. package/lib/images/quanping.svg +0 -12
  105. package/lib/index.js +0 -254
  106. package/lib/interface.js +0 -5
  107. package/lib/marker-layer.js +0 -381
  108. package/lib/marker.js +0 -449
  109. package/lib/popup/layerPopup.js +0 -317
  110. package/lib/popup/popup.js +0 -651
  111. package/lib/utils/anchor.js +0 -45
  112. package/lib/utils/icon.js +0 -18
  113. package/lib/utils/popper.js +0 -297
  114. package/lib/utils/screenfull.js +0 -167
@@ -1,151 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = exports.MapTheme = void 0;
9
-
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
21
-
22
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
-
24
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
25
-
26
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
27
-
28
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
29
-
30
- var _constants = require("../constants");
31
-
32
- var _icon = require("../utils/icon");
33
-
34
- var _selectControl = _interopRequireDefault(require("./baseControl/selectControl"));
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 MapTheme = /*#__PURE__*/function (_SelectControl) {
41
- (0, _inherits2.default)(MapTheme, _SelectControl);
42
-
43
- var _super = _createSuper(MapTheme);
44
-
45
- function MapTheme() {
46
- var _this;
47
-
48
- (0, _classCallCheck2.default)(this, MapTheme);
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), "onMapThemeChange", function () {
56
- _this.mapsService.setMapStyle(_this.selectValue[0]);
57
- });
58
- return _this;
59
- }
60
-
61
- (0, _createClass2.default)(MapTheme, [{
62
- key: "getDefault",
63
- value: function getDefault(option) {
64
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(MapTheme.prototype), "getDefault", this).call(this, option)), {}, {
65
- title: '地图样式',
66
- btnIcon: (0, _icon.createL7Icon)('l7-icon-color'),
67
- options: []
68
- });
69
- }
70
- }, {
71
- key: "getStyleOptions",
72
- value: function getStyleOptions() {
73
- var mapStyleConfig = this.mapsService.getType() === 'mapbox' ? _constants.MapboxMapStyleConfig : _constants.GaodeMapStyleConfig;
74
- return Object.entries(this.mapsService.getMapStyleConfig()).filter(function (_ref) {
75
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
76
- key = _ref2[0],
77
- value = _ref2[1];
78
-
79
- return typeof value === 'string' && key !== 'blank';
80
- }).map(function (_ref3) {
81
- var _mapStyleConfig$key;
82
-
83
- var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
84
- key = _ref4[0],
85
- value = _ref4[1];
86
-
87
- // @ts-ignore
88
- var _ref5 = (_mapStyleConfig$key = mapStyleConfig[key]) !== null && _mapStyleConfig$key !== void 0 ? _mapStyleConfig$key : {},
89
- text = _ref5.text,
90
- img = _ref5.img;
91
-
92
- return {
93
- text: text !== null && text !== void 0 ? text : key,
94
- value: value,
95
- img: img,
96
- key: key
97
- };
98
- });
99
- }
100
- }, {
101
- key: "getMapStyle",
102
- value: function getMapStyle() {
103
- return this.mapsService.getMapStyle();
104
- }
105
- }, {
106
- key: "onAdd",
107
- value: function onAdd() {
108
- var _this$controlOption$o,
109
- _this2 = this;
110
-
111
- if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
112
- this.controlOption.options = this.getStyleOptions();
113
- }
114
-
115
- if (this.controlOption.defaultValue) {
116
- var _this$controlOption$o2, _this$controlOption$o3;
117
-
118
- var defaultValue = this.controlOption.defaultValue;
119
- this.controlOption.defaultValue = (_this$controlOption$o2 = (_this$controlOption$o3 = this.controlOption.options.find(function (item) {
120
- return item.key === defaultValue;
121
- })) === null || _this$controlOption$o3 === void 0 ? void 0 : _this$controlOption$o3.value) !== null && _this$controlOption$o2 !== void 0 ? _this$controlOption$o2 : defaultValue;
122
- } else {
123
- var defaultStyle = this.getMapStyle();
124
-
125
- if (defaultStyle) {
126
- this.controlOption.defaultValue = defaultStyle;
127
- } else {
128
- // @ts-ignore
129
- this.mapsService.map.once('styledata', function () {
130
- var mapboxStyle = _this2.mapsService.getMapStyle();
131
-
132
- _this2.controlOption.defaultValue = mapboxStyle;
133
-
134
- _this2.setSelectValue(mapboxStyle, false);
135
- });
136
- }
137
- }
138
-
139
- this.on('selectChange', this.onMapThemeChange);
140
- return (0, _get2.default)((0, _getPrototypeOf2.default)(MapTheme.prototype), "onAdd", this).call(this);
141
- }
142
- }, {
143
- key: "getIsMultiple",
144
- value: function getIsMultiple() {
145
- return false;
146
- }
147
- }]);
148
- return MapTheme;
149
- }(_selectControl.default);
150
-
151
- exports.default = exports.MapTheme = MapTheme;
@@ -1,120 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = exports.MouseLocation = void 0;
9
-
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
- var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
21
-
22
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
23
-
24
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
25
-
26
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
27
-
28
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
29
-
30
- var _l7Core = require("@antv/l7-core");
31
-
32
- var _l7Utils = require("@antv/l7-utils");
33
-
34
- var _control = _interopRequireDefault(require("./baseControl/control"));
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 MouseLocation = /*#__PURE__*/function (_Control) {
41
- (0, _inherits2.default)(MouseLocation, _Control);
42
-
43
- var _super = _createSuper(MouseLocation);
44
-
45
- function MouseLocation() {
46
- var _this;
47
-
48
- (0, _classCallCheck2.default)(this, MouseLocation);
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), "location", [0, 0]);
56
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMouseMove", function (e) {
57
- var position = _this.location;
58
- var lngLat = e.lngLat || e.lnglat;
59
- var transform = _this.controlOption.transform;
60
-
61
- if (lngLat) {
62
- position = [lngLat.lng, lngLat.lat];
63
- }
64
-
65
- _this.location = position;
66
-
67
- if (transform) {
68
- position = transform(position);
69
- }
70
-
71
- _this.insertLocation2HTML(position);
72
-
73
- _this.emit('locationChange', position);
74
- });
75
- return _this;
76
- }
77
-
78
- (0, _createClass2.default)(MouseLocation, [{
79
- key: "getLocation",
80
- value: function getLocation() {
81
- return this.location;
82
- }
83
- }, {
84
- key: "getDefault",
85
- value: function getDefault(option) {
86
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(MouseLocation.prototype), "getDefault", this).call(this, option)), {}, {
87
- position: _l7Core.PositionType.BOTTOMLEFT,
88
- transform: function transform(_ref) {
89
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
90
- lng = _ref2[0],
91
- lat = _ref2[1];
92
-
93
- return [+(+lng).toFixed(6), +(+lat).toFixed(6)];
94
- }
95
- });
96
- }
97
- }, {
98
- key: "onAdd",
99
- value: function onAdd() {
100
- var container = _l7Utils.DOM.create('div', 'l7-control-mouse-location');
101
-
102
- container.innerHTML = '&nbsp;';
103
- this.mapsService.on('mousemove', this.onMouseMove);
104
- return container;
105
- }
106
- }, {
107
- key: "onRemove",
108
- value: function onRemove() {
109
- this.mapsService.off('mousemove', this.onMouseMove);
110
- }
111
- }, {
112
- key: "insertLocation2HTML",
113
- value: function insertLocation2HTML(position) {
114
- this.container.innerText = position.join(', ');
115
- }
116
- }]);
117
- return MouseLocation;
118
- }(_control.default);
119
-
120
- exports.default = exports.MouseLocation = MouseLocation;
@@ -1,189 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
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];
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;
62
- }
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
- });
76
- }
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;
89
- }
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);
96
- }
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
- }
105
- }
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
- }
120
- }
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();
145
- }
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;
@@ -1,162 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
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();
58
- }
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();
63
- }
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');
74
- }
75
-
76
- if (_this.disabled || mapsService.getZoom() >= mapsService.getMaxZoom()) {
77
- _this.zoomInButton.setAttribute('disabled', 'true');
78
- }
79
- });
80
- return _this;
81
- }
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
- });
94
- }
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
- }
103
- }
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;
@@ -1,70 +0,0 @@
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
- }