[OpenLayers-Users] disabling pan/zoom on map

Curtis W. Ruck ruckc at yahoo.com
Thu Feb 1 08:18:02 EST 2007


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.

----- Original Message ----
From: Christopher Schmidt <crschmidt at metacarta.com>
To: Jon Blower <jdb at mail.nerc-essc.ac.uk>
Cc: users at openlayers.org
Sent: Thursday, February 1, 2007 5:48:22 AM
Subject: Re: [OpenLayers-Users] disabling pan/zoom on map

On Thu, Feb 01, 2007 at 09:17:10AM +0000, Jon Blower wrote:
> Hi all,
> 
> Is there a way to (temporarily) prevent the user from panning or zooming an
> OpenLayers map?  I would like to stop the user moving the map while I am
> loading something else.

You could remove the Controls from the map temporarily. If you don't
expect them to hit the panzoom buttons, that would be as easy as... er,
wait. Apparently we don't have a removeControl method on the map? ack. I
guess that makes sense...

So, as far as I know, there is no easy way to do this. THe reason is
that controls don't tend to unregister their events. You could do
something like:

c = new OpenLayers.Control.MouseDefaults();
map.addControl(c);

// Want to turn off controls now
oldevents = []
oldevents['mouseDown'] = c.defaultMouseDown;
c.defaultMouseDown = function(){};
oldevents['mouseClick'] = c.defaultMouseClick;
c.defaultMouseClick = function() {}
...

// done now
c.defaultMouseDown=oldevents['mouseDown'];
c.defaultMouseClick = oldevents['mouseClick'];

It's not pretty, but it is a thought... I'd start from something like
that, and move on. Unfortunately, doing the same thing for the panzoom
controller would be much more difficult. 

It sounds like a removeControl method on the map, combined with teaching
controls how to clean up after themselves, would be a good idea. 

Regards,
-- 
Christopher Schmidt
MetaCarta
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070201/5d0ea18a/attachment.html


More information about the Users mailing list