converting between 2 different co-ordinate systems.

robzombie
03-10-2005, 05:48 PM
Hello all.
the evt.clientX and evt.clientY returns the x/y co-ordinate in pixels, however, the viewbox co-ordinates viewBox="518008 -185126 170 180" are not in pixels (they are map co-ordinates and are inline with the British national grid). How can I get the maximum x and y values in pixels so that I can convert the evt.clientX and evt.clientY into the viewbox's co-ordinate system, instead of pixels?
Thank you.

Anonymous
03-11-2005, 02:32 AM
With ASV3, answer depend of
- svg is alone or embedded in html
- width and height are values or 100%
- if width="100%", depend of preserveAspectRatio value ...

If you use ASV6, there is a single solution using getScreenCTM()

matrix = evt.target.ownerDocument.rootElement.getScreenCTM( ).inverse()
x = matrix.a * evt.clientX + matrix.c * evt.clientY + matrix.e
y = matrix.b * evt.clientX + matrix.d * evt.clientY + matrix.f

Michel

 
Web mp2kmag.com
mapforums.com

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum