hi karim,

i don't know what kind of svg base file you are using nor do i know what 
calls zoom() in your sample. but you could go on with such a structure


<svg width="100%" height="100%" ...><!--no viewBox defined here-->
<svg id="myMap" width="100%" height="100%"
viewBox="437000 –4788000 146000 226000"/>
...
</svg>
<svg id="myInfoBlock" ... viewBox="0 0 180 520" />
...
</svg>
</svg>


and use that function:


function myDoZoom(val){
var myOldScale = myDocElem.currentScale;
var oldTranslate = {
x : myDocElem.currentTranslate.x,
y : myDocElem.currentTranslate.y
}

var myStep = 2; // SPRUNGFAKTOR, KANN VARIABEL SEIN
if(myVal > 0){
myVal *= myStep;
} else {
myVal /= -myStep;
}

myDocElem.currentScale *= val;
myDocElem.currentTranslate.x = myViewportWidth / 2
– (myDocElem.currentScale / myOldScale)
* (myViewportWidth / 2 – oldTranslate.x);
myDocElem.currentTranslate.y = myViewportHeight / 2
– (myDocElem.currentScale / myOldScale)
* (myViewportHeight / 2 – oldTranslate.y);
}


where myDoZoom(1) zooms in and myDoZoom(-1) zooms out.

btw, this is a sample of a step by step tutorial specially dedicated to 
zoom/pan to be found in book that will be available feb. 2006 in german. 
the companion website is

<http://svg.carto.net/>

andré

-- 
___________________________________________________________________
andre m. winter,
  cartography for internet and multimedia applications
  schiessstand 4/1, a6091 goetzens, tyrol, austria
  tel.: ++43.5234.32732
  email: <[EMAIL PROTECTED]>

<http://www.vectoreal.com/>          SVG consulting and development
<http://www.carto.net/>          online cartography focusing on SVG
<http://www.carto.at/>     print and online touristic map solutions 






K. Scheik wrote:
> hi!
>
> i'm stuck trying to zoom via JS with the center staying the same.
> here's my current approach that works sometimes (i couldn't make out
> the system behind it):
>
> function zoom(offset) {
>       if (offset < 0)
>               offset = -1/offset;
>
>       svgdoc.currentScale *= offset;
>
>       svgdoc.currentTranslate.x = svgdoc.currentTranslate.x*offset + (1 -
> offset)*getInnerWidth/2;
>       svgdoc.currentTranslate.y = svgdoc.currentTranslate.y*offset + (1 -
> offset)*getInnerHeight/2;
> }
>
> where offset is 1.5 for +50% and -1.5 for -50%.
> sometimes it will mess up the center point.
>
> any help would be greatly appreciated!
>
> regards,
> karim
>
>
>   



------------------------ Yahoo! Groups Sponsor --------------------~--> 
1.2 million kids a year are victims of human trafficking. Stop slavery.
http://us.click.yahoo.com/.QUssC/izNLAA/TtwFAA/1U_rlB/TM
--------------------------------------------------------------------~-> 

-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to