mapimage.java public method addition?

Tom Kralidis tomkralidis at hotmail.com
Tue Jan 23 13:44:26 EST 2001


Hi,

I have implemented the wonderful mapimage applet into my web mapping 
application.

A feature that I would like to add (or see added) is an X Y report of where 
the user's mouse is over the mapplet.  Using the X Y position of the mouse 
over the image, one could access this from javascript, ie.

<APPLET
CODEBASE="/gis/mapserv/tom_demo/mapimage"
CODE="mapimage.class"
WIDTH="600"
HEIGHT="400"
NAME="mapimage"
ONMOUSEOVER="javascript:mapOver();" MAYSCRIPT>

<!-- does ONMOUSEOVER in applets work in NN?? -->

<PARAM NAME="image" VALUE="192.168.1.3[img]">
<PARAM NAME="jitter" VALUE="1">
<PARAM NAME="color"  VALUE="255 0 0">
</APPLET>

Note ONMOUSEOVER.

Then, through a public method within the .java file, ie:

public int[] reportXY(Event e, int x, int y) {
  int [] XYCoords;
  XYCoords = new int[2];
  XYCoords[0] = x;
  XYCoords[1] = y;
  return XYCoords;
}

..then in the javascript:

function mapOver() {
// grab image width/height
  var re = / /;
  var imgsize  = [imgsize];
  var newarray = new Array();
  newArray     = imgsize.split(re);

  // grab user X and Y click pos from java public method

  var tmpxy = new Array();
  tmpxy     = document.mapimage.reportXY(); // arguments here?

  var tmpx =  Number([minx] + (tmpxy[0] * (Math.abs([minx]) - Math.abs 
(([maxx]))) / NewArray[0] ));

  var tmpy = Number([miny] + (tmpxy[1] * (Math.abs([maxy]) - 
(Math.abs([miny]))) / NewArray[1] ));

  document.mapserv.mapOverX.value = tmpx;
  document.mapserv.mapOverY.value = tmpy;
}

...thus updating the form boxes.

Does this sort of thing make sense?  Has anyone tried this, or an 
alternative?

I've tried this but can't seem to find out the how to get the XY out of the 
applet.

If I could get this going, I'll post the edited source to the group with 
examples.

Thanks for your time.

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




More information about the mapserver-users mailing list