<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [mapserver-users] How to keep map from zooming/panning when I refresh?</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Here is the Javascript function that I use. I think the problem is that the values for your map click location are kept from the last pan or zoom, so that when the map refreshes it thinks you have clicked off-centre. (this is just my laymans interpretation of it, so don't flame me if that's wrong!)</FONT></P>

<P><FONT SIZE=2>Anyway, this little script works for me:</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>// update the map without panning or zooming</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>function updateMap() {</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>document.mapserv.mode.value = &quot;browse&quot;;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>document.mapserv.target = &quot;_self&quot;;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>document.mapserv.zoomdir.value = &quot;0&quot;;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>document.mapserv.imgext.value = &quot;[minx] [miny] [maxx] [maxy]&quot;;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>document.mapserv.imgxy.value = &quot;299.5 215.5&quot;;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>document.mapserv.submit();</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>}</FONT>
</P>

<P><FONT SIZE=2>I have attached this function to all the checkboxes I use to turn layers on/off, so when the user clicks on one it automatically updates, and seems to work nicely without panning or zooming.</FONT></P>

<P><FONT SIZE=2>You'll need to change the values in imgxy to reflect your half-image width/height, and also may need to change the document.mapserv if you've called your settings form something different.</FONT></P>

<P><FONT SIZE=2>Good luck!</FONT>
<BR><FONT SIZE=2>Matt.</FONT>
</P>

<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Mike Smith [<A HREF="mailto:nospam@cnrit.tamu.edu">mailto:nospam@cnrit.tamu.edu</A>]</FONT>
<BR><FONT SIZE=2>Sent: 06 September 2002 14:53</FONT>
<BR><FONT SIZE=2>To: Martin, Daniel</FONT>
<BR><FONT SIZE=2>Cc: mapserver-users@lists.gis.umn.edu</FONT>
<BR><FONT SIZE=2>Subject: Re: [mapserver-users] How to keep map from zooming/panning when</FONT>
<BR><FONT SIZE=2>I refresh?</FONT>
</P>
<BR>

<P><FONT SIZE=2>Thanks for this.&nbsp; This sorta worked...it kept my image from zooming in, </FONT>
<BR><FONT SIZE=2>but then it panned to the right for some reason?!&nbsp; I'm not sure what's </FONT>
<BR><FONT SIZE=2>up with that, but the other problem is that I've got to keep the </FONT>
<BR><FONT SIZE=2>&quot;zoomdir&quot; variable set because I keep the state of my &quot;Zoom In&quot;,&nbsp; &quot;Zoom </FONT>
<BR><FONT SIZE=2>Out&quot;, and &quot;Pan&quot; buttons based on the value of this variable, so setting </FONT>
<BR><FONT SIZE=2>it to null resets all my buttons.&nbsp; Regardless of my implementation, </FONT>
<BR><FONT SIZE=2>though, I even had this problem with the Itasca Demo...&nbsp; I'm just </FONT>
<BR><FONT SIZE=2>wondering if anybody else figured out a way to alter the image without </FONT>
<BR><FONT SIZE=2>the Mapserver CGI program reading and executing your zoomdir variable.</FONT>
</P>

<P><FONT SIZE=2>Thanks for the help, though...anybody else have any ideas?</FONT>
</P>

<P><FONT SIZE=2>MIke</FONT>
</P>

<P><FONT SIZE=2>Martin, Daniel wrote:</FONT>
</P>

<P><FONT SIZE=2>&gt;Whoops, I messed up the JavaScript.&nbsp; This is a correction, note &quot;.value&quot; is</FONT>
<BR><FONT SIZE=2>&gt;added:</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;function UpdateMap() {</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp; document.forms.mapserv.zoomdir.value = &quot;&quot;;</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp; document.mapserv.submit();&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;}</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;-----Original Message-----</FONT>
<BR><FONT SIZE=2>&gt;From: Martin, Daniel </FONT>
<BR><FONT SIZE=2>&gt;Sent: Thursday, September 05, 2002 11:47 AM</FONT>
<BR><FONT SIZE=2>&gt;To: 'Mike Smith'; mapserver-users@lists.gis.umn.edu</FONT>
<BR><FONT SIZE=2>&gt;Subject: RE: [mapserver-users] How to keep map from zooming/panning when</FONT>
<BR><FONT SIZE=2>&gt;I refresh?</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;I think this will work:</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;function UpdateMap() {</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp; document.forms.mapserv.zoomdir = &quot;&quot;;</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp; document.mapserv.submit();&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;}</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;Or perhaps I'm missing something.&nbsp; I do exactly what you say in my client,</FONT>
<BR><FONT SIZE=2>&gt;but I use Rosa to control zooming and panning, so it is a bit different.</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;-Dan</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;-----Original Message-----</FONT>
<BR><FONT SIZE=2>&gt;From: Mike Smith [<A HREF="mailto:nospam@cnrit.tamu.edu">mailto:nospam@cnrit.tamu.edu</A>]</FONT>
<BR><FONT SIZE=2>&gt;Sent: Thursday, September 05, 2002 10:01 AM</FONT>
<BR><FONT SIZE=2>&gt;To: mapserver-users@lists.gis.umn.edu</FONT>
<BR><FONT SIZE=2>&gt;Subject: [mapserver-users] How to keep map from zooming/panning when I</FONT>
<BR><FONT SIZE=2>&gt;refresh?</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;Hello,</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp; I've got my page working pretty well now thanks to lots of </FONT>
<BR><FONT SIZE=2>&gt;Javascript code I borrowed from this mailing list, but I've still got </FONT>
<BR><FONT SIZE=2>&gt;one problem that I can't seem to find a solution for in the archives. </FONT>
<BR><FONT SIZE=2>&gt; I've got my page set up so that the various layers that are available </FONT>
<BR><FONT SIZE=2>&gt;to view are in a list on the right-hand side of the page with checkboxes </FONT>
<BR><FONT SIZE=2>&gt;next to them.&nbsp; And since I wanted the behavior of the page to imitate </FONT>
<BR><FONT SIZE=2>&gt;ArcView as much as possible (because most of my users are used to that </FONT>
<BR><FONT SIZE=2>&gt;interface) I put in a little javascript function that automatically </FONT>
<BR><FONT SIZE=2>&gt;reloads the page whenever they check or uncheck a layer (without having </FONT>
<BR><FONT SIZE=2>&gt;to click a &quot;refresh&quot; button).&nbsp; My problem is that the layer loads or </FONT>
<BR><FONT SIZE=2>&gt;unloads fine, but my image also pans or zooms at the same time depending </FONT>
<BR><FONT SIZE=2>&gt;on what function they have checked.&nbsp; How can I make my page reload </FONT>
<BR><FONT SIZE=2>&gt;without changing the current view at all?&nbsp; Even if they have the &quot;Zoom </FONT>
<BR><FONT SIZE=2>&gt;In&quot; button clicked and the zoomsize is set to &quot;2&quot; I don't want the page </FONT>
<BR><FONT SIZE=2>&gt;to zoom in when they just add a new layer.&nbsp; Is there a value that I can </FONT>
<BR><FONT SIZE=2>&gt;set &quot;zoomdir&quot; to besides 1, 0, or -1 that basically disables panning and </FONT>
<BR><FONT SIZE=2>&gt;zooming altogether?</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;Thanks in advance,</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;Mike Smith</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;P.S. - Here's my javascript code that automatically loads/unloads layers:</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;function UpdateMap() {</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp; document.mapserv.submit();&nbsp;&nbsp; //Note that my form name is &quot;mapserv&quot;</FONT>
<BR><FONT SIZE=2>&gt;}</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;Then I add this to my checkbox tag:</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;onClick=&quot;UpdateMap();&quot;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
<BR><FONT SIZE=2>&gt;</FONT>
</P>

<CODE><FONT SIZE=3><BR>
<BR>
**********************************************************************<BR>
The information contained in this email and any subsequent<BR>
 correspondence is private and is intended solely for the <BR>
intended recipient(s). For those other than the intended<BR>
 recipient(s) any disclosure, copying, distribution, or any <BR>
action taken or omitted to be taken in reliance on such <BR>
information is prohibited and may be unlawful.<BR>
**********************************************************************<BR>
</FONT></CODE>
</BODY>
</HTML>