默认初始化地图展示标准3d地图(这里添加蒙层)
initMap () {
this.mapObj = new AMap.Map('mapContainer', {
features: ['bg', 'road', 'point', 'building'],
showLabel: true,
rotateEnable: false,
pitchEnable: false,
zoom: 17,
pitch: 65,
rotation: 45,
viewMode: '3D', // 开启3D视图,默认为关闭
zooms: [2, 20],
center: [120.582112, 29.997117],
// mapStyle: 'amap://styles/grey',
});
},
希望通过点击切换卫星地图展示—点击事件
changeMapStyle() {
if (this.styleType === 'default') {
this.initLoadMap();
} else {
this.layers.hide();
this.styleType = 'default';
}
this.mapObj.remove(this.markerList);
this.setMarker();
},
关键代码 — 思路:通过卫星图层的展示隐藏功能实现
initLoadMap() {
this.styleType = 'Satellite';
// 切换地图样式
this.layers = new AMap.TileLayer.Satellite({ map: this.mapObj });
this.layers && this.layers.show();
},