@antv/l7-component 2.18.2 → 2.18.3

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/es/assets/iconfont/iconfont.js +46 -0
  2. package/es/constants/index.d.ts +60 -0
  3. package/es/constants/index.js +60 -0
  4. package/es/control/baseControl/buttonControl.d.ts +59 -0
  5. package/es/control/baseControl/buttonControl.js +177 -0
  6. package/es/control/baseControl/control.d.ts +112 -0
  7. package/es/control/baseControl/control.js +302 -0
  8. package/es/control/baseControl/index.d.ts +4 -0
  9. package/es/control/baseControl/index.js +4 -0
  10. package/es/control/baseControl/popperControl.d.ts +26 -0
  11. package/es/control/baseControl/popperControl.js +120 -0
  12. package/es/control/baseControl/selectControl.d.ts +46 -0
  13. package/es/control/baseControl/selectControl.js +204 -0
  14. package/es/control/exportImage.d.ts +18 -0
  15. package/es/control/exportImage.js +159 -0
  16. package/es/control/fullscreen.d.ts +19 -0
  17. package/es/control/fullscreen.js +119 -0
  18. package/es/control/geoLocate.d.ts +16 -0
  19. package/es/control/geoLocate.js +107 -0
  20. package/es/control/layerSwitch.d.ts +19 -0
  21. package/es/control/layerSwitch.js +141 -0
  22. package/es/control/logo.d.ts +13 -0
  23. package/es/control/logo.js +75 -0
  24. package/es/control/mapTheme.d.ts +10 -0
  25. package/es/control/mapTheme.js +110 -0
  26. package/es/control/mouseLocation.d.ts +15 -0
  27. package/es/control/mouseLocation.js +83 -0
  28. package/es/control/scale.d.ts +34 -0
  29. package/es/control/scale.js +149 -0
  30. package/es/control/zoom.d.ts +38 -0
  31. package/es/control/zoom.js +132 -0
  32. package/es/css/button.less +70 -0
  33. package/es/css/control.less +71 -0
  34. package/es/css/index.css +594 -0
  35. package/es/css/index.less +12 -0
  36. package/es/css/l7.less +62 -0
  37. package/es/css/layerPopup.less +8 -0
  38. package/es/css/logo.less +18 -0
  39. package/es/css/mouseLocation.less +9 -0
  40. package/es/css/popper.less +64 -0
  41. package/es/css/popup.less +185 -0
  42. package/es/css/scale.less +34 -0
  43. package/es/css/select.less +86 -0
  44. package/es/css/variables.less +30 -0
  45. package/es/css/zoom.less +29 -0
  46. package/es/images/layers.png +0 -0
  47. package/es/images/layers.svg +1 -0
  48. package/es/images/logo.png +0 -0
  49. package/es/images/quanping.svg +12 -0
  50. package/es/index.d.ts +18 -0
  51. package/es/index.js +49 -0
  52. package/es/interface.d.ts +18 -0
  53. package/es/interface.js +1 -0
  54. package/es/marker-layer.d.ts +54 -0
  55. package/es/marker-layer.js +343 -0
  56. package/es/marker.d.ts +55 -0
  57. package/es/marker.js +410 -0
  58. package/es/popup/layerPopup.d.ts +86 -0
  59. package/es/popup/layerPopup.js +312 -0
  60. package/es/popup/popup.d.ts +139 -0
  61. package/es/popup/popup.js +567 -0
  62. package/es/utils/anchor.d.ts +22 -0
  63. package/es/utils/anchor.js +31 -0
  64. package/es/utils/icon.d.ts +1 -0
  65. package/es/utils/icon.js +9 -0
  66. package/es/utils/popper.d.ts +75 -0
  67. package/es/utils/popper.js +259 -0
  68. package/es/utils/screenfull.d.ts +2 -0
  69. package/es/utils/screenfull.js +128 -0
  70. package/lib/assets/iconfont/iconfont.js +48 -0
  71. package/lib/constants/index.js +68 -0
  72. package/lib/control/baseControl/buttonControl.js +183 -0
  73. package/lib/control/baseControl/control.js +314 -0
  74. package/lib/control/baseControl/index.js +39 -0
  75. package/lib/control/baseControl/popperControl.js +126 -0
  76. package/lib/control/baseControl/selectControl.js +210 -0
  77. package/lib/control/exportImage.js +165 -0
  78. package/lib/control/fullscreen.js +125 -0
  79. package/lib/control/geoLocate.js +113 -0
  80. package/lib/control/layerSwitch.js +147 -0
  81. package/lib/control/logo.js +81 -0
  82. package/lib/control/mapTheme.js +116 -0
  83. package/lib/control/mouseLocation.js +89 -0
  84. package/lib/control/scale.js +155 -0
  85. package/lib/control/zoom.js +138 -0
  86. package/lib/css/button.less +70 -0
  87. package/lib/css/control.less +71 -0
  88. package/lib/css/index.css +594 -0
  89. package/lib/css/index.less +12 -0
  90. package/lib/css/l7.less +62 -0
  91. package/lib/css/layerPopup.less +8 -0
  92. package/lib/css/logo.less +18 -0
  93. package/lib/css/mouseLocation.less +9 -0
  94. package/lib/css/popper.less +64 -0
  95. package/lib/css/popup.less +185 -0
  96. package/lib/css/scale.less +34 -0
  97. package/lib/css/select.less +86 -0
  98. package/lib/css/variables.less +30 -0
  99. package/lib/css/zoom.less +29 -0
  100. package/lib/images/layers.png +0 -0
  101. package/lib/images/layers.svg +1 -0
  102. package/lib/images/logo.png +0 -0
  103. package/lib/images/quanping.svg +12 -0
  104. package/lib/index.js +169 -0
  105. package/lib/interface.js +5 -0
  106. package/lib/marker-layer.js +349 -0
  107. package/lib/marker.js +417 -0
  108. package/lib/popup/layerPopup.js +317 -0
  109. package/lib/popup/popup.js +573 -0
  110. package/lib/utils/anchor.js +40 -0
  111. package/lib/utils/icon.js +16 -0
  112. package/lib/utils/popper.js +263 -0
  113. package/lib/utils/screenfull.js +136 -0
  114. package/package.json +6 -6
@@ -0,0 +1,141 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
+ import _get from "@babel/runtime/helpers/esm/get";
6
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
8
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
+ 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); }; }
11
+ 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; } }
12
+ import { createL7Icon } from "../utils/icon";
13
+ import SelectControl from "./baseControl/selectControl";
14
+ export { LayerSwitch };
15
+ var LayerSwitch = /*#__PURE__*/function (_SelectControl) {
16
+ _inherits(LayerSwitch, _SelectControl);
17
+ var _super = _createSuper(LayerSwitch);
18
+ function LayerSwitch() {
19
+ var _this;
20
+ _classCallCheck(this, LayerSwitch);
21
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
22
+ args[_key] = arguments[_key];
23
+ }
24
+ _this = _super.call.apply(_super, [this].concat(args));
25
+ _defineProperty(_assertThisInitialized(_this), "onLayerChange", function () {
26
+ var _this$controlOption$l;
27
+ if ((_this$controlOption$l = _this.controlOption.layers) !== null && _this$controlOption$l !== void 0 && _this$controlOption$l.length) {
28
+ return;
29
+ }
30
+ _this.selectValue = _this.getLayerVisible();
31
+ _this.setOptions({
32
+ options: _this.getLayerOptions()
33
+ });
34
+ });
35
+ _defineProperty(_assertThisInitialized(_this), "onLayerVisibleChane", function () {
36
+ _this.setSelectValue(_this.getLayerVisible());
37
+ });
38
+ _defineProperty(_assertThisInitialized(_this), "onSelectChange", function () {
39
+ _this.layers.forEach(function (layer) {
40
+ var needShow = _this.selectValue.includes(layer.name);
41
+ var isShow = layer.isVisible();
42
+ if (needShow && !isShow) {
43
+ layer.show();
44
+ }
45
+ if (!needShow && isShow) {
46
+ layer.hide();
47
+ }
48
+ });
49
+ });
50
+ return _this;
51
+ }
52
+ _createClass(LayerSwitch, [{
53
+ key: "layers",
54
+ get: function get() {
55
+ var layerService = this.layerService;
56
+ var layers = this.controlOption.layers;
57
+ if (Array.isArray(layers) && layers.length) {
58
+ var layerInstances = [];
59
+ layers.forEach(function (layer) {
60
+ if (layer instanceof Object) {
61
+ layerInstances.push(layer);
62
+ }
63
+ if (typeof layer === 'string') {
64
+ var targetLayer = layerService.getLayer(layer) || layerService.getLayerByName(layer);
65
+ if (targetLayer) {
66
+ layerInstances.push(targetLayer);
67
+ }
68
+ }
69
+ });
70
+ return layerInstances;
71
+ }
72
+ return layerService.getLayers() || [];
73
+ }
74
+ }, {
75
+ key: "getDefault",
76
+ value: function getDefault(option) {
77
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(LayerSwitch.prototype), "getDefault", this).call(this, option)), {}, {
78
+ title: '图层控制',
79
+ btnIcon: createL7Icon('l7-icon-layer'),
80
+ options: []
81
+ });
82
+ }
83
+ }, {
84
+ key: "getLayerVisible",
85
+ value: function getLayerVisible() {
86
+ return this.layers.filter(function (layer) {
87
+ return layer.isVisible();
88
+ }).map(function (layer) {
89
+ return layer.name;
90
+ });
91
+ }
92
+ }, {
93
+ key: "getLayerOptions",
94
+ value: function getLayerOptions() {
95
+ return this.layers.map(function (layer) {
96
+ return {
97
+ text: layer.name,
98
+ value: layer.name
99
+ };
100
+ });
101
+ }
102
+ }, {
103
+ key: "setOptions",
104
+ value: function setOptions(option) {
105
+ var isLayerChange = this.checkUpdateOption(option, ['layers']);
106
+ _get(_getPrototypeOf(LayerSwitch.prototype), "setOptions", this).call(this, option);
107
+ if (isLayerChange) {
108
+ this.selectValue = this.getLayerVisible();
109
+ this.controlOption.options = this.getLayerOptions();
110
+ this.popper.setContent(this.getPopperContent(this.controlOption.options));
111
+ }
112
+ }
113
+ }, {
114
+ key: "onAdd",
115
+ value: function onAdd() {
116
+ var _this$controlOption$o;
117
+ if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
118
+ this.controlOption.options = this.getLayerOptions();
119
+ }
120
+ if (!this.controlOption.defaultValue) {
121
+ this.controlOption.defaultValue = this.getLayerVisible();
122
+ }
123
+ this.on('selectChange', this.onSelectChange);
124
+ this.layerService.on('layerChange', this.onLayerChange);
125
+ return _get(_getPrototypeOf(LayerSwitch.prototype), "onAdd", this).call(this);
126
+ }
127
+ }, {
128
+ key: "onRemove",
129
+ value: function onRemove() {
130
+ this.off('selectChange', this.onSelectChange);
131
+ this.layerService.off('layerChange', this.onLayerChange);
132
+ }
133
+ }, {
134
+ key: "getIsMultiple",
135
+ value: function getIsMultiple() {
136
+ return true;
137
+ }
138
+ }]);
139
+ return LayerSwitch;
140
+ }(SelectControl);
141
+ export { LayerSwitch as default };
@@ -0,0 +1,13 @@
1
+ import { Control, IControlOption } from './baseControl';
2
+ export interface ILogoControlOption extends IControlOption {
3
+ img: string;
4
+ href?: string | null;
5
+ }
6
+ export { Logo };
7
+ export default class Logo extends Control<ILogoControlOption> {
8
+ getDefault(): ILogoControlOption;
9
+ onAdd(): HTMLElement;
10
+ onRemove(): null;
11
+ setOptions(option: Partial<ILogoControlOption>): void;
12
+ protected setLogoContent(container: HTMLElement): void;
13
+ }
@@ -0,0 +1,75 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _get from "@babel/runtime/helpers/esm/get";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
+ 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); }; }
8
+ 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; } }
9
+ import { DOM } from '@antv/l7-utils';
10
+ import { Control, PositionType } from "./baseControl";
11
+ export { Logo };
12
+ var Logo = /*#__PURE__*/function (_Control) {
13
+ _inherits(Logo, _Control);
14
+ var _super = _createSuper(Logo);
15
+ function Logo() {
16
+ _classCallCheck(this, Logo);
17
+ return _super.apply(this, arguments);
18
+ }
19
+ _createClass(Logo, [{
20
+ key: "getDefault",
21
+ value: function getDefault() {
22
+ return {
23
+ position: PositionType.BOTTOMLEFT,
24
+ name: 'logo',
25
+ href: 'https://l7.antv.antgroup.com/',
26
+ img: 'https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*GRb1TKp4HcMAAAAAAAAAAAAAARQnAQ'
27
+ };
28
+ }
29
+ }, {
30
+ key: "onAdd",
31
+ value: function onAdd() {
32
+ var container = DOM.create('div', 'l7-control-logo');
33
+ this.setLogoContent(container);
34
+ return container;
35
+ }
36
+ }, {
37
+ key: "onRemove",
38
+ value: function onRemove() {
39
+ return null;
40
+ }
41
+ }, {
42
+ key: "setOptions",
43
+ value: function setOptions(option) {
44
+ _get(_getPrototypeOf(Logo.prototype), "setOptions", this).call(this, option);
45
+ if (this.checkUpdateOption(option, ['img', 'href'])) {
46
+ DOM.clearChildren(this.container);
47
+ this.setLogoContent(this.container);
48
+ }
49
+ }
50
+ }, {
51
+ key: "setLogoContent",
52
+ value: function setLogoContent(container) {
53
+ var _this$controlOption = this.controlOption,
54
+ href = _this$controlOption.href,
55
+ img = _this$controlOption.img;
56
+ var imgDOM = DOM.create('img');
57
+ imgDOM.setAttribute('src', img);
58
+ imgDOM.setAttribute('aria-label', 'AntV logo');
59
+ DOM.setUnDraggable(imgDOM);
60
+ if (href) {
61
+ var anchorDOM = DOM.create('a', 'l7-control-logo-link');
62
+ anchorDOM.target = '_blank';
63
+ anchorDOM.href = href;
64
+ anchorDOM.rel = 'noopener nofollow';
65
+ anchorDOM.setAttribute('rel', 'noopener nofollow');
66
+ anchorDOM.appendChild(imgDOM);
67
+ container.appendChild(anchorDOM);
68
+ } else {
69
+ container.appendChild(imgDOM);
70
+ }
71
+ }
72
+ }]);
73
+ return Logo;
74
+ }(Control);
75
+ export { Logo as default };
@@ -0,0 +1,10 @@
1
+ import SelectControl, { ControlOptionItem, ISelectControlOption } from './baseControl/selectControl';
2
+ export { MapTheme };
3
+ export default class MapTheme extends SelectControl<ISelectControlOption> {
4
+ getDefault(option?: Partial<ISelectControlOption>): ISelectControlOption;
5
+ getStyleOptions(): ControlOptionItem[];
6
+ getMapStyle(): any;
7
+ onAdd(): HTMLElement;
8
+ protected onMapThemeChange: () => void;
9
+ protected getIsMultiple(): boolean;
10
+ }
@@ -0,0 +1,110 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
6
+ import _get from "@babel/runtime/helpers/esm/get";
7
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
8
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
9
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
10
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
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
+ 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; } }
13
+ import { GaodeMapStyleConfig, MapboxMapStyleConfig } from "../constants";
14
+ import { createL7Icon } from "../utils/icon";
15
+ import SelectControl from "./baseControl/selectControl";
16
+ export { MapTheme };
17
+ var MapTheme = /*#__PURE__*/function (_SelectControl) {
18
+ _inherits(MapTheme, _SelectControl);
19
+ var _super = _createSuper(MapTheme);
20
+ function MapTheme() {
21
+ var _this;
22
+ _classCallCheck(this, MapTheme);
23
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24
+ args[_key] = arguments[_key];
25
+ }
26
+ _this = _super.call.apply(_super, [this].concat(args));
27
+ _defineProperty(_assertThisInitialized(_this), "onMapThemeChange", function () {
28
+ _this.mapsService.setMapStyle(_this.selectValue[0]);
29
+ });
30
+ return _this;
31
+ }
32
+ _createClass(MapTheme, [{
33
+ key: "getDefault",
34
+ value: function getDefault(option) {
35
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(MapTheme.prototype), "getDefault", this).call(this, option)), {}, {
36
+ title: '地图样式',
37
+ btnIcon: createL7Icon('l7-icon-color'),
38
+ options: []
39
+ });
40
+ }
41
+ }, {
42
+ key: "getStyleOptions",
43
+ value: function getStyleOptions() {
44
+ var mapStyleConfig = this.mapsService.getType() === 'mapbox' ? MapboxMapStyleConfig : GaodeMapStyleConfig;
45
+ return Object.entries(this.mapsService.getMapStyleConfig()).filter(function (_ref) {
46
+ var _ref2 = _slicedToArray(_ref, 2),
47
+ key = _ref2[0],
48
+ value = _ref2[1];
49
+ return typeof value === 'string' && key !== 'blank';
50
+ }).map(function (_ref3) {
51
+ var _mapStyleConfig$key;
52
+ var _ref4 = _slicedToArray(_ref3, 2),
53
+ key = _ref4[0],
54
+ value = _ref4[1];
55
+ // @ts-ignore
56
+ var _ref5 = (_mapStyleConfig$key = mapStyleConfig[key]) !== null && _mapStyleConfig$key !== void 0 ? _mapStyleConfig$key : {},
57
+ text = _ref5.text,
58
+ img = _ref5.img;
59
+ return {
60
+ text: text !== null && text !== void 0 ? text : key,
61
+ value: value,
62
+ img: img,
63
+ key: key
64
+ };
65
+ });
66
+ }
67
+ }, {
68
+ key: "getMapStyle",
69
+ value: function getMapStyle() {
70
+ return this.mapsService.getMapStyle();
71
+ }
72
+ }, {
73
+ key: "onAdd",
74
+ value: function onAdd() {
75
+ var _this$controlOption$o,
76
+ _this2 = this;
77
+ if (!((_this$controlOption$o = this.controlOption.options) !== null && _this$controlOption$o !== void 0 && _this$controlOption$o.length)) {
78
+ this.controlOption.options = this.getStyleOptions();
79
+ }
80
+ if (this.controlOption.defaultValue) {
81
+ var _this$controlOption$o2, _this$controlOption$o3;
82
+ var defaultValue = this.controlOption.defaultValue;
83
+ this.controlOption.defaultValue = (_this$controlOption$o2 = (_this$controlOption$o3 = this.controlOption.options.find(function (item) {
84
+ return item.key === defaultValue;
85
+ })) === null || _this$controlOption$o3 === void 0 ? void 0 : _this$controlOption$o3.value) !== null && _this$controlOption$o2 !== void 0 ? _this$controlOption$o2 : defaultValue;
86
+ } else {
87
+ var defaultStyle = this.getMapStyle();
88
+ if (defaultStyle) {
89
+ this.controlOption.defaultValue = defaultStyle;
90
+ } else {
91
+ // @ts-ignore
92
+ this.mapsService.map.once('styledata', function () {
93
+ var mapboxStyle = _this2.mapsService.getMapStyle();
94
+ _this2.controlOption.defaultValue = mapboxStyle;
95
+ _this2.setSelectValue(mapboxStyle, false);
96
+ });
97
+ }
98
+ }
99
+ this.on('selectChange', this.onMapThemeChange);
100
+ return _get(_getPrototypeOf(MapTheme.prototype), "onAdd", this).call(this);
101
+ }
102
+ }, {
103
+ key: "getIsMultiple",
104
+ value: function getIsMultiple() {
105
+ return false;
106
+ }
107
+ }]);
108
+ return MapTheme;
109
+ }(SelectControl);
110
+ export { MapTheme as default };
@@ -0,0 +1,15 @@
1
+ import { Position } from '@antv/l7-core';
2
+ import Control, { IControlOption } from './baseControl/control';
3
+ export interface IMouseLocationControlOption extends IControlOption {
4
+ transform: (position: Position) => Position;
5
+ }
6
+ export { MouseLocation };
7
+ export default class MouseLocation extends Control<IMouseLocationControlOption> {
8
+ protected location: Position;
9
+ getLocation(): Position;
10
+ getDefault(option?: Partial<IMouseLocationControlOption>): IMouseLocationControlOption;
11
+ onAdd(): HTMLElement;
12
+ onRemove(): void;
13
+ protected onMouseMove: (e: any) => void;
14
+ protected insertLocation2HTML(position: Position): void;
15
+ }
@@ -0,0 +1,83 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
6
+ import _get from "@babel/runtime/helpers/esm/get";
7
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
8
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
9
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
10
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
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
+ 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; } }
13
+ import { PositionType } from '@antv/l7-core';
14
+ import { DOM } from '@antv/l7-utils';
15
+ import Control from "./baseControl/control";
16
+ export { MouseLocation };
17
+ var MouseLocation = /*#__PURE__*/function (_Control) {
18
+ _inherits(MouseLocation, _Control);
19
+ var _super = _createSuper(MouseLocation);
20
+ function MouseLocation() {
21
+ var _this;
22
+ _classCallCheck(this, MouseLocation);
23
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24
+ args[_key] = arguments[_key];
25
+ }
26
+ _this = _super.call.apply(_super, [this].concat(args));
27
+ _defineProperty(_assertThisInitialized(_this), "location", [0, 0]);
28
+ _defineProperty(_assertThisInitialized(_this), "onMouseMove", function (e) {
29
+ var position = _this.location;
30
+ var lngLat = e.lngLat || e.lnglat;
31
+ var transform = _this.controlOption.transform;
32
+ if (lngLat) {
33
+ position = [lngLat.lng, lngLat.lat];
34
+ }
35
+ _this.location = position;
36
+ if (transform) {
37
+ position = transform(position);
38
+ }
39
+ _this.insertLocation2HTML(position);
40
+ _this.emit('locationChange', position);
41
+ });
42
+ return _this;
43
+ }
44
+ _createClass(MouseLocation, [{
45
+ key: "getLocation",
46
+ value: function getLocation() {
47
+ return this.location;
48
+ }
49
+ }, {
50
+ key: "getDefault",
51
+ value: function getDefault(option) {
52
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(MouseLocation.prototype), "getDefault", this).call(this, option)), {}, {
53
+ position: PositionType.BOTTOMLEFT,
54
+ transform: function transform(_ref) {
55
+ var _ref2 = _slicedToArray(_ref, 2),
56
+ lng = _ref2[0],
57
+ lat = _ref2[1];
58
+ return [+(+lng).toFixed(6), +(+lat).toFixed(6)];
59
+ }
60
+ });
61
+ }
62
+ }, {
63
+ key: "onAdd",
64
+ value: function onAdd() {
65
+ var container = DOM.create('div', 'l7-control-mouse-location');
66
+ container.innerHTML = '&nbsp;';
67
+ this.mapsService.on('mousemove', this.onMouseMove);
68
+ return container;
69
+ }
70
+ }, {
71
+ key: "onRemove",
72
+ value: function onRemove() {
73
+ this.mapsService.off('mousemove', this.onMouseMove);
74
+ }
75
+ }, {
76
+ key: "insertLocation2HTML",
77
+ value: function insertLocation2HTML(position) {
78
+ this.container.innerText = position.join(', ');
79
+ }
80
+ }]);
81
+ return MouseLocation;
82
+ }(Control);
83
+ 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(): HTMLElement;
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,149 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
5
+ import _get from "@babel/runtime/helpers/esm/get";
6
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
7
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
8
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
10
+ 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); }; }
11
+ 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; } }
12
+ import { DOM, lnglatDistance } from '@antv/l7-utils';
13
+ import { Control, PositionType } from "./baseControl";
14
+ export { Scale };
15
+ var Scale = /*#__PURE__*/function (_Control) {
16
+ _inherits(Scale, _Control);
17
+ var _super = _createSuper(Scale);
18
+ function Scale() {
19
+ var _this;
20
+ _classCallCheck(this, Scale);
21
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
22
+ args[_key] = arguments[_key];
23
+ }
24
+ _this = _super.call.apply(_super, [this].concat(args));
25
+ _defineProperty(_assertThisInitialized(_this), "update", function () {
26
+ var mapsService = _this.mapsService;
27
+ var maxWidth = _this.controlOption.maxWidth;
28
+ var y = mapsService.getSize()[1] / 2;
29
+ var p1 = mapsService.containerToLngLat([0, y]);
30
+ var p2 = mapsService.containerToLngLat([maxWidth, y]);
31
+ var maxMeters = lnglatDistance([p1.lng, p1.lat], [p2.lng, p2.lat]);
32
+ _this.updateScales(maxMeters);
33
+ });
34
+ return _this;
35
+ }
36
+ _createClass(Scale, [{
37
+ key: "getDefault",
38
+ value: function getDefault(option) {
39
+ return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(Scale.prototype), "getDefault", this).call(this, option)), {}, {
40
+ name: 'scale',
41
+ position: PositionType.BOTTOMLEFT,
42
+ maxWidth: 100,
43
+ metric: true,
44
+ updateWhenIdle: false,
45
+ imperial: false,
46
+ lockWidth: true
47
+ });
48
+ }
49
+ }, {
50
+ key: "onAdd",
51
+ value: function onAdd() {
52
+ var className = 'l7-control-scale';
53
+ var container = DOM.create('div', className);
54
+ this.resetScaleLines(container);
55
+ var updateWhenIdle = this.controlOption.updateWhenIdle;
56
+ this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
57
+ this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
58
+ return container;
59
+ }
60
+ }, {
61
+ key: "onRemove",
62
+ value: function onRemove() {
63
+ var updateWhenIdle = this.controlOption.updateWhenIdle;
64
+ this.mapsService.off(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
65
+ this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
66
+ }
67
+ }, {
68
+ key: "setOptions",
69
+ value: function setOptions(newOption) {
70
+ _get(_getPrototypeOf(Scale.prototype), "setOptions", this).call(this, newOption);
71
+ if (this.checkUpdateOption(newOption, ['lockWidth', 'maxWidth', 'metric', 'updateWhenIdle', 'imperial'])) {
72
+ this.resetScaleLines(this.container);
73
+ }
74
+ }
75
+ }, {
76
+ key: "updateScales",
77
+ value: function updateScales(maxMeters) {
78
+ var _this$controlOption = this.controlOption,
79
+ metric = _this$controlOption.metric,
80
+ imperial = _this$controlOption.imperial;
81
+ if (metric && maxMeters) {
82
+ this.updateMetric(maxMeters);
83
+ }
84
+ if (imperial && maxMeters) {
85
+ this.updateImperial(maxMeters);
86
+ }
87
+ }
88
+ }, {
89
+ key: "resetScaleLines",
90
+ value: function resetScaleLines(container) {
91
+ DOM.clearChildren(container);
92
+ var _this$controlOption2 = this.controlOption,
93
+ metric = _this$controlOption2.metric,
94
+ imperial = _this$controlOption2.imperial,
95
+ maxWidth = _this$controlOption2.maxWidth,
96
+ lockWidth = _this$controlOption2.lockWidth;
97
+ if (lockWidth) {
98
+ DOM.addStyle(container, "width: ".concat(maxWidth, "px"));
99
+ }
100
+ if (metric) {
101
+ this.mScale = DOM.create('div', 'l7-control-scale-line', container);
102
+ }
103
+ if (imperial) {
104
+ this.iScale = DOM.create('div', 'l7-control-scale-line', container);
105
+ }
106
+ this.update();
107
+ }
108
+ }, {
109
+ key: "updateScale",
110
+ value: function updateScale(scale, text, ratio) {
111
+ var maxWidth = this.controlOption.maxWidth;
112
+ scale.style.width = Math.round(maxWidth * ratio) + 'px';
113
+ scale.innerHTML = text;
114
+ }
115
+ }, {
116
+ key: "getRoundNum",
117
+ value: function getRoundNum(num) {
118
+ var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
119
+ var d = num / pow10;
120
+ d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
121
+ return pow10 * d;
122
+ }
123
+ }, {
124
+ key: "updateMetric",
125
+ value: function updateMetric(maxMeters) {
126
+ var meters = this.getRoundNum(maxMeters);
127
+ var label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
128
+ this.updateScale(this.mScale, label, meters / maxMeters);
129
+ }
130
+ }, {
131
+ key: "updateImperial",
132
+ value: function updateImperial(maxMeters) {
133
+ var maxFeet = maxMeters * 3.2808399;
134
+ var maxMiles;
135
+ var miles;
136
+ var feet;
137
+ if (maxFeet > 5280) {
138
+ maxMiles = maxFeet / 5280;
139
+ miles = this.getRoundNum(maxMiles);
140
+ this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
141
+ } else {
142
+ feet = this.getRoundNum(maxFeet);
143
+ this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
144
+ }
145
+ }
146
+ }]);
147
+ return Scale;
148
+ }(Control);
149
+ export { Scale as default };
@@ -0,0 +1,38 @@
1
+ import { PositionType } from '@antv/l7-core';
2
+ import { DOM } from '@antv/l7-utils';
3
+ import { Control, IControlOption } from './baseControl';
4
+ export interface IZoomControlOption extends IControlOption {
5
+ zoomInText: DOM.ELType | string;
6
+ zoomInTitle: string;
7
+ zoomOutText: DOM.ELType | string;
8
+ zoomOutTitle: string;
9
+ showZoom: boolean;
10
+ }
11
+ export { Zoom };
12
+ export default class Zoom extends Control<IZoomControlOption> {
13
+ private disabled;
14
+ private zoomInButton;
15
+ private zoomOutButton;
16
+ private zoomNumDiv;
17
+ getDefault(option: Partial<IZoomControlOption>): {
18
+ position: PositionType;
19
+ name: string;
20
+ zoomInText: SVGSVGElement;
21
+ zoomInTitle: string;
22
+ zoomOutText: SVGSVGElement;
23
+ zoomOutTitle: string;
24
+ showZoom: boolean;
25
+ className?: string | undefined;
26
+ style?: string | undefined;
27
+ };
28
+ setOptions(newOptions: Partial<IZoomControlOption>): void;
29
+ onAdd(): HTMLElement;
30
+ onRemove(): void;
31
+ disable(): this;
32
+ enable(): this;
33
+ zoomIn: () => void;
34
+ zoomOut: () => void;
35
+ private resetButtonGroup;
36
+ private createButton;
37
+ private updateDisabled;
38
+ }