两种方法
const mapcontainer = ref(null)
let map = null
const baseMapLayer = newAMap.TileLayer()
const initMap = async()=>{
try {
map = new AMap.Map(mapContainer.value, {
center:[113.388,23.03],
zoom :19
resizeEnable:true,
layersa : [baseMapLayer]
})
map.on("complete", function(){
console.log("地图图块加载完毕!当前地图中心点为:"+map.getcenter())
})
//默认地图不显示
baseMapLayer .setMap(null)
const showMapChoice = (val) =>{
if (val) {
baseMapLayer.setMap(map)
//map.add(baseMapLayer);两种方法均可
} else {
baseMapLayer.setMap(null)
// map.remove(baseMapLayer);
}
}