Bryan
Bryan

Reputation: 2305

How can I get a SVG path shape to scale on zoom in D3?

Given my example here, how can I get the location markers on the map to scale when I zoom in/out on the map? Based on what I've read, I think I need to use a tween function via attrTween but I don't really know what that means.

Upvotes: 1

Views: 937

Answers (1)

Lars Kotthoff
Lars Kotthoff

Reputation: 109232

You can get the current zoom level through zoom.scale(). This you can then use to compute the scale factor for the marker paths such that they remain the same size. All you then need to do is apply this scale in a transform attribute for those paths.

Upvotes: 1

Related Questions