How to get the x,y values(in pixel) via mapscript?

Stephen Lime steve.lime at dnr.state.mn.us
Wed Mar 7 16:16:32 EST 2001


The mapserv app can't do much for you here. What you want to do is *really*
browser specific. If I understand it write you want the image to act as an image
map AND as a form input. For example, in Netscape (pre-6.0 anyway) form image
elements are not scriptable. In MSIE everything is scriptable and you can
use the onMouseOver event to nab the xy and do the imagemap computation
yourself. 

You could use the DNR mapplet applet to do this as well. There is a mouse over 
javascript function that is called from the applet. It's intended use is to put map
coordinates in the status bar but it could be used for mouse overs. You'd need 
to do the detection of collisions yourself. 

MapScript or Javascript can be used to compute the pixel values of your hand
placed points. The equation is:

  cellsize = (extent.maxx - extent.minx)/(width-1)

  px = round((mx - extent.minx)/cellsize);
  py = round((extent.maxy - my)/cellsize);
      
where

Cellsize is size of pixels in map units, mapserver will supply the exent for square
pixels so using the x dimension or y dimension should give the same result. Width
is the map image width in pixels. Mx and my are the coordinates in map units and
px and py are the pixel values.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> "Tom Kralidis" <tomkralidis at hotmail.com> 03/07/01 01:08PM >>>
I second this question.  Can this also be done without mapscript, ie the 
mapserv app itself?

It would be great to be able to create events based on mouseovers, ie 
imagemaps created inline, etc.

..Tom


>I'm using mapscript(with perl) to create maps on the fly. I add points  "by
>hand" ($point->draw). Now i would like to enhance this application with
>overlib.js, so a user might move his mouse-cursor over a point(drawed "by
>hand" ;)) and an image would be displayed. For this feature i need the 
>exact
>points in pixel, where these points are on the final map. Any suggestions,
>how to solve this problem?
>
>Here you can see, how the application works:
>http://www.citybeat.de/bremen/alles?adatum=2001-03-09&graum=bremen 
>If you are curious: citybeat is a town-portal for Bremen and Hamburg in
>germany. The map is from official sites completly in TIFF. If you zoom in 
>or
>out, it will change (zooming out) to Vector-Data. If a mouse-cursor is over
>a red dot, i would like to show a picture. I only need the coordinates, the
>displaying is no problem.
>
>
>Thank,
>  Hermi
>

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.





More information about the mapserver-users mailing list