话不多说,直接上代码
<el-amap ref="Amap"></el-amap>
<div class="btn" @click="gotoWx">
<span style="display: block;font-size:12px;margin-top: 4px;">切换</span>
</div>
<script>
var satellite
data() {
setTimeout(() => {
satellite = new AMap.TileLayer.Satellite({
map: this.$refs.Amap.$$getInstance()
})
satellite.hide()
},200)
return{
isWx : false
}
},
gotoWx() {
this.isWx = !this.isWx
if (this.isWx) {
satellite.show()
} else {
satellite.hide()
}
},
</script>