Working with React-Leaflet, I'm trying to provide a custom icon to a Marker made with URI encoded SVG. When providing an Hex color once, all works well.
var stopCircleSvg =
'<svg xmlns="http://www.w3.org/2000/svg" width="67" height="67">'+
'<g>' +
'<circle id="1" cx="34" cy="34" r="3" stroke="#D7629B" stroke-width="1.5" fill="none"/>' +
'<circle id="2" cx="34" cy="34" r="1" fill="red" />' +
'</g>' +
'</svg>';
var url = encodeURI("data:image/svg+xml," + stopCircleSvg).replace("#", "%23");
var CustomIcon = Icon.extend({
options: {
iconSize: [stopCircleSize, stopCircleSize],
iconAnchor: [stopCircleSize / 2, stopCircleSize / 2],
},
});
....
icon={
new CustomIcon({ iconUrl: url })
}
When providing an Hex color to more elements, the SVG breaks.
var stopCircleSvg =
'<svg xmlns="http://www.w3.org/2000/svg" width="67" height="67">'+
'<g>' +
'<circle id="1" cx="34" cy="34" r="3" stroke="#D7629B" stroke-width="1.5" fill="none"/>' +
'<circle id="2" cx="34" cy="34" r="1" fill="#D7629B" />' +
'</g>' +
'</svg>';
var url = encodeURI("data:image/svg+xml," + stopCircleSvg).replace("#", "%23");

