html52.com
我爱小程序-开发者交流社区

map bindmarkertap方法中调用setData设置map属性

问题模块
API和组件

wxml代码:

 <view class="container">

  <map id="myMap"
    show-location=true
    style="width: 100%; height: 800rpx;"
    latitude="{{latitude}}"
    longitude="{{longitude}}"
    markers="{{markers}}"
    circles="{{circles}}"
    scale="{{scale}}"
    controls="{{controls}}"
    bindregionchange="regionchange"
    bindcontroltap="controltap"
    bindmarkertap="markertap"
  ></map>
</view>

js代码

markertap(e) {
    console.log(e.markerId)
    var location = this.data.pubInfos[tabIndex]
    this.setData({
      latitude: location.latitude,
      longitude: location.longitude,
    }) 

},

在map的bindmarkertap方法中,使用setData接口设置map的一些属性,会导致后续bindmarkertap事件无法响应

开发工具正常,真机有这个问题

应用场景是点击地图marker点后,将地图中心切到该marker点

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付