@antv/l7-component 2.9.32-alpha.2 → 2.9.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/control/BaseControl.d.ts +27 -0
- package/es/control/BaseControl.js +134 -0
- package/es/control/layer.d.ts +38 -0
- package/es/control/layer.js +340 -0
- package/es/control/logo.d.ts +9 -0
- package/es/control/logo.js +57 -0
- package/es/control/scale.d.ts +24 -0
- package/es/control/scale.js +148 -0
- package/es/control/zoom.d.ts +24 -0
- package/es/control/zoom.js +119 -0
- package/es/css/l7.css +502 -0
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +1 -0
- package/es/images/logo.png +0 -0
- package/es/index.d.ts +11 -0
- package/es/index.js +53 -0
- package/es/interface.d.ts +37 -0
- package/es/interface.js +1 -0
- package/es/marker-layer.d.ts +53 -0
- package/es/marker-layer.js +363 -0
- package/es/marker.d.ts +49 -0
- package/es/marker.js +434 -0
- package/es/popup.d.ts +35 -0
- package/es/popup.js +300 -0
- package/es/utils/anchor.d.ts +22 -0
- package/es/utils/anchor.js +35 -0
- package/lib/control/BaseControl.js +160 -0
- package/lib/control/layer.js +362 -0
- package/lib/control/logo.js +78 -0
- package/lib/control/scale.js +169 -0
- package/lib/control/zoom.js +143 -0
- package/lib/css/l7.css +502 -0
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +1 -0
- package/lib/images/logo.png +0 -0
- package/lib/index.js +139 -0
- package/lib/interface.js +5 -0
- package/lib/marker-layer.js +381 -0
- package/lib/marker.js +449 -0
- package/lib/popup.js +317 -0
- package/lib/utils/anchor.js +45 -0
- package/package.json +5 -8
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
|
|
8
|
+
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); }; }
|
|
9
|
+
|
|
10
|
+
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; } }
|
|
11
|
+
|
|
12
|
+
import { bindAll, DOM, lnglatDistance } from '@antv/l7-utils';
|
|
13
|
+
import Control, { PositionType } from "./BaseControl";
|
|
14
|
+
|
|
15
|
+
var Scale = /*#__PURE__*/function (_Control) {
|
|
16
|
+
_inherits(Scale, _Control);
|
|
17
|
+
|
|
18
|
+
var _super = _createSuper(Scale);
|
|
19
|
+
|
|
20
|
+
function Scale(cfg) {
|
|
21
|
+
var _this;
|
|
22
|
+
|
|
23
|
+
_classCallCheck(this, Scale);
|
|
24
|
+
|
|
25
|
+
_this = _super.call(this, cfg);
|
|
26
|
+
bindAll(['update'], _assertThisInitialized(_this));
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_createClass(Scale, [{
|
|
31
|
+
key: "getDefault",
|
|
32
|
+
value: function getDefault() {
|
|
33
|
+
return {
|
|
34
|
+
position: PositionType.BOTTOMLEFT,
|
|
35
|
+
maxWidth: 100,
|
|
36
|
+
metric: true,
|
|
37
|
+
updateWhenIdle: false,
|
|
38
|
+
imperial: false,
|
|
39
|
+
name: 'scale'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
key: "onAdd",
|
|
44
|
+
value: function onAdd() {
|
|
45
|
+
var className = 'l7-control-scale';
|
|
46
|
+
var container = DOM.create('div', className);
|
|
47
|
+
this.addScales(className + '-line', container);
|
|
48
|
+
var updateWhenIdle = this.controlOption.updateWhenIdle; // TODO: 高德地图和MapBox地图事件不一致问题
|
|
49
|
+
// 高德zoomchange
|
|
50
|
+
|
|
51
|
+
this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
52
|
+
this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
53
|
+
this.update();
|
|
54
|
+
return container;
|
|
55
|
+
}
|
|
56
|
+
}, {
|
|
57
|
+
key: "onRemove",
|
|
58
|
+
value: function onRemove() {
|
|
59
|
+
var updateWhenIdle = this.controlOption.updateWhenIdle;
|
|
60
|
+
this.mapsService.off(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
61
|
+
this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "update",
|
|
65
|
+
value: function update() {
|
|
66
|
+
var mapsService = this.mapsService;
|
|
67
|
+
var maxWidth = this.controlOption.maxWidth;
|
|
68
|
+
var y = mapsService.getSize()[1] / 2;
|
|
69
|
+
var p1 = mapsService.containerToLngLat([0, y]);
|
|
70
|
+
var p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
71
|
+
var maxMeters = lnglatDistance([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
72
|
+
this.updateScales(maxMeters);
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "updateScales",
|
|
76
|
+
value: function updateScales(maxMeters) {
|
|
77
|
+
var _this$controlOption = this.controlOption,
|
|
78
|
+
metric = _this$controlOption.metric,
|
|
79
|
+
imperial = _this$controlOption.imperial;
|
|
80
|
+
|
|
81
|
+
if (metric && maxMeters) {
|
|
82
|
+
this.updateMetric(maxMeters);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (imperial && maxMeters) {
|
|
86
|
+
this.updateImperial(maxMeters);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "updateMetric",
|
|
91
|
+
value: function updateMetric(maxMeters) {
|
|
92
|
+
var meters = this.getRoundNum(maxMeters);
|
|
93
|
+
var label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
|
|
94
|
+
this.updateScale(this.mScale, label, meters / maxMeters);
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "updateImperial",
|
|
98
|
+
value: function updateImperial(maxMeters) {
|
|
99
|
+
var maxFeet = maxMeters * 3.2808399;
|
|
100
|
+
var maxMiles;
|
|
101
|
+
var miles;
|
|
102
|
+
var feet;
|
|
103
|
+
|
|
104
|
+
if (maxFeet > 5280) {
|
|
105
|
+
maxMiles = maxFeet / 5280;
|
|
106
|
+
miles = this.getRoundNum(maxMiles);
|
|
107
|
+
this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
|
|
108
|
+
} else {
|
|
109
|
+
feet = this.getRoundNum(maxFeet);
|
|
110
|
+
this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "updateScale",
|
|
115
|
+
value: function updateScale(scale, text, ratio) {
|
|
116
|
+
var maxWidth = this.controlOption.maxWidth;
|
|
117
|
+
scale.style.width = Math.round(maxWidth * ratio) + 'px';
|
|
118
|
+
scale.innerHTML = text;
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "getRoundNum",
|
|
122
|
+
value: function getRoundNum(num) {
|
|
123
|
+
var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
|
|
124
|
+
var d = num / pow10;
|
|
125
|
+
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
126
|
+
return pow10 * d;
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "addScales",
|
|
130
|
+
value: function addScales(className, container) {
|
|
131
|
+
var _this$controlOption2 = this.controlOption,
|
|
132
|
+
metric = _this$controlOption2.metric,
|
|
133
|
+
imperial = _this$controlOption2.imperial;
|
|
134
|
+
|
|
135
|
+
if (metric) {
|
|
136
|
+
this.mScale = DOM.create('div', className, container);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (imperial) {
|
|
140
|
+
this.iScale = DOM.create('div', className, container);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}]);
|
|
144
|
+
|
|
145
|
+
return Scale;
|
|
146
|
+
}(Control);
|
|
147
|
+
|
|
148
|
+
export { Scale as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IZoomControlOption } from '../interface';
|
|
2
|
+
import Control, { PositionType } from './BaseControl';
|
|
3
|
+
export default class Zoom extends Control {
|
|
4
|
+
private disabled;
|
|
5
|
+
private zoomInButton;
|
|
6
|
+
private zoomOutButton;
|
|
7
|
+
constructor(cfg?: Partial<IZoomControlOption>);
|
|
8
|
+
getDefault(): {
|
|
9
|
+
position: PositionType;
|
|
10
|
+
zoomInText: string;
|
|
11
|
+
zoomInTitle: string;
|
|
12
|
+
zoomOutText: string;
|
|
13
|
+
zoomOutTitle: string;
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
onAdd(): HTMLElement;
|
|
17
|
+
onRemove(): void;
|
|
18
|
+
disable(): this;
|
|
19
|
+
enable(): this;
|
|
20
|
+
private zoomIn;
|
|
21
|
+
private zoomOut;
|
|
22
|
+
private createButton;
|
|
23
|
+
private updateDisabled;
|
|
24
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
|
|
8
|
+
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); }; }
|
|
9
|
+
|
|
10
|
+
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; } }
|
|
11
|
+
|
|
12
|
+
import { bindAll, DOM } from '@antv/l7-utils';
|
|
13
|
+
import Control, { PositionType } from "./BaseControl";
|
|
14
|
+
|
|
15
|
+
var Zoom = /*#__PURE__*/function (_Control) {
|
|
16
|
+
_inherits(Zoom, _Control);
|
|
17
|
+
|
|
18
|
+
var _super = _createSuper(Zoom);
|
|
19
|
+
|
|
20
|
+
function Zoom(cfg) {
|
|
21
|
+
var _this;
|
|
22
|
+
|
|
23
|
+
_classCallCheck(this, Zoom);
|
|
24
|
+
|
|
25
|
+
_this = _super.call(this, cfg);
|
|
26
|
+
bindAll(['updateDisabled', 'zoomIn', 'zoomOut'], _assertThisInitialized(_this));
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
_createClass(Zoom, [{
|
|
31
|
+
key: "getDefault",
|
|
32
|
+
value: function getDefault() {
|
|
33
|
+
return {
|
|
34
|
+
position: PositionType.TOPLEFT,
|
|
35
|
+
zoomInText: '+',
|
|
36
|
+
zoomInTitle: 'Zoom in',
|
|
37
|
+
zoomOutText: '−',
|
|
38
|
+
zoomOutTitle: 'Zoom out',
|
|
39
|
+
name: 'zoom'
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
key: "onAdd",
|
|
44
|
+
value: function onAdd() {
|
|
45
|
+
var zoomName = 'l7-control-zoom';
|
|
46
|
+
var container = DOM.create('div', zoomName + ' l7-bar');
|
|
47
|
+
this.zoomInButton = this.createButton(this.controlOption.zoomInText, this.controlOption.zoomInTitle, zoomName + '-in', container, this.zoomIn);
|
|
48
|
+
this.zoomOutButton = this.createButton(this.controlOption.zoomOutText, this.controlOption.zoomOutTitle, zoomName + '-out', container, this.zoomOut);
|
|
49
|
+
this.mapsService.on('zoomend', this.updateDisabled);
|
|
50
|
+
this.mapsService.on('zoomchange', this.updateDisabled);
|
|
51
|
+
this.updateDisabled();
|
|
52
|
+
return container;
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "onRemove",
|
|
56
|
+
value: function onRemove() {
|
|
57
|
+
this.mapsService.off('zoomend', this.updateDisabled);
|
|
58
|
+
this.mapsService.off('zoomchange', this.updateDisabled);
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "disable",
|
|
62
|
+
value: function disable() {
|
|
63
|
+
this.disabled = true;
|
|
64
|
+
this.updateDisabled();
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "enable",
|
|
69
|
+
value: function enable() {
|
|
70
|
+
this.disabled = false;
|
|
71
|
+
this.updateDisabled();
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
}, {
|
|
75
|
+
key: "zoomIn",
|
|
76
|
+
value: function zoomIn() {
|
|
77
|
+
if (!this.disabled && this.mapsService.getZoom() < this.mapsService.getMaxZoom()) {
|
|
78
|
+
this.mapsService.zoomIn();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
key: "zoomOut",
|
|
83
|
+
value: function zoomOut() {
|
|
84
|
+
if (!this.disabled && this.mapsService.getZoom() > this.mapsService.getMinZoom()) {
|
|
85
|
+
this.mapsService.zoomOut();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "createButton",
|
|
90
|
+
value: function createButton(html, tile, className, container, fn) {
|
|
91
|
+
var link = DOM.create('a', className, container);
|
|
92
|
+
link.innerHTML = html;
|
|
93
|
+
link.title = tile;
|
|
94
|
+
link.href = 'javascript:void(0)';
|
|
95
|
+
link.addEventListener('click', fn);
|
|
96
|
+
return link;
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "updateDisabled",
|
|
100
|
+
value: function updateDisabled() {
|
|
101
|
+
var mapsService = this.mapsService;
|
|
102
|
+
var className = 'l7-disabled';
|
|
103
|
+
DOM.removeClass(this.zoomInButton, className);
|
|
104
|
+
DOM.removeClass(this.zoomOutButton, className);
|
|
105
|
+
|
|
106
|
+
if (this.disabled || mapsService.getZoom() <= mapsService.getMinZoom()) {
|
|
107
|
+
DOM.addClass(this.zoomOutButton, className);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (this.disabled || mapsService.getZoom() >= mapsService.getMaxZoom()) {
|
|
111
|
+
DOM.addClass(this.zoomInButton, className);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}]);
|
|
115
|
+
|
|
116
|
+
return Zoom;
|
|
117
|
+
}(Control);
|
|
118
|
+
|
|
119
|
+
export { Zoom as default };
|