UNPKG

@tianditu/wc

Version:

Web components for tianditu, powered by Demo Macro.

214 lines (213 loc) 7.06 kB
/*! * MIT © Demo Macro */ import { Host, h } from "@stencil/core"; export class TdtMap { constructor() { 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' }))); } static get is() { return "tdt-map"; } static get encapsulation() { return "shadow"; } static get properties() { return { "tk": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": true, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "tk", "reflect": true }, "projection": { "type": "string", "mutable": false, "complexType": { "original": "T.MapOptions[\"projection\"]", "resolved": "string | undefined", "references": { "T": { "location": "global", "id": "global::T" } } }, "required": true, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "projection", "reflect": true }, "minZoom": { "type": "number", "mutable": false, "complexType": { "original": "T.MapOptions[\"minZoom\"]", "resolved": "number | undefined", "references": { "T": { "location": "global", "id": "global::T" } } }, "required": true, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "min-zoom", "reflect": true }, "maxZoom": { "type": "number", "mutable": false, "complexType": { "original": "T.MapOptions[\"maxZoom\"]", "resolved": "number | undefined", "references": { "T": { "location": "global", "id": "global::T" } } }, "required": true, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "max-zoom", "reflect": true }, "maxBounds": { "type": "unknown", "mutable": false, "complexType": { "original": "T.MapOptions[\"maxBounds\"]", "resolved": "LngLatBounds | undefined", "references": { "T": { "location": "global", "id": "global::T" } } }, "required": true, "optional": false, "docs": { "tags": [], "text": "" } }, "center": { "type": "unknown", "mutable": false, "complexType": { "original": "number[]", "resolved": "number[]", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "defaultValue": "[0, 0]" }, "zoom": { "type": "number", "mutable": false, "complexType": { "original": "T.MapOptions[\"zoom\"]", "resolved": "number | undefined", "references": { "T": { "location": "global", "id": "global::T" } } }, "required": true, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "zoom", "reflect": true }, "uniqueId": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "unique-id", "reflect": true, "defaultValue": "Math.random().toString(36).slice(2)" } }; } static get states() { return { "map": {} }; } static get elementRef() { return "el"; } } //# sourceMappingURL=tdt-map.js.map