vue-tianditu2
Version:
61 lines (60 loc) • 1.6 kB
JavaScript
import { toBounds as w } from "../../utils/converter.mjs";
function v(f, t, c) {
var i;
(i = f.controls) == null || i.forEach((o) => {
typeof o == "string" ? l(o) : typeof o == "object" && d(o);
});
function l(o) {
const n = o;
if (!T.Control[n]) {
setTimeout(() => l(o));
return;
}
const r = new T.Control[n]();
n === "OverviewMap" && r.addEventListener("viewchange", (e) => c("viewchange", e)), t.addControl(r);
}
function d(o) {
var r, a;
const n = o.name;
if (!T.Control[n]) {
setTimeout(() => d(o));
return;
}
switch (n) {
case "MapType":
{
const e = (r = o.mapTypes) == null ? void 0 : r.map((C) => ({
...C,
layer: window[C.layer]
})), s = new T.Control.MapType(e);
o.position && s.setPosition(o.position), t.addControl(s);
}
break;
case "OverviewMap":
{
const e = new T.Control.OverviewMap(o);
e.addEventListener("viewchange", (s) => c("viewchange", s)), t.addControl(e);
}
break;
case "Copyright":
{
const e = new T.Control.Copyright({ position: o.position || "bottomleft" });
t.addControl(e), e.addCopyright({
...o,
bounds: (a = o.bounds) != null && a.length ? w(o.bounds) : void 0
});
}
break;
default:
{
const e = new T.Control[n](o);
t.addControl(e);
}
break;
}
}
}
export {
v as useControls
};
//# sourceMappingURL=controls.mjs.map