@antv/l7-component 2.9.21 → 2.9.22-alpha.0
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.js +5 -26
- package/es/control/layer.js +13 -28
- package/es/control/logo.js +3 -4
- package/es/control/scale.js +6 -11
- package/es/control/zoom.js +3 -12
- 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.js +10 -10
- package/es/interface.js +1 -2
- package/es/marker-layer.js +27 -27
- package/es/marker.js +21 -27
- package/es/popup.js +16 -34
- package/es/utils/anchor.js +1 -2
- package/lib/control/BaseControl.js +100 -163
- package/lib/control/layer.js +248 -347
- package/lib/control/logo.js +52 -77
- package/lib/control/scale.js +112 -165
- package/lib/control/zoom.js +95 -143
- 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 +53 -135
- package/lib/interface.js +17 -2
- package/lib/marker-layer.js +224 -330
- package/lib/marker.js +271 -404
- package/lib/popup.js +201 -309
- package/lib/utils/anchor.js +54 -37
- package/package.json +9 -9
- package/es/control/BaseControl.js.map +0 -1
- package/es/control/layer.js.map +0 -1
- package/es/control/logo.js.map +0 -1
- package/es/control/scale.js.map +0 -1
- package/es/control/zoom.js.map +0 -1
- package/es/index.js.map +0 -1
- package/es/interface.js.map +0 -1
- package/es/marker-layer.js.map +0 -1
- package/es/marker.js.map +0 -1
- package/es/popup.js.map +0 -1
- package/es/utils/anchor.js.map +0 -1
- package/lib/control/BaseControl.js.map +0 -1
- package/lib/control/layer.js.map +0 -1
- package/lib/control/logo.js.map +0 -1
- package/lib/control/scale.js.map +0 -1
- package/lib/control/zoom.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interface.js.map +0 -1
- package/lib/marker-layer.js.map +0 -1
- package/lib/marker.js.map +0 -1
- package/lib/popup.js.map +0 -1
- package/lib/utils/anchor.js.map +0 -1
package/lib/control/logo.js
CHANGED
|
@@ -1,79 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
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
|
|
9
26
|
});
|
|
10
|
-
exports
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 = 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);
|
|
27
|
+
module.exports = __toCommonJS(logo_exports);
|
|
28
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
29
|
+
var import_BaseControl = __toESM(require("./BaseControl"));
|
|
30
|
+
var Logo = class extends import_BaseControl.default {
|
|
31
|
+
getDefault() {
|
|
32
|
+
return {
|
|
33
|
+
position: import_BaseControl.PositionType.BOTTOMLEFT,
|
|
34
|
+
name: "logo"
|
|
35
|
+
};
|
|
42
36
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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;
|
|
79
|
-
//# sourceMappingURL=logo.js.map
|
|
37
|
+
onAdd() {
|
|
38
|
+
const className = "l7-control-logo";
|
|
39
|
+
const container = import_l7_utils.DOM.create("div", className);
|
|
40
|
+
const anchor = import_l7_utils.DOM.create("a", "l7-ctrl-logo");
|
|
41
|
+
anchor.target = "_blank";
|
|
42
|
+
anchor.rel = "noopener nofollow";
|
|
43
|
+
anchor.href = "https://antv.alipay.com/l7";
|
|
44
|
+
anchor.setAttribute("aria-label", "AntV logo");
|
|
45
|
+
anchor.setAttribute("rel", "noopener nofollow");
|
|
46
|
+
container.appendChild(anchor);
|
|
47
|
+
return container;
|
|
48
|
+
}
|
|
49
|
+
onRemove() {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {});
|
package/lib/control/scale.js
CHANGED
|
@@ -1,172 +1,119 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
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
|
|
9
26
|
});
|
|
10
|
-
exports
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
27
|
-
|
|
28
|
-
var _BaseControl = _interopRequireWildcard(require("./BaseControl"));
|
|
29
|
-
|
|
30
|
-
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); }
|
|
31
|
-
|
|
32
|
-
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; }
|
|
33
|
-
|
|
34
|
-
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); }; }
|
|
35
|
-
|
|
36
|
-
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; } }
|
|
37
|
-
|
|
38
|
-
var Scale = function (_Control) {
|
|
39
|
-
(0, _inherits2.default)(Scale, _Control);
|
|
40
|
-
|
|
41
|
-
var _super = _createSuper(Scale);
|
|
42
|
-
|
|
43
|
-
function Scale(cfg) {
|
|
44
|
-
var _this;
|
|
45
|
-
|
|
46
|
-
(0, _classCallCheck2.default)(this, Scale);
|
|
47
|
-
_this = _super.call(this, cfg);
|
|
48
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mScale", void 0);
|
|
49
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "iScale", void 0);
|
|
50
|
-
(0, _l7Utils.bindAll)(['update'], (0, _assertThisInitialized2.default)(_this));
|
|
51
|
-
return _this;
|
|
27
|
+
module.exports = __toCommonJS(scale_exports);
|
|
28
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
29
|
+
var import_BaseControl = __toESM(require("./BaseControl"));
|
|
30
|
+
var Scale = class extends import_BaseControl.default {
|
|
31
|
+
constructor(cfg) {
|
|
32
|
+
super(cfg);
|
|
33
|
+
(0, import_l7_utils.bindAll)(["update"], this);
|
|
52
34
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var maxWidth = this.controlOption.maxWidth;
|
|
92
|
-
var y = mapsService.getSize()[1] / 2;
|
|
93
|
-
var p1 = mapsService.containerToLngLat([0, y]);
|
|
94
|
-
var p2 = mapsService.containerToLngLat([maxWidth, y]);
|
|
95
|
-
var maxMeters = (0, _l7Utils.lnglatDistance)([p1.lng, p1.lat], [p2.lng, p2.lat]);
|
|
96
|
-
this.updateScales(maxMeters);
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "updateScales",
|
|
100
|
-
value: function updateScales(maxMeters) {
|
|
101
|
-
var _this$controlOption = this.controlOption,
|
|
102
|
-
metric = _this$controlOption.metric,
|
|
103
|
-
imperial = _this$controlOption.imperial;
|
|
104
|
-
|
|
105
|
-
if (metric && maxMeters) {
|
|
106
|
-
this.updateMetric(maxMeters);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (imperial && maxMeters) {
|
|
110
|
-
this.updateImperial(maxMeters);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "updateMetric",
|
|
115
|
-
value: function updateMetric(maxMeters) {
|
|
116
|
-
var meters = this.getRoundNum(maxMeters);
|
|
117
|
-
var label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
|
|
118
|
-
this.updateScale(this.mScale, label, meters / maxMeters);
|
|
35
|
+
getDefault() {
|
|
36
|
+
return {
|
|
37
|
+
position: import_BaseControl.PositionType.BOTTOMLEFT,
|
|
38
|
+
maxWidth: 100,
|
|
39
|
+
metric: true,
|
|
40
|
+
updateWhenIdle: false,
|
|
41
|
+
imperial: false,
|
|
42
|
+
name: "scale"
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
onAdd() {
|
|
46
|
+
const className = "l7-control-scale";
|
|
47
|
+
const container = import_l7_utils.DOM.create("div", className);
|
|
48
|
+
this.addScales(className + "-line", container);
|
|
49
|
+
const { updateWhenIdle } = this.controlOption;
|
|
50
|
+
this.mapsService.on(updateWhenIdle ? "moveend" : "mapmove", this.update);
|
|
51
|
+
this.mapsService.on(updateWhenIdle ? "zoomend" : "zoomchange", this.update);
|
|
52
|
+
this.update();
|
|
53
|
+
return container;
|
|
54
|
+
}
|
|
55
|
+
onRemove() {
|
|
56
|
+
const { updateWhenIdle } = this.controlOption;
|
|
57
|
+
this.mapsService.off(updateWhenIdle ? "zoomend" : "zoomchange", this.update);
|
|
58
|
+
this.mapsService.off(updateWhenIdle ? "moveend" : "mapmove", this.update);
|
|
59
|
+
}
|
|
60
|
+
update() {
|
|
61
|
+
const mapsService = this.mapsService;
|
|
62
|
+
const { maxWidth } = this.controlOption;
|
|
63
|
+
const y = mapsService.getSize()[1] / 2;
|
|
64
|
+
const p1 = mapsService.containerToLngLat([0, y]);
|
|
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);
|
|
68
|
+
}
|
|
69
|
+
updateScales(maxMeters) {
|
|
70
|
+
const { metric, imperial } = this.controlOption;
|
|
71
|
+
if (metric && maxMeters) {
|
|
72
|
+
this.updateMetric(maxMeters);
|
|
119
73
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
value: function updateImperial(maxMeters) {
|
|
123
|
-
var maxFeet = maxMeters * 3.2808399;
|
|
124
|
-
var maxMiles;
|
|
125
|
-
var miles;
|
|
126
|
-
var feet;
|
|
127
|
-
|
|
128
|
-
if (maxFeet > 5280) {
|
|
129
|
-
maxMiles = maxFeet / 5280;
|
|
130
|
-
miles = this.getRoundNum(maxMiles);
|
|
131
|
-
this.updateScale(this.iScale, miles + ' mi', miles / maxMiles);
|
|
132
|
-
} else {
|
|
133
|
-
feet = this.getRoundNum(maxFeet);
|
|
134
|
-
this.updateScale(this.iScale, feet + ' ft', feet / maxFeet);
|
|
135
|
-
}
|
|
74
|
+
if (imperial && maxMeters) {
|
|
75
|
+
this.updateImperial(maxMeters);
|
|
136
76
|
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
77
|
+
}
|
|
78
|
+
updateMetric(maxMeters) {
|
|
79
|
+
const meters = this.getRoundNum(maxMeters);
|
|
80
|
+
const label = meters < 1e3 ? meters + " m" : meters / 1e3 + " km";
|
|
81
|
+
this.updateScale(this.mScale, label, meters / maxMeters);
|
|
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);
|
|
143
95
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
96
|
+
}
|
|
97
|
+
updateScale(scale, text, ratio) {
|
|
98
|
+
const { maxWidth } = this.controlOption;
|
|
99
|
+
scale.style.width = Math.round(maxWidth * ratio) + "px";
|
|
100
|
+
scale.innerHTML = text;
|
|
101
|
+
}
|
|
102
|
+
getRoundNum(num) {
|
|
103
|
+
const pow10 = Math.pow(10, (Math.floor(num) + "").length - 1);
|
|
104
|
+
let d = num / pow10;
|
|
105
|
+
d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
|
|
106
|
+
return pow10 * d;
|
|
107
|
+
}
|
|
108
|
+
addScales(className, container) {
|
|
109
|
+
const { metric, imperial } = this.controlOption;
|
|
110
|
+
if (metric) {
|
|
111
|
+
this.mScale = import_l7_utils.DOM.create("div", className, container);
|
|
151
112
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
value: function addScales(className, container) {
|
|
155
|
-
var _this$controlOption2 = this.controlOption,
|
|
156
|
-
metric = _this$controlOption2.metric,
|
|
157
|
-
imperial = _this$controlOption2.imperial;
|
|
158
|
-
|
|
159
|
-
if (metric) {
|
|
160
|
-
this.mScale = _l7Utils.DOM.create('div', className, container);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (imperial) {
|
|
164
|
-
this.iScale = _l7Utils.DOM.create('div', className, container);
|
|
165
|
-
}
|
|
113
|
+
if (imperial) {
|
|
114
|
+
this.iScale = import_l7_utils.DOM.create("div", className, container);
|
|
166
115
|
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
exports.default = Scale;
|
|
172
|
-
//# sourceMappingURL=scale.js.map
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {});
|