@antv/l7-component 2.9.32-alpha.1 → 2.9.32-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.
- package/package.json +8 -5
- package/es/control/BaseControl.d.ts +0 -27
- package/es/control/BaseControl.js +0 -134
- package/es/control/layer.d.ts +0 -38
- package/es/control/layer.js +0 -340
- package/es/control/logo.d.ts +0 -9
- package/es/control/logo.js +0 -57
- package/es/control/scale.d.ts +0 -24
- package/es/control/scale.js +0 -148
- package/es/control/zoom.d.ts +0 -24
- package/es/control/zoom.js +0 -119
- package/es/css/l7.css +0 -502
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +0 -1
- package/es/images/logo.png +0 -0
- package/es/index.d.ts +0 -11
- package/es/index.js +0 -53
- package/es/interface.d.ts +0 -37
- package/es/interface.js +0 -1
- package/es/marker-layer.d.ts +0 -53
- package/es/marker-layer.js +0 -363
- package/es/marker.d.ts +0 -49
- package/es/marker.js +0 -434
- package/es/popup.d.ts +0 -35
- package/es/popup.js +0 -300
- package/es/utils/anchor.d.ts +0 -22
- package/es/utils/anchor.js +0 -35
- package/lib/control/BaseControl.js +0 -110
- package/lib/control/layer.js +0 -269
- package/lib/control/logo.js +0 -54
- package/lib/control/scale.js +0 -119
- package/lib/control/zoom.js +0 -101
- package/lib/css/l7.css +0 -502
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +0 -1
- package/lib/images/logo.png +0 -0
- package/lib/index.js +0 -56
- package/lib/interface.js +0 -17
- package/lib/marker-layer.js +0 -263
- package/lib/marker.js +0 -307
- package/lib/popup.js +0 -216
- package/lib/utils/anchor.js +0 -63
package/lib/control/layer.js
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
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/layer.ts
|
|
23
|
-
var layer_exports = {};
|
|
24
|
-
__export(layer_exports, {
|
|
25
|
-
default: () => Layers
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(layer_exports);
|
|
28
|
-
var import_l7_core = require("@antv/l7-core");
|
|
29
|
-
var import_l7_utils = require("@antv/l7-utils");
|
|
30
|
-
var import_BaseControl = __toESM(require("./BaseControl"));
|
|
31
|
-
var Layers = class extends import_BaseControl.default {
|
|
32
|
-
constructor(cfg) {
|
|
33
|
-
super(cfg);
|
|
34
|
-
this.layerControlInputs = [];
|
|
35
|
-
this.layers = [];
|
|
36
|
-
this.lastZIndex = 0;
|
|
37
|
-
this.handlingClick = false;
|
|
38
|
-
this.initLayers();
|
|
39
|
-
(0, import_l7_utils.bindAll)([
|
|
40
|
-
"checkDisabledLayers",
|
|
41
|
-
"onLayerChange",
|
|
42
|
-
"collapse",
|
|
43
|
-
"extend",
|
|
44
|
-
"expand",
|
|
45
|
-
"onInputClick"
|
|
46
|
-
], this);
|
|
47
|
-
}
|
|
48
|
-
getDefault() {
|
|
49
|
-
return {
|
|
50
|
-
collapsed: true,
|
|
51
|
-
position: import_l7_core.PositionType.TOPRIGHT,
|
|
52
|
-
autoZIndex: true,
|
|
53
|
-
hideSingleBase: false,
|
|
54
|
-
sortLayers: false,
|
|
55
|
-
name: "layers"
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
onAdd() {
|
|
59
|
-
this.initLayout();
|
|
60
|
-
this.update();
|
|
61
|
-
this.mapsService.on("zoomend", this.checkDisabledLayers);
|
|
62
|
-
this.layers.forEach((layerItem) => {
|
|
63
|
-
layerItem.layer.on("remove", this.onLayerChange);
|
|
64
|
-
layerItem.layer.on("add", this.onLayerChange);
|
|
65
|
-
});
|
|
66
|
-
return this.container;
|
|
67
|
-
}
|
|
68
|
-
addVisualLayer(layer, name) {
|
|
69
|
-
this.addLayer(layer, name, true);
|
|
70
|
-
return this.mapsService ? this.update() : this;
|
|
71
|
-
}
|
|
72
|
-
expand() {
|
|
73
|
-
const { height } = this.renderService.getViewportSize();
|
|
74
|
-
import_l7_utils.DOM.addClass(this.container, "l7-control-layers-expanded");
|
|
75
|
-
this.form.style.height = "null";
|
|
76
|
-
const acceptableHeight = height - (this.container.offsetTop + 50);
|
|
77
|
-
if (acceptableHeight < this.form.clientHeight) {
|
|
78
|
-
import_l7_utils.DOM.addClass(this.form, "l7-control-layers-scrollbar");
|
|
79
|
-
this.form.style.height = acceptableHeight + "px";
|
|
80
|
-
} else {
|
|
81
|
-
import_l7_utils.DOM.removeClass(this.form, "l7-control-layers-scrollbar");
|
|
82
|
-
}
|
|
83
|
-
this.checkDisabledLayers();
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
collapse() {
|
|
87
|
-
import_l7_utils.DOM.removeClass(this.container, "l7-control-layers-expanded");
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
|
-
onRemove() {
|
|
91
|
-
if (!this.mapsService) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
this.mapsService.off("click", this.collapse);
|
|
95
|
-
this.layers.forEach((layerItem) => {
|
|
96
|
-
layerItem.layer.off("remove", this.onLayerChange);
|
|
97
|
-
layerItem.layer.off("add", this.onLayerChange);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
initLayout() {
|
|
101
|
-
const className = "l7-control-layers";
|
|
102
|
-
const container = this.container = import_l7_utils.DOM.create("div", className);
|
|
103
|
-
const { collapsed } = this.controlOption;
|
|
104
|
-
container.setAttribute("aria-haspopup", "true");
|
|
105
|
-
const form = this.form = import_l7_utils.DOM.create("form", className + "-list");
|
|
106
|
-
if (collapsed) {
|
|
107
|
-
this.mapsService.on("click", this.collapse);
|
|
108
|
-
container.addEventListener("mouseenter", this.expand);
|
|
109
|
-
container.addEventListener("mouseleave", this.collapse);
|
|
110
|
-
}
|
|
111
|
-
this.layersLink = import_l7_utils.DOM.create("a", className + "-toggle", container);
|
|
112
|
-
const link = this.layersLink;
|
|
113
|
-
link.title = "Layers";
|
|
114
|
-
if (!collapsed) {
|
|
115
|
-
this.expand();
|
|
116
|
-
}
|
|
117
|
-
this.baseLayersList = import_l7_utils.DOM.create("div", className + "-base", form);
|
|
118
|
-
this.separator = import_l7_utils.DOM.create("div", className + "-separator", form);
|
|
119
|
-
this.overlaysList = import_l7_utils.DOM.create("div", className + "-overlays", form);
|
|
120
|
-
container.appendChild(form);
|
|
121
|
-
}
|
|
122
|
-
initLayers() {
|
|
123
|
-
const { baseLayers = {}, overlayers = {} } = this.controlOption;
|
|
124
|
-
Object.keys(baseLayers).forEach((name) => {
|
|
125
|
-
this.addLayer(baseLayers[name], name, false);
|
|
126
|
-
});
|
|
127
|
-
Object.keys(overlayers).forEach((name) => {
|
|
128
|
-
this.addLayer(overlayers[name], name, true);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
update() {
|
|
132
|
-
if (!this.container) {
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
import_l7_utils.DOM.empty(this.baseLayersList);
|
|
136
|
-
import_l7_utils.DOM.empty(this.overlaysList);
|
|
137
|
-
this.layerControlInputs = [];
|
|
138
|
-
let baseLayersPresent;
|
|
139
|
-
let overlaysPresent;
|
|
140
|
-
let i;
|
|
141
|
-
let obj;
|
|
142
|
-
let baseLayersCount = 0;
|
|
143
|
-
for (i = 0; i < this.layers.length; i++) {
|
|
144
|
-
obj = this.layers[i];
|
|
145
|
-
this.addItem(obj);
|
|
146
|
-
overlaysPresent = overlaysPresent || obj.overlay;
|
|
147
|
-
baseLayersPresent = baseLayersPresent || !obj.overlay;
|
|
148
|
-
baseLayersCount += !obj.overlay ? 1 : 0;
|
|
149
|
-
}
|
|
150
|
-
if (this.controlOption.hideSingleBase) {
|
|
151
|
-
baseLayersPresent = baseLayersPresent && baseLayersCount > 1;
|
|
152
|
-
this.baseLayersList.style.display = baseLayersPresent ? "" : "none";
|
|
153
|
-
}
|
|
154
|
-
this.separator.style.display = overlaysPresent && baseLayersPresent ? "" : "none";
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
|
-
checkDisabledLayers() {
|
|
158
|
-
const inputs = this.layerControlInputs;
|
|
159
|
-
let input;
|
|
160
|
-
let layer;
|
|
161
|
-
const zoom = this.mapsService.getZoom();
|
|
162
|
-
for (let i = inputs.length - 1; i >= 0; i--) {
|
|
163
|
-
input = inputs[i];
|
|
164
|
-
layer = this.layerService.getLayer(input.layerId);
|
|
165
|
-
if (layer && layer.inited) {
|
|
166
|
-
const minZoom = layer.getMinZoom();
|
|
167
|
-
const maxZoom = layer.getMaxZoom();
|
|
168
|
-
input.disabled = zoom < minZoom || zoom > maxZoom;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
addLayer(layer, name, overlay) {
|
|
173
|
-
if (this.mapsService) {
|
|
174
|
-
layer.on("add", this.onLayerChange);
|
|
175
|
-
layer.on("remove", this.onLayerChange);
|
|
176
|
-
}
|
|
177
|
-
this.layers.push({
|
|
178
|
-
layer,
|
|
179
|
-
name,
|
|
180
|
-
overlay
|
|
181
|
-
});
|
|
182
|
-
const { sortLayers, sortFunction, autoZIndex } = this.controlOption;
|
|
183
|
-
if (sortLayers) {
|
|
184
|
-
this.layers.sort((a, b) => {
|
|
185
|
-
return sortFunction(a.layer, b.layer, a.name, b.name);
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
if (autoZIndex && layer.setZIndex) {
|
|
189
|
-
this.lastZIndex++;
|
|
190
|
-
layer.setZIndex(this.lastZIndex);
|
|
191
|
-
}
|
|
192
|
-
this.expandIfNotCollapsed();
|
|
193
|
-
}
|
|
194
|
-
expandIfNotCollapsed() {
|
|
195
|
-
if (this.mapsService && !this.controlOption.collapsed) {
|
|
196
|
-
this.expand();
|
|
197
|
-
}
|
|
198
|
-
return this;
|
|
199
|
-
}
|
|
200
|
-
onLayerChange(e) {
|
|
201
|
-
if (!this.handlingClick) {
|
|
202
|
-
this.update();
|
|
203
|
-
}
|
|
204
|
-
const obj = this.layerService.getLayer(e.target.layerId);
|
|
205
|
-
const type = (obj == null ? void 0 : obj.overlay) ? e.type === "add" ? "overlayadd" : "overlayremove" : e.type === "add" ? "baselayerchange" : null;
|
|
206
|
-
if (type) {
|
|
207
|
-
this.emit(type, obj);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
createRadioElement(name, checked) {
|
|
211
|
-
const radioHtml = '<input type="radio" class="l7-control-layers-selector" name="' + name + '"' + (checked ? ' checked="checked"' : "") + "/>";
|
|
212
|
-
const radioFragment = document.createElement("div");
|
|
213
|
-
radioFragment.innerHTML = radioHtml;
|
|
214
|
-
return radioFragment.firstChild;
|
|
215
|
-
}
|
|
216
|
-
addItem(obj) {
|
|
217
|
-
const label = document.createElement("label");
|
|
218
|
-
const layer = this.layerService.getLayer(obj.layer.id);
|
|
219
|
-
const checked = layer && layer.inited && obj.layer.isVisible();
|
|
220
|
-
let input;
|
|
221
|
-
if (obj.overlay) {
|
|
222
|
-
input = document.createElement("input");
|
|
223
|
-
input.type = "checkbox";
|
|
224
|
-
input.className = "l7-control-layers-selector";
|
|
225
|
-
input.defaultChecked = checked;
|
|
226
|
-
} else {
|
|
227
|
-
input = this.createRadioElement("l7-base-layers", checked);
|
|
228
|
-
}
|
|
229
|
-
this.layerControlInputs.push(input);
|
|
230
|
-
input.layerId = obj.layer.id;
|
|
231
|
-
input.addEventListener("click", this.onInputClick);
|
|
232
|
-
const name = document.createElement("span");
|
|
233
|
-
name.innerHTML = " " + obj.name;
|
|
234
|
-
const holder = document.createElement("div");
|
|
235
|
-
label.appendChild(holder);
|
|
236
|
-
holder.appendChild(input);
|
|
237
|
-
holder.appendChild(name);
|
|
238
|
-
const container = obj.overlay ? this.overlaysList : this.baseLayersList;
|
|
239
|
-
container.appendChild(label);
|
|
240
|
-
this.checkDisabledLayers();
|
|
241
|
-
return label;
|
|
242
|
-
}
|
|
243
|
-
onInputClick() {
|
|
244
|
-
const inputs = this.layerControlInputs;
|
|
245
|
-
let input;
|
|
246
|
-
let layer;
|
|
247
|
-
const addedLayers = [];
|
|
248
|
-
const removedLayers = [];
|
|
249
|
-
this.handlingClick = true;
|
|
250
|
-
for (let i = inputs.length - 1; i >= 0; i--) {
|
|
251
|
-
input = inputs[i];
|
|
252
|
-
layer = this.layerService.getLayer(input.layerId);
|
|
253
|
-
if (input.checked) {
|
|
254
|
-
addedLayers.push(layer);
|
|
255
|
-
} else if (!input.checked) {
|
|
256
|
-
removedLayers.push(layer);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
removedLayers.forEach((l) => {
|
|
260
|
-
l.hide();
|
|
261
|
-
});
|
|
262
|
-
addedLayers.forEach((l) => {
|
|
263
|
-
l.show();
|
|
264
|
-
});
|
|
265
|
-
this.handlingClick = false;
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
269
|
-
0 && (module.exports = {});
|
package/lib/control/logo.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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
|
|
26
|
-
});
|
|
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
|
-
};
|
|
36
|
-
}
|
|
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
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
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
|
|
26
|
-
});
|
|
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);
|
|
34
|
-
}
|
|
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);
|
|
73
|
-
}
|
|
74
|
-
if (imperial && maxMeters) {
|
|
75
|
-
this.updateImperial(maxMeters);
|
|
76
|
-
}
|
|
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);
|
|
95
|
-
}
|
|
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);
|
|
112
|
-
}
|
|
113
|
-
if (imperial) {
|
|
114
|
-
this.iScale = import_l7_utils.DOM.create("div", className, container);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
-
0 && (module.exports = {});
|
package/lib/control/zoom.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
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/zoom.ts
|
|
23
|
-
var zoom_exports = {};
|
|
24
|
-
__export(zoom_exports, {
|
|
25
|
-
default: () => Zoom
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(zoom_exports);
|
|
28
|
-
var import_l7_utils = require("@antv/l7-utils");
|
|
29
|
-
var import_BaseControl = __toESM(require("./BaseControl"));
|
|
30
|
-
var Zoom = class extends import_BaseControl.default {
|
|
31
|
-
constructor(cfg) {
|
|
32
|
-
super(cfg);
|
|
33
|
-
(0, import_l7_utils.bindAll)(["updateDisabled", "zoomIn", "zoomOut"], this);
|
|
34
|
-
}
|
|
35
|
-
getDefault() {
|
|
36
|
-
return {
|
|
37
|
-
position: import_BaseControl.PositionType.TOPLEFT,
|
|
38
|
-
zoomInText: "+",
|
|
39
|
-
zoomInTitle: "Zoom in",
|
|
40
|
-
zoomOutText: "−",
|
|
41
|
-
zoomOutTitle: "Zoom out",
|
|
42
|
-
name: "zoom"
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
onAdd() {
|
|
46
|
-
const zoomName = "l7-control-zoom";
|
|
47
|
-
const container = import_l7_utils.DOM.create("div", zoomName + " l7-bar");
|
|
48
|
-
this.zoomInButton = this.createButton(this.controlOption.zoomInText, this.controlOption.zoomInTitle, zoomName + "-in", container, this.zoomIn);
|
|
49
|
-
this.zoomOutButton = this.createButton(this.controlOption.zoomOutText, this.controlOption.zoomOutTitle, zoomName + "-out", container, this.zoomOut);
|
|
50
|
-
this.mapsService.on("zoomend", this.updateDisabled);
|
|
51
|
-
this.mapsService.on("zoomchange", this.updateDisabled);
|
|
52
|
-
this.updateDisabled();
|
|
53
|
-
return container;
|
|
54
|
-
}
|
|
55
|
-
onRemove() {
|
|
56
|
-
this.mapsService.off("zoomend", this.updateDisabled);
|
|
57
|
-
this.mapsService.off("zoomchange", this.updateDisabled);
|
|
58
|
-
}
|
|
59
|
-
disable() {
|
|
60
|
-
this.disabled = true;
|
|
61
|
-
this.updateDisabled();
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
enable() {
|
|
65
|
-
this.disabled = false;
|
|
66
|
-
this.updateDisabled();
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
zoomIn() {
|
|
70
|
-
if (!this.disabled && this.mapsService.getZoom() < this.mapsService.getMaxZoom()) {
|
|
71
|
-
this.mapsService.zoomIn();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
zoomOut() {
|
|
75
|
-
if (!this.disabled && this.mapsService.getZoom() > this.mapsService.getMinZoom()) {
|
|
76
|
-
this.mapsService.zoomOut();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
createButton(html, tile, className, container, fn) {
|
|
80
|
-
const link = import_l7_utils.DOM.create("a", className, container);
|
|
81
|
-
link.innerHTML = html;
|
|
82
|
-
link.title = tile;
|
|
83
|
-
link.href = "javascript:void(0)";
|
|
84
|
-
link.addEventListener("click", fn);
|
|
85
|
-
return link;
|
|
86
|
-
}
|
|
87
|
-
updateDisabled() {
|
|
88
|
-
const mapsService = this.mapsService;
|
|
89
|
-
const className = "l7-disabled";
|
|
90
|
-
import_l7_utils.DOM.removeClass(this.zoomInButton, className);
|
|
91
|
-
import_l7_utils.DOM.removeClass(this.zoomOutButton, className);
|
|
92
|
-
if (this.disabled || mapsService.getZoom() <= mapsService.getMinZoom()) {
|
|
93
|
-
import_l7_utils.DOM.addClass(this.zoomOutButton, className);
|
|
94
|
-
}
|
|
95
|
-
if (this.disabled || mapsService.getZoom() >= mapsService.getMaxZoom()) {
|
|
96
|
-
import_l7_utils.DOM.addClass(this.zoomInButton, className);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
101
|
-
0 && (module.exports = {});
|