[mapserver-users] Fwd: full extent

Mike Smith nospam at cnrit.tamu.edu
Thu Sep 5 09:49:40 EDT 2002


I actually had to play with it a while to get it working also.  As you 
can see the comment line right above that line where I'm setting the 
zoomdir says that we must  "select the Pan option", but a zoomdir value 
of "1" is really zoom in.  Selecting Pan didn't work in my web page, so 
I started manually setting the zoomdir value to 1 (zoom in) and it worked.

Couple of notes here.  You will probably be able to nail down exactly 
what your problem is by watching the "Javascript Console" that comes 
with your web browser.  Under Netscape I find this console by pulling 
down the "Tasks" menu in my browser and going to the "Tools" option and 
then selecting "Javascript Console".  I see exactly which line of my 
code is crapping out by watching the errors that appear on that console 
when I load my page.

Also, I went ahead and put a couple of lines into my init HTML page to 
manually set the initial values of a couple of variables...like this:

<input type="hidden" name="zoomsize" value=2>
<input type="hidden" name="zoomdir" value=1>

Then in my main HTML page I put these two lines:

<input type="hidden" name="zoomsize" value="[zoomsize]">
<input type="hidden" name="zoomdir" value="[zoomdir]">

I did this just to avoid getting any "document.mapserv.zoomdir.value has 
no properties" errors.  Please also note that you must have named your 
HTML form "mapserv" in order to use my code word-for-word, for example, 
my HTML FORM tag looks like this:

<form method=GET name="mapserv" action="[program]">

If the word after the "name=" in your form tag looks any different, then 
you need to substitute all the "mapserv" words in my javascript code 
with whatever you have named your form.

Hope this helps,

Mike


Rob Holloway wrote:

>Hi 
>
>I tried the code you supplied but I'm still having
>some problems.  The button only works after I have
>manually selected my pan radio button - for some
>reason the document.mapserv.zoomdir.value = 1;  
>doesn't seem to work.  Have any ideas?
>
>Cheers
>
>Rob
>
>--- Mike Smith <nospam at cnrit.tamu.edu> wrote:
>
>>I borrowed this javascript function from the
>>mapserver mail archive and 
>>it works for me.  Just put this code in the head
>>block of your HTML page:
>>
>><SCRIPT language=JavaScript>
>>function goGlobal() {
>>  //select the Pan option so we won't zoom in when
>>clicking "full extent"
>>  document.mapserv.zoomdir.value = 1;   // NOTE that
>>my HTML form is 
>>named "mapserv"
>>  document.mapserv.zoomsize.value = 2;  // Use your
>>form's name here 
>>after "document."
>>  //set image extent to the extent value in your map
>>file
>>  // map extent is 33.709580 -4.999999 41.891010
>>5.682579
>>  document.mapserv.imgext.value = "30.109580
>>-4.999999 48.891010 6.082579";
>>  document.mapserv.imgbox.value = "-1 -1 -1 -1";
>>//used with the mapplet
>>  //set center pixel coordinates - my image size is
>>565 by 670
>>  document.mapserv.imgxy.value = "232.5 335.0";
>>  document.mapserv.submit();
>>}
>></SCRIPT>
>>
>>then call the function from any image (for example)
>>using the "onClick" 
>>action like this:
>>
>><img src="global.jpg" onClick="goGlobal();">
>>
>>Hope this helps,
>>
>>Mike Smith
>>
>>Steve Lime wrote:
>>
>>>
>------------------------------------------------------------------------
>
>>>Subject:
>>>
>>>full extent
>>>From:
>>>
>>>Rob Holloway <rholloway_1999 at yahoo.com>
>>>Date:
>>>
>>>Wed, 4 Sep 2002 11:14:46 -0700 (PDT)
>>>To:
>>>
>>>mapserver-info at lists.gis.umn.edu
>>>
>>>
>>>Hi
>>>
>>>I'm trying to create a zoom to full extent button
>>>without much success.  Does anyone have any
>>>suggestions/code to offer.  Thanks!
>>>
>>>Rob
>>>
>>>__________________________________________________
>>>Do You Yahoo!?
>>>Yahoo! Finance - Get real-time stock quotes
>>>http://finance.yahoo.com
>>>
>>>
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! Finance - Get real-time stock quotes
>http://finance.yahoo.com
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20020905/3306bfcb/attachment.html


More information about the mapserver-users mailing list