1***@qq.com
1***@qq.com
  • 发布:2023-02-16 17:37
  • 更新:2023-02-16 17:38
  • 阅读:335

ios自定义点聚合缩放地图点会消失

分类:uni-app

微信小程序地图使用自定义点聚合,在ios上缩放地图后,只要触发自定义点聚合的事件,距离当前位置最近的一个点就会消失,并且不管怎么样都出不来,但是在安卓上没有这个问题

2023-02-16 17:37 负责人:无 分享
已邀请:
1***@qq.com

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

onReady() {
this._mapContext = uni.createMapContext("around-food-map", this);

// 仅调用初始化,才会触发 on.("markerClusterCreate", (e) => {})  
this._mapContext.initMarkerCluster({  
  enableDefaultStyle: false, // 是否使用默认聚合样式  
  zoomOnClick: true,  
  gridSize: 50,  
});  

this._mapContext.on("markerClusterCreate", ({ clusters }) => {  
  this.updateClusters(clusters);  
});  

},

methods: {
updateClusters(clu) {
let clusterMarkers = [];
clu.forEach((cluster, index) => {
const {
center, // 聚合点的经纬度数组
clusterId, // 聚合簇id
markerIds, // 已经聚合了的标记点id数组
} = cluster;
let clusterObj = {
clusterId, //必须
...center,
width: 33,
height: 40,
iconPath: "../../static/index/cluster.png", // 如果label不能满足需求,可用图片
joinCluster: true, // 注意:不加此项 自定义样式不显示,
label: {
// 定制聚合簇样式
content: markerIds.length + "",
fontSize: 14,
color: "#ff9030",
width: 25,
height: 20,
bgColor: "transparent",
textAlign: "center",
anchorX: this.iosFlag ? 0 : -13,
anchorY: -34,
},
};
clusterMarkers.push(clusterObj);
});
// 添加聚合簇
this._mapContext.addMarkers({
markers: clusterMarkers,
clear: false, //是否先清空地图上所有的marker
});
},
}

  • 2***@qq.com

    markerId不能为0,不然苹果机 聚合簇产生触发时 id为0的标点不显示

    2023-07-10 17:23

要回复问题请先登录注册