UNPKG

@tianditu/wc

Version:

Web components for tianditu, powered by Demo Macro.

76 lines (72 loc) 2.53 kB
/*! * MIT © Demo Macro */ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client'; const TdtMap$1 = /*@__PURE__*/ proxyCustomElement(class TdtMap extends HTMLElement { constructor() { super(); this.__registerHost(); this.__attachShadow(); 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 this; } }, [1, "tdt-map", { "tk": [513], "projection": [513], "minZoom": [514, "min-zoom"], "maxZoom": [514, "max-zoom"], "maxBounds": [16], "center": [16], "zoom": [514], "uniqueId": [513, "unique-id"], "map": [32] }]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["tdt-map"]; components.forEach(tagName => { switch (tagName) { case "tdt-map": if (!customElements.get(tagName)) { customElements.define(tagName, TdtMap$1); } break; } }); } const TdtMap = TdtMap$1; const defineCustomElement = defineCustomElement$1; export { TdtMap, defineCustomElement }; //# sourceMappingURL=tdt-map.js.map