Hi Christopher,<br><br>Thanks very much for that.&nbsp; I didn&#39;t make it clear that I not only wanted to disable the pan/zoom buttons, but also the capability to drag the map.&nbsp; This is because I want to freeze the map while I load an animation, which will be overlaid on top of the map in precisely the right place.&nbsp; (The animation, by the way, is generated on a WMS using the TIME parameter and animated GIF format).
<br><br>Happily however, this turns out to be a self-solving problem!&nbsp; I load the animation in a div which sits on top of the OpenLayers map.&nbsp; When this div is visible it prevents the mouse clicks from reaching the OL map, effectively freezing it.&nbsp; In order to &quot;re-enable&quot; the OL map, I simply hide the div overlay.&nbsp; The pan/zoom controls are still visible however, so it would indeed be useful to be able to temporarily hide them so as not to confuse the user.
<br><br>Perhaps not the most elegant solution but it seems to work exactly as I need.<br><br>Regards,<br>Jon<br><br><div><span class="gmail_quote">On 2/1/07, <b class="gmail_sendername">Christopher Schmidt</b> &lt;<a href="mailto:crschmidt@metacarta.com">
crschmidt@metacarta.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Thu, Feb 01, 2007 at 09:17:10AM +0000, Jon Blower wrote:
<br>&gt; Hi all,<br>&gt;<br>&gt; Is there a way to (temporarily) prevent the user from panning or zooming an<br>&gt; OpenLayers map?&nbsp;&nbsp;I would like to stop the user moving the map while I am<br>&gt; loading something else.
<br><br>You could remove the Controls from the map temporarily. If you don&#39;t<br>expect them to hit the panzoom buttons, that would be as easy as... er,<br>wait. Apparently we don&#39;t have a removeControl method on the map? ack. I
<br>guess that makes sense...<br><br>So, as far as I know, there is no easy way to do this. THe reason is<br>that controls don&#39;t tend to unregister their events. You could do<br>something like:<br><br>c = new OpenLayers.Control.MouseDefaults
();<br>map.addControl(c);<br><br>// Want to turn off controls now<br>oldevents = []<br>oldevents[&#39;mouseDown&#39;] = c.defaultMouseDown;<br>c.defaultMouseDown = function(){};<br>oldevents[&#39;mouseClick&#39;] = c.defaultMouseClick
;<br>c.defaultMouseClick = function() {}<br>...<br><br>// done now<br>c.defaultMouseDown=oldevents[&#39;mouseDown&#39;];<br>c.defaultMouseClick = oldevents[&#39;mouseClick&#39;];<br><br>It&#39;s not pretty, but it is a thought... I&#39;d start from something like
<br>that, and move on. Unfortunately, doing the same thing for the panzoom<br>controller would be much more difficult.<br><br>It sounds like a removeControl method on the map, combined with teaching<br>controls how to clean up after themselves, would be a good idea.
<br><br>Regards,<br>--<br>Christopher Schmidt<br>MetaCarta<br></blockquote></div><br><br clear="all"><br>-- <br>--------------------------------------------------------------<br>Dr Jon Blower&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tel: +44 118 378 5213 (direct line)
<br>Technical Director&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tel: +44 118 378 8741 (ESSC)<br>Reading e-Science Centre&nbsp;&nbsp; Fax: +44 118 378 6413<br>ESSC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Email: <a href="mailto:jdb@mail.nerc-essc.ac.uk">jdb@mail.nerc-essc.ac.uk</a><br>
University of Reading<br>3 Earley Gate<br>Reading RG6 6AL, UK<br>--------------------------------------------------------------