文件:ChangeMap.js
import * as Cesium from 'cesium'
import { useCesiumStore } from '@/stores/useCesiumStore.js'
import { toRaw } from 'vue'
export function changeMap(mapName) {
const viewer = toRaw(useCesiumStore().viewer); // Get the viewer instance
viewer.imageryLayers.removeAll(); // Remove all imagery layers
let imgFrom
let layer = viewer.imageryLayers
if (mapName === 'ArcGISMap') { //ArcGIS地图
Cesium.ArcGisMapService.defaultAccessToken = '你的ArcGis key'
const arcGisImagery = Cesium.ArcGisMapServerImageryProvider.fromBasemapType(Cesium.ArcGisBaseMapType.SATELLITE)
layer.add( Cesium.ImageryLayer.fromProviderAsync(arcGisImagery))
//第二种写法,参考官网API:https://cesium.com/learn/cesiumjs/ref-doc/ArcGisMapServerImageryProvider.html
// imgFrom = Cesium.ArcGisMapServerImageryProvider.fromUrl(
// "https://ibasemaps-api.