本文介绍了raphael js setViewBox没有调整我的论文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在raphael上遇到了setViewBox的问题,即使我做了 myPaper.setViewBox(0,0,new_map_width,new_map_height,true),也没有调整纸张大小; (JS代码第9行)

I have a problem with setViewBox on raphael, The paper isn't resized even if I did myPaper.setViewBox(0, 0, new_map_width, new_map_height,true); (Line 9 on the JS code)

Nb:new_map_width = 400且new_map_height = 300,地图为800 * 600

Nb : new_map_width = 400 and new_map_height=300 and the map is at 800*600

这是我的代码:

推荐答案

我找到了解决方案,我必须在绘制所有路径后执行我的setViewBox方法,并使用一些数学技能:)

I found the solution, I have to execute my setViewBox method after drawing all the paths, and use some math skills :)

var original_width = 777;
var original_height = 667;
var zoom_width = map_width/original_width;
var zoom_height = map_height/original_height;
if(zoom_width<=zoom_height)
   zoom = zoom_width;
else
   zoom = zoom_height;
rsr.setViewBox($("#"+map_name).offset().left, $("#"+map_name).offset().top, (map_width/zoom), (map_height/zoom));

这篇关于raphael js setViewBox没有调整我的论文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 14:13