I have a custom SVG icon I want to use in a Mapbox map. I have successfully added the icon to the style in Mapbox Studio, and it appears in the list of available images.
But when I try to use it in my map, it doesn't show up.
{
'id': 'hubs',
'type': 'symbol',
'paint': {
'icon-color': "red",
'icon-opacity': 0.8,
},
'layout': {
'icon-image': 'warehouse'
}
}
I'm using the Studio style in the map:
<Map
initialViewState={{
longitude: -0.114835,
latitude: 51.545553,
zoom: 11.5
}}
style={{ width: "100%", height: 400 }}
mapStyle="mapbox://styles/MY_MAPBOX_USER/MY_STYLE_ID"
styleDiffing
mapboxAccessToken={process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN}
onMouseMove={onHover}
interactiveLayerIds={interactiveLayerIds}
>
// etc.
When I use a built-in icon, though, it works fine:
'layout': {
'icon-image': 'airport-15'
}
I have looked through the Troubleshooting SVG image errors in Mapbox Studio page, but that hasn't helped.
What am I doing wrong?
I've had this problem twice now. In each case, the solution was just to wait. My guess is that it takes awhile for the icon to propogate through Mapbox's CDN. After 15 minutes or so, the icon will begin to appear and can be used as normal.