我想在地图上放置自己的标记,但MyImage应该为png。如果我希望它成为svg,怎么办?
map.loadImage(MyImage, function(error, image) {
if (error) throw error;
map.addImage("custom-marker", image);
});
答案 0 :(得分:1)
mapbox不支持SVG,您需要光栅化SVG
import mySVG from 'foo.svg'
let img = new Image(20,20)
img.onload = ()=>map.addImage('bus', img)
img.src = mySVG
来源:https://github.com/mapbox/mapbox-gl-js/issues/5529#issuecomment-340011876