收藏
回答

marker点击事件bindmarkertap不触发

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug map 微信iOS客户端 8.0.34 2.30.4

在开发者工具中可以触发bindmarkertap点击事件,真机调试不触发,iphone11,iphone13,三星手机都不行

index.wxml:

<view class="pages">
  <view id="searchBox">
    <view data-keyword="卫生间" bindtap="search">卫生间</view>
  </view>
  <map id="mapId" class="map" latitude="{{latitude}}" longitude="{{longitude}}" bindtap="mapclick" bindmarkertap="onMarkerTap" bindcallouttap="onCalloutTap" markers="{{currentMarkers}}" scale="{{scale}}" setting="{{setting}}" min-scale="{{minScale}}" max-scale="{{maxScale}}" enable-poi="{{enablePoi}}">
    <cover-view slot="callout">
      <block wx:if="false" wx:for="{{currentMarkers}}" wx:for-item="item" wx:key="index">
        <cover-view  class="customCallout" marker-id="{{item.id}}" bindtap="tapCustomCallout" >
          <cover-view> 
            {{item.content}}
          </cover-view>
        </cover-view>
      </block>
    </cover-view>
    <view class="floorBtns" style="bottom:{{bottom}}">
      <view class="ul">
        <block  wx:for="{{floorData}}"  wx:for-item="floor" wx:key="index">
        <view class="li {{floor.flindex == currFlIndex ? 'active' : ''}}" data-flid="{{floor.flid}}"  data-floorname="{{floor.flname}}" data-rect="{{floor.rect}}" data-flindex="{{floor.flindex}}" bindtap="changeFloor">{{floor.flname}}</view>
        </block>
      </view>
    </view>
    <view class="main_zoom zoom_wrapper" style="bottom:{{bottom}}">
      <view class="main_zoomin zoom_btn" id="main_zoomin" bindtap="zoomout">
        <view class="icon_map-jia"></view>
      </view>
      <view class="main_zoomout zoom_btn" id="main_zoomout" bindtap="zoomin">
        <view class="icon_map-jian"></view>
      </view>
    </view>
  </map> 
  <view class="bottomView" wx:if="{{showBottomView}}">
    <view class="ul">
      <view class="li myposition">
        <icon></icon>
        <text class="positon">当前位置</text>
      </view>
      <view class="li target">
        <icon></icon>
        <text class="positon">{{targetName}}</text>
        <text class="distance">距此{{targetDistance}}米</text>
      </view>
      <view class="btn btn_default openMap" data-targetname="{{targetName}}" data-targetfloorid="{{targetfloorId}}" data-targetlat="{{targetLat}}" data-targetlon="{{targetLon}}" data-method="{{method}}">路线</view>
    </view>
  </view>
</view>

index.js:

creatMaker(poiInfo){
    poiInfo.markerType = poiInfo.markerType || 1;
    let normalCallout = {
      id: poiInfo.index,
      latitude: poiInfo.lat,
      longitude: poiInfo.lon,
      iconPath: "",
      floorId:poiInfo.floorId,
      method:poiInfo.method,
      distance:poiInfo.distance,
      startPos:poiInfo.startPos,
      customCallout:true,
      content:poiInfo.text,
      zIndex:999,
      customCallout: {
        display: 'BYCLICK',
        anchorX:0,
        anchorY:90
      },
      callout: {
        content: poiInfo.text,
        color: '#000',
        fontSize: 14,
        borderWidth: 1,
        borderRadius: 5,
        borderColor: '#ccc',
        bgColor: '#fff',
        padding: 5,
        display: 'ALWAYS',
        textAlign: 'center',
      }
    }
    //点击搜索进入
    if(!poiInfo.startPos){
      normalCallout.startPos = {
        startFloorId: this.data.currFlId,
        startFloorName: "",
        startLat: this.data.latitude,
        startLon: this.data.longitude,
        startbdid: this.data.bdid,
      }
      normalCallout.iconPath = poiInfo.iconPath;
    }
    //扫码进入、大头针marker
    if(poiInfo.targetPos){
      normalCallout.targetbdid = poiInfo.targetPos.targetbdid;
      normalCallout.iconPath = iconPath + "icontype" + poiInfo.markerType + ".png";
    }
    return normalCallout
  },
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容