[mapserver-users] How to keep map from zooming/panning when I refresh?

Matthew Hatcher MJHatcher@space.qinetiq.com
Mon, 9 Sep 2002 08:52:37 +0100


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C257D5.DD6ACDD0
Content-Type: text/plain; charset="ISO-8859-1"

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!)

Anyway, this little script works for me:

	// update the map without panning or zooming
	function updateMap() {
		document.mapserv.mode.value = "browse";
		document.mapserv.target = "_self";
		document.mapserv.zoomdir.value = "0";
		document.mapserv.imgext.value = "[minx] [miny] [maxx]
[maxy]";
		document.mapserv.imgxy.value = "299.5 215.5";
		document.mapserv.submit();
	}

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.

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.

Good luck!
Matt.

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


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

Thanks for the help, though...anybody else have any ideas?

MIke

Martin, Daniel wrote:

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



**********************************************************************
The information contained in this email and any subsequent
 correspondence is private and is intended solely for the 
intended recipient(s). For those other than the intended
 recipient(s) any disclosure, copying, distribution, or any 
action taken or omitted to be taken in reliance on such 
information is prohibited and may be unlawful.
**********************************************************************


------_=_NextPart_001_01C257D5.DD6ACDD0
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

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

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

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

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

<P><FONT SIZE=3D2>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 upd=
ates, and seems to work nicely without panning or zooming.</FONT></P>

<P><FONT SIZE=3D2>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=3D2>Good luck!</FONT>
<BR><FONT SIZE=3D2>Matt.</FONT>
</P>

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

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

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

<P><FONT SIZE=3D2>MIke</FONT>
</P>

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

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

<CODE><FONT SIZE=3D3><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>
------_=_NextPart_001_01C257D5.DD6ACDD0--