加上展示切换瓦片 按钮,单个按钮即可实现功能
添加按钮
<view class="cover-view">
<van-button plain hairline type="info" class="button" bind:click="setSatellite" data-type="true">{{satellite?'卫星地图':'矢量地图'}}</van-button>
<!-- <van-icon name="setting" class="icon" bind:click="showPopup" /> -->
<view class="icon" bindtap="showPopup">
<image src="../../icon/shezhi.png" style="height: 50rpx; width: 50rpx;vertical-align:middle" alt="" srcset="" />
</view>
</view>
绑定事件修改
修改的是地图的enable-satellite 属性绑定的值 下面标星代码段是属性
这样就能实现地图的瓦片切换了。
<map class="map" id="map" longitude="{{longitude}}"
latitude="{{latitude}}" scale="3"
show-location="true" markers="{{markers}}"
***enable-satellite***="{{satellite}}"
circles="{{circles}}" bindmarkertap="makertap">
</map>
setSatellite(type){
var that = this;
console.log(type)
that.setData({
satellite: !that.data.satellite
})
},