for (let i = 1; i <= 10; i++) {
let t1 = Math.random() * (maxX - minX + 1) + minX;
let t2 = Math.random() * (maxY - minY + 1) + minY;
//创建图标特性
iconFeature = new ol.Feature({
geometry: new ol.geom.Point([t1, t2], "XY"),
name: "ico"+i
});
for (let i = 1; i <= arr.length; i++) {
let t1 = Math.random() * (maxX - minX + 1) + minX;
let t2 = Math.random() * (maxY - minY + 1) + minY;
//创建图标特性
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point([t1, t2], "XY"),
name: arr[i - 1]
});
//设置点要素样式
iconFeature.setStyle(
createLabelStyle(iconFeature, icon, scale, opacity)
);
//将图标特性添加进矢量中
vectorSource.addFeature(iconFeature);
}