@antv/l7-component 2.9.32 → 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/lib/control/BaseControl.js +150 -100
- package/lib/control/layer.js +341 -248
- package/lib/control/logo.js +76 -52
- package/lib/control/scale.js +162 -112
- package/lib/control/zoom.js +137 -95
- package/lib/index.js +136 -53
- package/lib/interface.js +4 -16
- package/lib/marker-layer.js +367 -249
- package/lib/marker.js +419 -277
- package/lib/popup.js +302 -201
- package/lib/utils/anchor.js +37 -55
- package/package.json +5 -5
package/lib/control/logo.js
CHANGED
|
@@ -1,54 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
|
|
22
|
-
// src/control/logo.ts
|
|
23
|
-
var logo_exports = {};
|
|
24
|
-
__export(logo_exports, {
|
|
25
|
-
default: () => Logo
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
26
9
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
23
|
+
|
|
24
|
+
var _BaseControl = _interopRequireWildcard(require("./BaseControl"));
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
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); }; }
|
|
31
|
+
|
|
32
|
+
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; } }
|
|
33
|
+
|
|
34
|
+
var Logo = /*#__PURE__*/function (_Control) {
|
|
35
|
+
(0, _inherits2.default)(Logo, _Control);
|
|
36
|
+
|
|
37
|
+
var _super = _createSuper(Logo);
|
|
38
|
+
|
|
39
|
+
function Logo() {
|
|
40
|
+
(0, _classCallCheck2.default)(this, Logo);
|
|
41
|
+
return _super.apply(this, arguments);
|
|
51
42
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
|
|
44
|
+
(0, _createClass2.default)(Logo, [{
|
|
45
|
+
key: "getDefault",
|
|
46
|
+
value: function getDefault() {
|
|
47
|
+
return {
|
|
48
|
+
position: _BaseControl.PositionType.BOTTOMLEFT,
|
|
49
|
+
name: 'logo'
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "onAdd",
|
|
54
|
+
value: function onAdd() {
|
|
55
|
+
var className = 'l7-control-logo';
|
|
56
|
+
|
|
57
|
+
var container = _l7Utils.DOM.create('div', className);
|
|
58
|
+
|
|
59
|
+
var anchor = _l7Utils.DOM.create('a', 'l7-ctrl-logo');
|
|
60
|
+
|
|
61
|
+
anchor.target = '_blank';
|
|
62
|
+
anchor.rel = 'noopener nofollow';
|
|
63
|
+
anchor.href = 'https://antv.alipay.com/l7';
|
|
64
|
+
anchor.setAttribute('aria-label', 'AntV logo');
|
|
65
|
+
anchor.setAttribute('rel', 'noopener nofollow');
|
|
66
|
+
container.appendChild(anchor);
|
|
67
|
+
return container;
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "onRemove",
|
|
71
|
+
value: function onRemove() {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}]);
|
|
75
|
+
return Logo;
|
|
76
|
+
}(_BaseControl.default);
|
|
77
|
+
|
|
78
|
+
exports.default = Logo;
|
package/lib/control/scale.js
CHANGED
|
@@ -1,119 +1,169 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
|
|
22
|
-
// src/control/scale.ts
|
|
23
|
-
var scale_exports = {};
|
|
24
|
-
__export(scale_exports, {
|
|
25
|
-
default: () => Scale
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
26
9
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
66
|
-
const maxMeters = (0, import_l7_utils.lnglatDistance)([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
67
|
-
this.updateScales(maxMeters);
|
|
10
|
+
exports.default = void 0;
|
|
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 _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
+
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
+
|
|
24
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
25
|
+
|
|
26
|
+
var _BaseControl = _interopRequireWildcard(require("./BaseControl"));
|
|
27
|
+
|
|
28
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
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(cfg) {
|
|
42
|
+
var _this;
|
|
43
|
+
|
|
44
|
+
(0, _classCallCheck2.default)(this, Scale);
|
|
45
|
+
_this = _super.call(this, cfg);
|
|
46
|
+
(0, _l7Utils.bindAll)(['update'], (0, _assertThisInitialized2.default)(_this));
|
|
47
|
+
return _this;
|
|
68
48
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
49
|
+
|
|
50
|
+
(0, _createClass2.default)(Scale, [{
|
|
51
|
+
key: "getDefault",
|
|
52
|
+
value: function getDefault() {
|
|
53
|
+
return {
|
|
54
|
+
position: _BaseControl.PositionType.BOTTOMLEFT,
|
|
55
|
+
maxWidth: 100,
|
|
56
|
+
metric: true,
|
|
57
|
+
updateWhenIdle: false,
|
|
58
|
+
imperial: false,
|
|
59
|
+
name: 'scale'
|
|
60
|
+
};
|
|
73
61
|
}
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
}, {
|
|
63
|
+
key: "onAdd",
|
|
64
|
+
value: function onAdd() {
|
|
65
|
+
var className = 'l7-control-scale';
|
|
66
|
+
|
|
67
|
+
var container = _l7Utils.DOM.create('div', className);
|
|
68
|
+
|
|
69
|
+
this.addScales(className + '-line', container);
|
|
70
|
+
var updateWhenIdle = this.controlOption.updateWhenIdle; // TODO: 高德地图和MapBox地图事件不一致问题
|
|
71
|
+
// 高德zoomchange
|
|
72
|
+
|
|
73
|
+
this.mapsService.on(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
74
|
+
this.mapsService.on(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
75
|
+
this.update();
|
|
76
|
+
return container;
|
|
76
77
|
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
updateImperial(maxMeters) {
|
|
84
|
-
const maxFeet = maxMeters * 3.2808399;
|
|
85
|
-
let maxMiles;
|
|
86
|
-
let miles;
|
|
87
|
-
let feet;
|
|
88
|
-
if (maxFeet > 5280) {
|
|
89
|
-
maxMiles = maxFeet / 5280;
|
|
90
|
-
miles = this.getRoundNum(maxMiles);
|
|
91
|
-
this.updateScale(this.iScale, miles + " mi", miles / maxMiles);
|
|
92
|
-
} else {
|
|
93
|
-
feet = this.getRoundNum(maxFeet);
|
|
94
|
-
this.updateScale(this.iScale, feet + " ft", feet / maxFeet);
|
|
78
|
+
}, {
|
|
79
|
+
key: "onRemove",
|
|
80
|
+
value: function onRemove() {
|
|
81
|
+
var updateWhenIdle = this.controlOption.updateWhenIdle;
|
|
82
|
+
this.mapsService.off(updateWhenIdle ? 'zoomend' : 'zoomchange', this.update);
|
|
83
|
+
this.mapsService.off(updateWhenIdle ? 'moveend' : 'mapmove', this.update);
|
|
95
84
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
85
|
+
}, {
|
|
86
|
+
key: "update",
|
|
87
|
+
value: function update() {
|
|
88
|
+
var mapsService = this.mapsService;
|
|
89
|
+
var maxWidth = this.controlOption.maxWidth;
|
|
90
|
+
var y = mapsService.getSize()[1] / 2;
|
|
91
|
+
var p1 = mapsService.containerToLngLat([0, y]);
|
|
92
|
+
var p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
93
|
+
var maxMeters = (0, _l7Utils.lnglatDistance)([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
94
|
+
this.updateScales(maxMeters);
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "updateScales",
|
|
98
|
+
value: function updateScales(maxMeters) {
|
|
99
|
+
var _this$controlOption = this.controlOption,
|
|
100
|
+
metric = _this$controlOption.metric,
|
|
101
|
+
imperial = _this$controlOption.imperial;
|
|
102
|
+
|
|
103
|
+
if (metric && maxMeters) {
|
|
104
|
+
this.updateMetric(maxMeters);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (imperial && maxMeters) {
|
|
108
|
+
this.updateImperial(maxMeters);
|
|
109
|
+
}
|
|
112
110
|
}
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
}, {
|
|
112
|
+
key: "updateMetric",
|
|
113
|
+
value: function updateMetric(maxMeters) {
|
|
114
|
+
var meters = this.getRoundNum(maxMeters);
|
|
115
|
+
var label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
|
|
116
|
+
this.updateScale(this.mScale, label, meters / maxMeters);
|
|
115
117
|
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
}, {
|
|
119
|
+
key: "updateImperial",
|
|
120
|
+
value: function updateImperial(maxMeters) {
|
|
121
|
+
var maxFeet = maxMeters * 3.2808399;
|
|
122
|
+
var maxMiles;
|
|
123
|
+
var miles;
|
|
124
|
+
var feet;
|
|
125
|
+
|
|
126
|
+
if (maxFeet > 5280) {
|
|
127
|
+
maxMiles = maxFeet / 5280;
|
|
128
|
+
miles = this.getRoundNum(maxMiles);
|
|
129
|
+
this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
|
|
130
|
+
} else {
|
|
131
|
+
feet = this.getRoundNum(maxFeet);
|
|
132
|
+
this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}, {
|
|
136
|
+
key: "updateScale",
|
|
137
|
+
value: function updateScale(scale, text, ratio) {
|
|
138
|
+
var maxWidth = this.controlOption.maxWidth;
|
|
139
|
+
scale.style.width = Math.round(maxWidth * ratio) + 'px';
|
|
140
|
+
scale.innerHTML = text;
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "getRoundNum",
|
|
144
|
+
value: function getRoundNum(num) {
|
|
145
|
+
var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
|
|
146
|
+
var d = num / pow10;
|
|
147
|
+
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
148
|
+
return pow10 * d;
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
key: "addScales",
|
|
152
|
+
value: function addScales(className, container) {
|
|
153
|
+
var _this$controlOption2 = this.controlOption,
|
|
154
|
+
metric = _this$controlOption2.metric,
|
|
155
|
+
imperial = _this$controlOption2.imperial;
|
|
156
|
+
|
|
157
|
+
if (metric) {
|
|
158
|
+
this.mScale = _l7Utils.DOM.create('div', className, container);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (imperial) {
|
|
162
|
+
this.iScale = _l7Utils.DOM.create('div', className, container);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}]);
|
|
166
|
+
return Scale;
|
|
167
|
+
}(_BaseControl.default);
|
|
168
|
+
|
|
169
|
+
exports.default = Scale;
|