首先添加资源
map.addSource("Points",{
type:'geojson',
data:{
type:"FeatureCollection",
features:this.geometryArr, //这里是要添加的实例的集合
}
});
接着添加图层,重点就在这里
map.addLayer({
type:"symbol'',
source:"Points", //对应上面集合的id
layout:{
"icon-image":['get','url'] //这里就可以加载多种图片
"icon-size":1.5 //图片(缩放)大小
}
})
添加实例进来
this.geometryArr.push({
type:"Feature",
geometry:{
type:"geojson",
coordinates:[120,30]
},
properties:{
url:"ceshi",//此时就会加载这个图片
}