i'm currently trying to get custom marker images to work in Svelte. It seems that sometimes (on refresh) the marker icons shows up and sometimes not, which is why i guess it could be loading issue.
This is appropriate for Stack Overflow as it's a question, not an issue. To quickly answer it, I believe you may need to enclose your marker creation within the map's 'load' event.
mapbox-gl-js version: latest
Question
Hi there !
i'm currently trying to get custom marker images to work in Svelte. It seems that sometimes (on refresh) the marker icons shows up and sometimes not, which is why i guess it could be loading issue.
This is my CustomMarker Component:
And this is how i add the markers on the map page:
When i remove the markerElement from the new mapboxgl.Marker the default marker can be shown and clicked.
Links to related documentation
I used this as an starting point:
https://docs.mapbox.com/help/tutorials/use-mapbox-gl-js-with-svelte/