@tuoyuan/map-adapter-img-map
Version:
图片地图适配器
59 lines (58 loc) • 1.84 kB
JavaScript
var h = Object.defineProperty;
var u = (n, t, a) => t in n ? h(n, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : n[t] = a;
var c = (n, t, a) => u(n, typeof t != "symbol" ? t + "" : t, a);
import { AMap as y } from "../node_modules/@tuoyuan/map-adapter-amap/dist/es/Map.js";
class M extends y {
constructor() {
super();
c(this, "coordinateSystem", "GCJ02");
}
init(a, d) {
const o = d;
this._dom = a.dom;
const s = document.createElement("style");
s.innerHTML = ".amap-logo{display:none!important;}.amap-copyright{display:none!important;}", document.body.appendChild(s);
const e = o == null ? void 0 : o.bounds, m = new this.AMap.ImageLayer({
url: o == null ? void 0 : o.url,
bounds: new this.AMap.Bounds(...e)
}), l = new this.AMap.Polygon({
strokeColor: (o == null ? void 0 : o.background) ?? "#fff",
strokeWeight: 0,
fillColor: (o == null ? void 0 : o.background) ?? "#000",
fillOpacity: 1
}), i = [
[
[-360, 90],
[-360, -90],
[360, -90],
[360, 90]
],
[
[e[0][0], e[0][1]],
[e[1][0] - 2e-5, e[0][1]],
[e[1][0] - 2e-5, e[1][1]],
// [bounds[1][0], bounds[0][1]],
// [bounds[1][0], bounds[1][1]],
[e[0][0], e[1][1]]
]
];
l.setPath(i);
const p = [e[1][0] - (e[1][0] - e[0][0]) / 2, e[1][1] - (e[1][1] - e[0][1]) / 2], r = new this.AMap.Map(a.dom, {
zoom: a.zoom,
center: a.position ?? p,
showIndoorMap: !1,
dragEnable: !1,
zoomEnable: !1,
rotateEnable: !1,
keyboardEnable: !1,
doubleClickZoom: !1,
scrollWheel: !1,
touchZoom: !1,
layers: [m]
});
return r.add(l), this.mapInstance = r, this.initEvent(), Promise.resolve(r);
}
}
export {
M as ImgMap
};