如何使不同的图片坐标分别实现点聚拢,并且可以根据不同的图层控制图片的大小
const arr = JSON.parse(sessionStorage.getItem("weatherData"));
arr.forEach((item, index) => {
let aa = item.tianqi + index;
this.map.loadImage(item.info, (error, image) => {
if (error) throw error;
this.map.addImage(aa, image);
this.map.addLayer({
id: aa + "点",
type: "symbol",
source: {
type: "geojson",
data: {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: {
title: item.cityName,
},
geometry: {
type: "Point",
coordinates: [
Number(item.zx.split(",")[0]),
Number(item.zx.split(",")[1]),
],
},
},
],
},
},
layout: {
"icon-image": aa,
"icon-size": 0.1,
"text-field": "{title}",
"text-font": ["Noto Sans Regular"],
"text-size": 12,
"text-anchor": "top",
"text-offset": [0, 1.25],
"icon-allow-overlap": true
},
paint: {
'text-halo-color': '#fff',
'text-halo-width': 2
}
});
});
});
这是我实现加载不同坐标点的方法,让相同图片实现点聚拢并没有实现