I have a canvas which displays some SVG paths. I've drawn these using KonvaJs. Users should be able to click on any of these paths and zoom in on it. After clicking a path, the canvas should zoom to the point where the path fits the full size of the canvas. See this JsFiddle. (The paths will be imported from another source).
I know you can scale a layer like this:
layer.scale({
x : 2,
y : 2
});
But I don't know what x
and y
value it needs to get the right scale.
So, my question: How to zoom/scale a path to fit it's container, using KonvaJs?
I hope you know what I mean. If not, AmCharts' Maps does the exact thing I want to accomplish. When you click on a country, the canvas zooms in on it. The zoom animation would be nice to have, but is not a requirement. I'm not using AmCharts because it doesn't fit (the rest of) my needs.
Note: I started using KonvaJs because I've used KineticJs before. As I understand, KineticJs is not maintained anymore, but KonvaJs is a fork of it (correct me if I'm wrong). If you know of a better library to do this, please let me know.