<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;">just for the record, i think bill woodall has the code and may be tidying it up some, but the generic toolbar class i wrote would easily allow this... a lot more than the current Mouse* classes would.<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Christopher Schmidt <crschmidt@metacarta.com><br>To: Jon Blower <jdb@mail.nerc-essc.ac.uk><br>Cc: users@openlayers.org<br>Sent: Thursday, February 1, 2007 5:48:22 AM<br>Subject: Re: [OpenLayers-Users] disabling pan/zoom on map<br><br><div>On Thu, Feb 01, 2007 at 09:17:10AM +0000, Jon Blower wrote:<br>> Hi all,<br>> <br>> Is there a way to (temporarily) prevent the user from panning or zooming an<br>> OpenLayers
map? I would like to stop the user moving the map while I am<br>> loading something else.<br><br>You could remove the Controls from the map temporarily. If you don't<br>expect them to hit the panzoom buttons, that would be as easy as... er,<br>wait. Apparently we don'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'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['mouseDown'] = c.defaultMouseDown;<br>c.defaultMouseDown = function(){};<br>oldevents['mouseClick'] = c.defaultMouseClick;<br>c.defaultMouseClick = function() {}<br>...<br><br>// done now<br>c.defaultMouseDown=oldevents['mouseDown'];<br>c.defaultMouseClick = oldevents['mouseClick'];<br><br>It's not pretty, but it is a
thought... I'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>_______________________________________________<br>Users mailing list<br>Users@openlayers.org<br><a target="_blank" href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</a><br></div></div><br></div></div></body></html>