Zoom to full extent

Michael Hearne Michael.Hearne at noaa.gov
Tue Mar 13 13:05:35 EST 2001


Robert - The only way I figured out how to do it was with some
Javascript:

function goGlobal() {
  //set image extent to the extent value in your map file
  document.mapserv.imgext.value = "390000 4830000 733800 5055500";
  document.mapserv.imgbox.value = "-1 -1 -1 -1"; //used with the mapplet
  //set center pixel coordinates - my image size is 400 by 250
  document.mapserv.imgxy.value = "200.0 125.0"; 
  //remember the old zoomdir
  document.mapserv.old_zoom.value = document.mapserv.zoomdir.value;
  //select the Pan option so we won't zoom in when clicking "full
extent"
  document.mapserv.zoomdir.value = 0;
  document.mapserv.submit();
}

You'd then need a script to run when your page loads that sets the
zoomdir back:

function update_form{
  document.mapserv.zoomdir.value = document.mapserv.old_zoom.value;
}

<-- body tag-->
<body bgcolor=#FFFFFF link="#FFFFFF" onLoad="update_form();">
<-- button to do the full extent -->
<input type="button" name="fullextent" onClick="goGlobal()">

There may be some easier way to do it using some property of the CGI
script that I didn't pay attention to...

Robert Stanton wrote:
> 
> I have been trying to create a radio button, along with my zoom and pan
> buttons, that would expand a map to its original full extent, using [mapxy]
> and [scale], to no avail. I would be grateful if someone could tell me if
> I'm on the right idea, and if so what the exact syntax of the radio input
> would be.
> 
> Thanks in advance
> 
> Robert Stanton



-- 
Michael G. Hearne     	  	email: Michael.Hearne at noaa.gov  
Coastal Remote Sensing  		phone: 843 740-1281             
TPMC/NOAA Coastal Services Center	fax:   843 740-1312       
2234 S. Hobson Ave.,    Charleston, SC 29407



More information about the mapserver-users mailing list