高德地图实现来回切换卫星图

高德地图 默认初始化地图展示标准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',
      });
    },

![在这里插入图片描述](https://img-blog.csdnimg.cn/67d0c6467bfe428285104a335ca4b749.png

希望通过点击切换卫星地图展示—点击事件

    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();
    },
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值