[mapserver-users] Intercepting Map Click Coordinates withJavaScript ? Zooming with scale values.
Stephen Woodbridge
woodbri at swoodbridge.com
Tue Jan 22 07:41:31 PST 2002
Well yes it IS darn near impossible! I got it to work for NS4 and IE4
but I never played with it to get it to work on IE5 or NS6. Check out:
http://web-maps.org/RQ/nav_map.php3?event=get_map&clat=42.634735&clon=-71.390831&zoom=8&title=North+Chelmsford%2C+MA+01863
and run the cursor over the map and read the lat/lon in the boxes below
the map.
Let me know if anyone is interested in trying to get it to work with IE5
and NS6 or adding it to a navigation Skin.
-Steve W.
Steve Lime wrote:
>
> Does this actually work? I was under the impression it would IF the
> image in question was in an absolutely positioned layer or it's own
> frame. It's typically easy to get page coordinates but figuring out
> where an image lies on the page (so you know where you are in the image)
> is darn near impossible without layers or frames.
>
> Steve
>
> Stephen Lime
> Data & Applications Manager
>
> Minnesota DNR
> 500 Lafayette Road
> St. Paul, MN 55155
> 651-297-2937
> >>> Walt Lin <joemayfair at usa.net> 01/21/02 12:18 PM >>>
> 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