UNPKG

@tuoyuan/map-container

Version:

地图容器组件

105 lines (104 loc) 3.53 kB
import { defineComponent as A, ref as E, openBlock as R, createElementBlock as T } from "vue"; import p from "./apis/index.js"; import { EventBus as B } from "../../node_modules/@tuoyuan/vue-event-bus/dist/EventBus.js"; import { createMap as U } from "../../node_modules/@tuoyuan/map-adapter-lib/dist/es/ProxyMap.js"; import { useGeometrySourceHook as N } from "./hooks/useGeometrySourceHook.js"; import { useMapEventHook as z } from "./hooks/useMapEventHook.js"; import { useNavigationRouteHook as I } from "./hooks/useNavigationRouteHook.js"; import { useResourceLayerHook as L } from "./hooks/useResourceLayerHook.js"; const Q = /* @__PURE__ */ A({ name: "TyMapContainer", __name: "index", props: { mapId: {}, options: {} }, setup(H, { expose: k }) { var _, y; const c = H, m = new B(), d = E(null); let t; const f = /* @__PURE__ */ new Map(), w = (a, e) => f.has(a) ? (f.get(a) ?? []).find((o) => e ? o.field_key === e : o.is_default) : void 0, s = N({ getMap: () => t, bus: m, options: { staticUrl: (_ = c.options) == null ? void 0 : _.staticUrl } }), g = z({ bus: m }), S = I({ getMap: () => t, geometrySource: s.exposes }), l = L({ getMap: () => t, bus: m, geometrySource: s, getTagStyle: w, options: { staticUrl: (y = c.options) == null ? void 0 : y.staticUrl } }), j = async (a) => { var M, h, v, C, x; let e = c.mapId; e || (e = (await p.mapManage.project.getConfig({}).then((i) => i.data)).default_map_id), t = U(e, a); const r = t.coordinateSystem, o = await p.mapManage.project.getConfig({ coordinate_system: r }).then((n) => n.data), u = await p.mapManage.map.get({ map_id: e }).then((n) => n.data); t.has("load") && await t.load(u.auth_info), await t.init( { dom: d.value, zoom: o.initial_zoom_level, position: (h = (M = o.centre_resource) == null ? void 0 : M.geometry) == null ? void 0 : h.coordinates, camera: (v = o.centre_resource) == null ? void 0 : v.camera_info, boundary: o.is_show_bound && o.bound_resource ? { path: o.bound_resource.geometry.coordinates[0], style: (x = (C = o.bound_resource.styles) == null ? void 0 : C.find((n) => n.is_default)) == null ? void 0 : x.style_info } : void 0 }, u.config_info ), s.setProjectConfig(o), s.setMapConfig(u), g.setMap(t), l.setProjectConfig(o), p.mapManage.tag.getAll().then((n) => { n.data.forEach((i) => { f.set(i.tag_id, i.styles); }); }); }, b = { ...[ "panTo", "setCenter", "getCenter", "setZoom", "getZoom", "getViewBounds", "getCamera", "openHeatmap", "closeHeatmap", "createMoveAnimation", "updateMoveAnimation", "removeMoveAnimation", "setMoveAnimationInstanceState" ].reduce((a, e) => (a[e] = (...r) => { if (typeof t[e] == "function") return t[e](...r); }, a), {}), init: j }; return k({ // 地图方法 ...b, // 资源方法 ...s.exposes, // 事件方法 ...g.exposes, // 导航方法 ...S.exposes, // 图层方法 ...l.exposes }), (a, e) => (R(), T("div", { class: "ty-map-container", ref_key: "mapRef", ref: d }, null, 512)); } }); export { Q as default };