g***@163.com
g***@163.com
  • 发布:2024-08-30 11:31
  • 更新:2024-08-30 11:31
  • 阅读:128

【报Bug】Google map 点聚合能力在ios上不生效,除非设置延时添加markers

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: w11

HBuilderX类型: 正式

HBuilderX版本号: 4.24

手机系统: iOS

手机系统版本号: iOS 17

手机厂商: 苹果

手机机型: iphone 14 pro

页面类型: nvue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

<template>
<view class="content">
<map id="map" class="map" :show-location="true" :latitude="latitude" :longitude="longitude"></map>
</view>
</template>

<script>
const img = '/static/logo.png';

export default {
data() {
return {
latitude: 23.099994,
longitude: 113.324520,
}
},
onReady() {
this._mapContext = uni.createMapContext("map", this);

  // 仅调用初始化,才会触发 on.("markerClusterCreate", (e) => {})  
  this._mapContext.initMarkerCluster({  
    enableDefaultStyle: false,  
    zoomOnClick: true,  
    gridSize: 60,  
    complete(res) {  
      console.log('initMarkerCluster', res)  
    }  
  });  

  this._mapContext.on("markerClusterCreate", (e) => {  
    console.log("markerClusterCreate", e);  
  });  

  this.addMarkers();  
},  
methods: {  
  addMarkers() {  
    const positions = [  
      {  
        latitude: 23.099994,  
        longitude: 113.324520,  
      }, {  
        latitude: 23.099994,  
        longitude: 113.322520,  
      }, {  
        latitude: 23.099994,  
        longitude: 113.326520,  
      }, {  
        latitude: 23.096994,  
        longitude: 113.329520,  
      }  
    ]  

    const markers = []  

    positions.forEach((p, i) => {  
      console.log(i)  
      markers.push(  
        Object.assign({},{  
          id: i + 1,  
          iconPath: img,  
          width: 50,  
          height: 50,  
          joinCluster: true, // 指定了该参数才会参与聚合  
          label: {  
              width: 50,  
              height: 30,  
              borderWidth: 1,  
              borderRadius: 10,  
              bgColor: '#ffffff',  
              content: `label ${i + 1}`  
          }  
        },p)  
      )  
    })  
    this._mapContext.addMarkers({  
        markers,  
        clear: false,  
        complete(res) {  
          console.log('addMarkers', res)  
        }  
    })  
  }  
}  

}
</script>

<style>
.content {
flex: 1;
}

.map {
flex: 1;
}
</style>

操作步骤:
  1. copy官方map 点聚合的功能 到nvue的页面
  2. 然后运行到ios设备上
  3. 点聚合功能显示不出来

预期结果:

期望 在ios上 不适用setTimeout就可以 显示出来点聚合的markers ,

实际结果:

实际结果是显示不出来markers

bug描述:

使用Map组件,配置了Google的APIKey,并且map组件是在nvue页面中使用的,我想使用markers的点聚合功能,按照官方的实例代码,拷贝进项目,进行运行,安卓手机map的点聚合显示正确,ios的点聚合的marker不显示,除非使用setTimeout函数,并且设置一个挺大的延迟时间 比如3s,在这个setTimeout中调用addMarkers的逻辑,这个时候ios的map地图就显示出来点聚合的markers了。所以addMarkers的调用时机在ios上有什么要求嘛?

2024-08-30 11:31 负责人:无 分享
已邀请:

要回复问题请先登录注册