Mouse position - coords

Jirka Cajthaml jiri.cajthaml at FSV.CVUT.CZ
Thu Aug 25 17:33:42 EDT 2005


Hi,

I use mapserver on my web page. The map is generated as image by CGI 
mapserver
and I want to show coordinates on mouse over this map. So I need pixel 
coordinates
of image (it is part of a page - table). Do you know how to solve this 
in Javacript?

I solved this for IE, but I dont know how to solve this for Mozilla...

my script:

function MYS() {
if (navigator.appName == 'Netscape') {
          document.captureEvents(Event.MOUSEMOVE);
      document.onmousemove = NNMouseMove(e);   
}
if (document.all) {
          MSMouseMove();
        }
}

function NNMouseMove(e) {
            document.mapserv.X.value = e.pageX;
            document.mapserv.Y.value = e.pageY;
}

function MSMouseMove() {
            document.mapserv.X.value = event.offsetX;
            document.mapserv.Y.value = event.offsetY;
}

and in HTML there is
...
<input type="image" name="img" src="[img]" width="600" height="420" 
border="0" onmousemove=MYS();>
....


It works for IE - it shows pixel coords of image, but in Mozilla it 
shows coords of page (I dont know how
can I get coords of upperleft corner of image realtive to page...)

Thanks for any reaction

Jiri Cajthaml



More information about the mapserver-users mailing list