【发布时间】:2015-10-01 12:35:53
【问题描述】:
我在 SVG 地图上有一个圆形图钉。 SVG位于带有溢出的div“位置图”内:隐藏。 SVG 尺寸大于 div 尺寸。
<div class="location-map">
<svg></svg>
</div>
svg.selectAll(".pin")
.data(places)
.enter().append("circle", ".pin")
.attr("r", 5)
.attr("fill", "#fff")
.attr("transform", function(d) {
return "translate(" + projection([
d.location.longitude,
d.location.latitude
]) + ")";
});
我想获取 SVG 上的圆针位置,以便我可以在 div 内以负边距重新定位 SVG,以使圆针在 div 上水平和垂直居中显示。
如何获取圆针的 x、y 位置?
【问题讨论】:
标签: javascript d3.js svg