mapbox地图加载本地图片
import rodeImg from '@/assets/rode.png'
_this.map.on('load', () => {
_this.map.loadImage(
rodeImg,
(error, image) => {
_this.map.addImage('cat', image);
_this.map.addSource('buildings', {
type: 'geojson',
data: {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [
113.53074544385078, 34.78495896361274
]
}
}
]
}
});
_this.map.addLayer({
id: 'cat-on-building',
source: 'buildings',
slot: 'top',
type: 'symbol',
'layout': {
'icon-image': 'cat',
'icon-size': 0.1,
'symbol-placement': 'point',
'symbol-z-elevate': true
}
});
}
);
})