最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how do i Zoom and pan an SVG Document embed in XHTML Page using AMPLE SDK - Stack Overflow

programmeradmin5浏览0评论

Hello i am developing my map from raster to vector

i have managed to embed the SVG Map File into the XHTML page and i am using AMPLE SDK Library it is great works on all browsers.

but how can i use this library to zoom and pan into the map? i am using AMPLE SDK because the Raphael Converter from SVG To Raphael not working in good way. RAPHAEL CONVERTER

Hello i am developing my map from raster to vector

i have managed to embed the SVG Map File into the XHTML page and i am using AMPLE SDK Library it is great works on all browsers.

but how can i use this library to zoom and pan into the map? i am using AMPLE SDK because the Raphael Converter from SVG To Raphael not working in good way. RAPHAEL CONVERTER

Share edited Dec 11, 2012 at 13:35 DanMan 11.6k4 gold badges42 silver badges61 bronze badges asked May 14, 2011 at 16:06 Mark CasoMark Caso 231 silver badge3 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You can implement zoom and pan on SVG fragment by manipulating viewBox attribute on svg element as echo-flow suggested. However you should be using setAttribute to get the change reflected:

ample.getElementById("mysvg").setAttribute("viewBox", "500 500 1000 1000");

or

ample.query("#mysvg").attr("viewBox", "500 500 1000 1000");

Study the format of viewBox attribute and it will not be difficult to find out how it should be manipulated.

If Ample SDK supports dynamic SVG (and it looks like it does), then you can add this functionality by scripting the SVG root element's viewbox property in response to mouse events. For example.


var newX = 100;
var svg = document.documentElement;
svg.viewBox.baseVal.x = newX;

You would still need to hook up this code to respond to mouse events.

If you want library support, you can look into using the jQuery SVG library (although, again, I'm not sure how well this will play with Ample): http://keith-wood.name/svg.html

A demo of jquery SVG being used to perform an animated zoom using viewbox can be found here: http://keith-wood.name/svg.html#anim

发布评论

评论列表(0)

  1. 暂无评论