import * as mars3d from "mars3d"; export let map: mars3d.Map; // mars3d.Map三维地图对象 /** * 初始化地图业务,生命周期钩子函数(必须) * 框架在地图初始化完成后自动调用该函数 * @param {mars3d.Map} mapInstance 地图对象 * @returns {void} 无 */ export function onMounted(mapInstance: any) { map = mapInstance; // 记录首次创建的map } /** * 释放当前地图业务的生命周期函数 * @returns {void} 无 */ export function onUnmounted() { map = null; } // 获取图层 export function getLayers() { return map.getLayers({ basemaps: true, // 是否取config.json中的basemaps layers: true // 是否取config.json中的layers }); } export function addLayer(layer: any) { map.addLayer(layer); }