I have a svg element in a html document that I would like to file with an image upon certain interactions, however no matter how hard I tried I can't get this to work. Even the most simple example here
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Hello World!</title>
</head>
<body>
<div id = "header" style = "border:1px solid black;">
<svg width="100%" height="100%" id = "map"></svg>
</div>
<script>
var el = document.createElementNS('http://www.w3.org/2000/svg', 'image');
el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', "https://url_of_image_here.com");
el.setAttributeNS(null, 'width', '100');
el.setAttributeNS(null, 'height', '100');
el.setAttributeNS(null, 'x', 20);
el.setAttributeNS(null, 'y', 20);
document.getElementById("map").append(el);
</script>
</body>
</html>
Produces only an empty <div>
... I looked at all other related posts and always end up with an empty <div>
(in fact, this snipet is taken from another answer to this issue...). What do I do wrong?
Moreover, how do I link a local image?