[mapserver-users] Intercepting Map Click Coordinates with JavaScript ? Zooming with scale values.

Walt Lin joemayfair at usa.net
Mon Jan 21 13:08:06 EST 2002


With CGI, it's dirt easy-- the input type=image automatically sends
along name.x and name.y as cgi parameters.  So if you could do what you
want to server side, that's the most reliable and the easiest.

If you must do it client side, you could do something like this:
var mouseX=0,mouseY=0,setX=0,setY=0;
function getMousemove(e){
    mouseX= (bw.ns4||bw.ns6)? e.pageX:
			bw.ie&&bw.win&&!bw.ie4? (event.clientX
          	-2)+document.body.scrollLeft : !bw.opera5?
			event.clientX+document.body.scrollLeft : 
			(event.clientX-2);
    mouseY= (bw.ns4||bw.ns6)? e.pageY:
			bw.ie&&bw.win&&!bw.ie4? (event.clientY
			-2)+document.body.scrollTop : !bw.opera5?
			event.clientY+document.body.scrollTop
			 : (event.clientY-2);
};

where the bw is browser detection stuff.

On Mon, Jan 21, 2002 at 11:38:36AM -0500, Doyon, Jean-Francois wrote:
> Hello,
> 
> This is not necessarily a mpaserver specific question but ...
> 
> Is there anyway/does anybody know how to intercept the x/y pixel coordinates
> that the user generated by clicking on the map when using the map as an
> <input type=image> ?
> 
> I'm trying to create an interface that uses scale values to determine the
> next up/down zoom levels, and apparently in order to do this I have to use
> the CGI variable MAPXY, which unfortunately has to be inn the map's
> projection coordinates.
> 
> So, I need to intercept the pixel coordinates (img.x and img.y) in order to
> do the necessary calculations and set MAPXY, all this triggered by the
> form's onSubmit ...
> 
> Anybody have any idea on how to do this? I haven't had any luck so far using
> things like document.form.img.x ...
> 
> If worse comes to worse I guess I could use client-side maps, but I'd rather
> not unless I absolutely have to!
> 
> Thanks in advance for the help!
> 
> Jean-Fran?ois Doyon
> Internet Service Development and Systems Support
> GeoAccess Division
> Canadian Center for Remote Sensing
> Natural Resources Canada
> http://atlas.gc.ca
> Phone: (613) 992-4902
> Fax: (613) 947-2410
> 
> 
> 



More information about the mapserver-users mailing list