@tianditu/wc
Version:
Web components for tianditu, powered by Demo Macro.
48 lines (45 loc) • 1.71 kB
JavaScript
/*!
* MIT © Demo Macro
*/
import { r as registerInstance, h, H as Host, g as getElement } from './index-0cd9c6b6.js';
const TdtMap = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.tk = undefined;
this.projection = undefined;
this.minZoom = undefined;
this.maxZoom = undefined;
this.maxBounds = undefined;
this.center = [0, 0];
this.zoom = undefined;
this.uniqueId = Math.random().toString(36).slice(2);
this.map = undefined;
}
connectedCallback() {
this.el.style.display = "block";
this.el.style.height = "100%";
this.el.style.width = "100%";
globalThis.onload = () => {
this.map = new T.Map(this.el, {
projection: this.projection,
minZoom: this.minZoom,
maxZoom: this.maxZoom,
maxBounds: this.maxBounds,
center: new T.LngLat(this.center[0], this.center[1]),
zoom: this.zoom,
});
this.map.centerAndZoom(new T.LngLat(this.center[0], this.center[1]), this.zoom || 18);
globalThis[this.uniqueId] = this.map;
const childElements = this.el.querySelectorAll("*");
for (let i = 0; i < childElements.length; i++) {
childElements[i].setAttribute("unique-id", this.uniqueId);
}
};
}
render() {
return (h(Host, { key: '7bda253b550567a77b4ab9f9abd5ebb8a2a0eaa9' }, h("slot", { key: '9128ed9a8daaaa176958b8b702d945ed44598d32' })));
}
get el() { return getElement(this); }
};
export { TdtMap as tdt_map };
//# sourceMappingURL=tdt-map.entry.js.map