[mapserver-users] Mapplet and Status Bar coordinates

Eduin Yesid Carrillo yecarrillo at hotmail.com
Fri May 25 15:30:50 PDT 2001


First that all, thanks to Sthepen, Ken and Tom for Mapplet and its 
documentation.

I've made some work to get Mapplet display real coordinates in the status 
bar here is the result and it's working fine.

I really don't know how many mapplet versions are on the air, but my version 
has different javascript functions names, so be careful with yours.
(In some versions mapplet_mouse_exited function doesn't exists and 
mapplet_mouse_moved works as mapOver. Parameters are different too!)

You must add this inside <head> tag.

<script language="JavaScript"><!--
	function mapplet_mouse_moved(name,x,y) {
	 var imgext = '[imgext]';
	 var mapext = '[mapext]';
	 var mapsize = '[mapsize]';

	 mapsizeArray = mapsize.split(' ');

     if (imgext != '' && mapext == '') {
    	imgextArray = imgext.split(' ');
	 	}
	 else if (mapext != '' && imgext == '') {
     	imgextArray = mapext.split(' ');
     	}
	 else if (mapext != '' && imgext != '') {
     	imgextArray = mapext.split(' ');
     	}
	 else {
	 	imgextArray = '';
	 	}

   	 if (imgextArray != '')	{
	 	coordx = imgextArray[0]*1 + 
(x*(imgextArray[2]-imgextArray[0])/mapsizeArray[0]);
	 	coordy = imgextArray[3] - 
(y*(imgextArray[3]-imgextArray[1])/mapsizeArray[1]);
	 	}
	 else {
		coordx = '';
		coordy = '';
	 	}
     with (Math) {
        window.status = "X: " + round(coordx) + " Y: " + round(coordy);
		}
	}
    function mapplet_apply(name, minx, miny, maxx, maxy, redraw) {
      document.mapserv.imgbox.value = minx + ' ' + miny + ' ' + maxx + ' ' + 
maxy;
      document.mapserv.imgxy.value = minx + ' ' + miny;
    }

    function mapplet_error(name,message) {
      alert(message);
    }

	function mapplet_mouse_exited(name)	{
	  window.status = "";
	}
// --></script>

----------------------------
Eduin Yesid Carrillo
Ingeniero Civil
CIUDAD DIGITAL
Central de Información Regional Georefenciada
Bucaramanga - Colombia
yecarrillo at hotmail.com
yecarrillo at condorito.uis.edu.co
#ICQ 14323531

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




More information about the MapServer-users mailing list