diff --git a/src/js/map/map.js b/src/js/map/map.js index 3e30e93..ee16867 100644 --- a/src/js/map/map.js +++ b/src/js/map/map.js @@ -129,18 +129,17 @@ Stop and start the development process in terminal after you have added your tok } function updateSVG() { - const boundaries = getSVGBoundaries(); - const { - topLeft, - bottomRight - } = boundaries; - svg.attr('width', bottomRight.x - topLeft.x + 200) - .attr('height', bottomRight.y - topLeft.y + 200) - .style('left', `${topLeft.x - 100}px`) - .style('top', `${topLeft.y - 100}px`); + const boundingClient = d3.select(`#${ui.dom.map}`).node().getBoundingClientRect(); + + let WIDTH = boundingClient.width; + let HEIGHT = boundingClient.height; g.attr('transform', `translate(${-(topLeft.x - 100)},${-(topLeft.y - 100)})`); + svg.attr('width', WIDTH) + .attr('height', HEIGHT) + .attr('style', `left: ${-transformX}px; top: ${-transformY}px`); + g.selectAll('.location').attr('transform', (d) => { const newPoint = projectPoint([+d.latitude, +d.longitude]); return `translate(${newPoint.x},${newPoint.y})`;