UNPKG

@tuoyuan/map-adapter-grid-tile-map

Version:

自定义栅格地图适配器

71 lines (70 loc) 2.21 kB
var u = Object.defineProperty; var S = (i, a, e) => a in i ? u(i, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[a] = e; var n = (i, a, e) => S(i, typeof a != "symbol" ? a + "" : a, e); import { AMap as M } from "../node_modules/@tuoyuan/map-adapter-amap/dist/es/Map.js"; class w extends M { constructor() { super(); n(this, "coordinateSystem", "WGS84"); n(this, "tmap_token", ""); } async load(e) { return await super.load({ key: e.key, secret: e.secret }), this.tmap_token = e.tmap_token, Promise.resolve(); } init(e, s) { const t = s; this._dom = e.dom; const o = document.createElement("style"); o.innerHTML = ".amap-logo{display:none!important;}.amap-copyright{display:none!important;}", document.body.appendChild(o); const r = [], l = new this.AMap.TileLayer({ dataZooms: [t == null ? void 0 : t.tileDataMinZooms, t == null ? void 0 : t.tileDataMaxZooms], tileSize: (t == null ? void 0 : t.tileSize) ?? 256, getTileUrl: (p, y, h) => t == null ? void 0 : t.tileUrl.replace("{x}", p.toString()).replace("{y}", y.toString()).replace("{z}", h.toString()), zIndex: 3 }); r.push(l); const c = new this.AMap.TileLayer.WMTS({ url: "https://t4.tianditu.gov.cn/img_w/wmts", blend: !1, tileSize: 256, params: { Layer: "img", Version: "1.0.0", Format: "tiles", TileMatrixSet: "w", STYLE: "default", tk: this.tmap_token }, zIndex: 2 }); t != null && t.satellite && r.push(c); const d = new this.AMap.TileLayer.WMTS({ url: "https://t4.tianditu.gov.cn/cia_w/wmts", blend: !1, tileSize: 256, params: { Layer: "cia", Version: "1.0.0", Format: "tiles", TileMatrixSet: "w", STYLE: "default", tk: this.tmap_token }, zIndex: 4 }); t != null && t.satelliteAnnotion && r.push(d); const m = new this.AMap.Map(e.dom, { zoom: e.zoom, zooms: e.zooms, center: e.position, layers: r }); return this.mapInstance = m, this.initEvent(), Promise.resolve(m); } } export { w as GridTileMap };