I am trying to put a text so that it is located in the center of my element as in the following image:
I would like this to be done dynamically depending on the size of my image.
How can I do it?
<body>
<script type="text/javascript">
const svg = d3.select("body").append("svg").attr("width",1000).attr("height",1000);
var widthMarker=50;
var img = svg.append("svg:image")
.attr("xlink:href", "marker.svg")
.attr("width", widthMarker)
.attr("height", widthMarker)
.attr("x", 228)
.attr("y",53);
svg.append("text").attr("width",100).attr("height",100).text("hello world");
</script>
</body>