【解决办法】可调用map的loadImage以及addImage引入图片,最后设置icon-image即可,具体代码如下:
// 1.填写图片的地址
map.loadImage('./image/ss.png',(error, image) => {
if (error) throw error;
// 2.添加图片到style中,并命名id为“supermap”
map.addImage('supermap', image);
// 3.将添加的图片设置为点的icon-image
map.addLayer({
'id': 'points',
'type': 'symbol',
'source': 'point',
'layout': {
'icon-image': 'supermap',
'icon-size': 0.25
}
});
});