Get X and Y of g with ID even when zooming

2

I have a map of Brazil with several <g> svg. Each element of this is a municipality. I need to get the X and Y of this element in relation to div that svg is. The bigger problem is because I have a zoom, that when clicking for example "zoom in" it zooms by changing the matrix of <g> , so the map of Brazil is closer to the screen, but its X and Y the same holds for div. So if you have too far or too close the zoom, it is no use, as the X and Y stays fixed.

I'm getting X and Y with the code:

var path      = document.getElementById(municipio).getBoundingClientRect();
var svggerado = document.getElementById('svggeradodiv').getBoundingClientRect();

var calculaX  = Math.round(path.left - (svggerado.left + 110));
var calculaY  = Math.round(path.top);
    
asked by anonymous 18.02.2017 / 17:06

0 answers