24

I am in need of a small script that will display an SVG (vector image) within a frame that has 2 functions;

  1. The image can be panned (moved around to look at different parts of the svg image with the cursor) simmilar to google maps.

  2. The SVG image can be zoomed in and out on also simmilar to google maps except there will be no need to load new imagery as the image is a vector.

For a simmilar script i have seen that works with normal image formats see http://jibbering.com/routeplanner/

jberryman
  • 16,334
  • 5
  • 42
  • 83
Chandan Jog
  • 343
  • 1
  • 3
  • 5
  • Also this functionality should work on all the broswers including ie(not ie 6) without the need to download and install a svg viewer plugin. – Chandan Jog Feb 26 '10 at 04:07
  • 1
    No version of IE supports SVG (without a plugin), so this "small script" will at the very least need to convert SVG to VML. That's a pretty big job right there: the SVG spec is 719 pages long! – Ken Feb 26 '10 at 17:58
  • @Chandan You've had some useful answers - suggest you accept one of them – peter.murray.rust Jul 31 '12 at 07:48

6 Answers6

20

Raphael is good, but not good enough.

Check out this page: http://code.google.com/p/svgpan/. It does exactly what you asked for.

Washa Wu
  • 201
  • 2
  • 2
  • Does this library have any documentation? It would be great if there were some way to make it zoom in when a specific function was called on a web page. – Anderson Green Feb 26 '13 at 15:39
17

If someone is still interested: I just found this implementation of Pan and Zoom for Raphael. Still a very young project, but interesting enough I think:

https://github.com/escobar5/raphael-pan-zoom

Online demo here: http://htmlpreview.github.com/?https://raw.github.com/escobar5/raphael-pan-zoom/master/examples/complete-map/index.html

Daniel Alder
  • 5,031
  • 2
  • 45
  • 55
12

I've derived Andrea's SVGPan into a (hopefully) more friendly Raphäel plugin :)

Olha Puzhay
  • 370
  • 2
  • 9
Daniel Assange
  • 121
  • 1
  • 2
4

First you need to learn how to install a function that extends Raphael to support zooming... http://www.irunmywebsite.com/raphael/additionalhelp.html?q=addownmethodstocanvas

Next you want to implement Wout's zooming plugin... http://github.com/wout/raphael-zoom

Chasbeen
  • 1,448
  • 12
  • 17
1

You can try the scripts from IE9 test page http://ie.microsoft.com/testdrive/Graphics/42OrganizationChart/Default.xhtml Requires a little tweaking with ids but worked fine for me.

Spadar Shut
  • 15,111
  • 5
  • 47
  • 54
0

I ended up using the svg-pan-zoom which is derived from SVGPan, but allows zoomin/panning of an arbitrary svg element within your HTML, and can add controls.

SVGPan works great if your complete page is just a loaded SVG (like the tiger example), but not if your svg is somewhere deeper in the html.

nathanvda
  • 49,707
  • 13
  • 117
  • 139