w***@qq.com
w***@qq.com
  • 发布:2025-05-07 11:40
  • 更新:2025-05-07 11:43
  • 阅读:48

【报Bug】markers 运行在开发者工具没问题 但是真机调试 或者发布体验版小程序 就完全不展示 不是图片路径问题

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 11 专业版 24H2

HBuilderX类型: 正式

HBuilderX版本号: 4.62

第三方开发者工具版本号: 1.06.2412050

基础库版本号: 3.8.2

项目创建方式: HBuilderX

操作步骤:
<map id="around-food-map" :enable-3D="enable3D" class="map" style="width: 100%;" :style="{height:mapheight}" show-location='true' :latitude="latitude" :longitude="longitude" :markers="markersList.length ? markersList : []"

scale="scale" @markertap="markertap" @controltap="onControltap">
<!-- 在小程序的回到自身图标 -->
<!-- #ifdef MP-WEIXIN -->
<cover-image class="img-map" src="https://oss.qiacaiba.com/crmebimage/app/img/ref-location.png"
@click="onControltap"></cover-image>

<!-- #endif -->  
<!--  地图气泡   -->  
<cover-view slot="callout">  
  <cover-view v-for="(id, index) in customCalloutMarkerIds" :key="index">  
    <cover-view class="customCallout" :marker-id="id">  
      <cover-image class="position-absolute" style="width: 92rpx; height: 78rpx;"  
src="markersList[index].iconPath"></cover-image> <cover-view class="content">
{{ markersList[index].stationName }}
</cover-view>
</cover-view>
</cover-view>
</cover-view>
</map> 就正常这么写

预期结果:

初始默认的markers 会展示 但是退出这个页面 再进来 就不展示了

实际结果:

微信开发者工具展示markers 真及调试不展示markers

bug描述:

updateMapMarkers() {
if (!this.housingList || this.housingList.length === 0) {
this.markers = [];
this.customCalloutMarkerIds = [];
return;
}

  // 创建新标记  
  const newMarkers = this.housingList.map((item, index) => {  
    return {  
      id: item.id || index + 1,  
      clusterId: index + 1,  
      stationName: item.title || item.name || '房源',  
      distance: item.distance || 0,  
      checked: false,  
      latitude: Number(item.latitude),  
      longitude: Number(item.longitude),  
      alpha: 0.8,  
      width: 30,  
      height: 30,  
      iconPath: "https://oss.qiacaiba.com/crmebimage/app/img/homestay-loc1.png",  
      callout: {  
        content: item.title || item.name || '房源',  
        color: '#333333',  
        fontSize: 12,  
        borderRadius: 4,  
        bgColor: '#ffffff',  
        padding: 4,  
        anchorY: 0,  
        anchorX: 0,  
        display: 'ALWAYS',  
      },  
      housingData: item  
    };  
  });  

  // 直接赋值,不使用异步操作  
  this.markers = newMarkers;  

  // 修改为对象数组,保存对应的索引  
  this.customCalloutMarkerIds = newMarkers.map((marker, index) => marker.id);  

  // 获取地图上下文并刷新视图  
  const mapContext = uni.createMapContext('around-food-map', this);  
  if (mapContext && typeof mapContext.includePoints === 'function') {  
    mapContext.includePoints({  
      points: newMarkers.map(marker => ({  
        latitude: marker.latitude,  
        longitude: marker.longitude  
      })),  
      padding: [80, 80, 80, 80]  
    });  
  }  
},  

这里是处理代码

2025-05-07 11:40 负责人:无 分享
已邀请:
w***@qq.com

w***@qq.com (作者)

求大佬帮忙解决一下

要回复问题请先登录注册