[GIS] Using SVG icon as marker for a geoJSON point file in Leaflet

geojsonleafletmarkerssvg

I have a basemap that displays locations from a geoJSON file. Instead of the default markers I would like to use my own svg files, but can't find out how.

Best Answer

I use this simple approach:

var svg = ''; /* insert your own svg */
var iconUrl = 'data:image/svg+xml;base64,' + btoa(svg);

var icon = L.icon( {
            iconUrl: iconUrl,
        } );