Can't scale multiple paths in Raphael?

怎甘沉沦 提交于 2019-12-05 08:28:21

Don't know if this'll help, and it's a bit off the cuff, but have you tried sticking your map in it's own raphael instance and then using Paper.setViewBox(...) to resize it?

 var map = Raphael(100,100,800,500);
 //
 // draw my very big map, bigger than 800x500
 //
 map.setViewBox(100,100,800,500,true); 
 // doesn't change the size of the raphael instance, but will force the graphics to fit
 // inside it.

setViewBox lets you alter the viewport. From the link - "Sets the view box of the paper. Practically it gives you ability to zoom and pan whole paper surface by specifying new boundaries".

It might be a quick way to get what you want. It Raphael 2 only though :(

(This should work, but I haven't actually tested it. As I said, it's a bit off the cuff...)

Challe

Add the parameter viewBox and preserveAspectRatio to the SVG element. I tried adding these parameters, just to see if I managed to change the size, and I did.

<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
   viewBox="0 0 2500 3100" preserveAspectRatio="none">

More about the viewBox attribute here.

I came up with this jsfiddle. I'm using this in my own map with multiple regions. Works on IE6,8 & 9

http://jsfiddle.net/chrisloughnane/EUwRq/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!