[OpenLayers-Users] disable Zoom-in function?

Erik Uzureau euzuro at gmail.com
Tue Dec 12 07:46:25 EST 2006


Hi Xiaopeng

The way to do this is, like chris said, inside
OpenLayers.Control.MouseDefaults. You need  to override the
zoomBoxEnd() function.

The easiest way to do this is like this:

    OpenLayers.Control.MouseDefaults.prototype.zoomBoxEnd = function (evt) {

    if (this.mouseDragStart != null) {

        // Ripped from MouseDefaults.js
            var start = this.map.getLonLatFromViewPortPx(
                            this.mouseDragStart );
            var end = this.map.getLonLatFromViewPortPx( evt.xy );
            var top = Math.max(start.lat, end.lat);
            var bottom = Math.min(start.lat, end.lat);
            var left = Math.min(start.lon, end.lon);
            var right = Math.max(start.lon, end.lon);
            var bounds = new OpenLayers.Bounds(left, bottom,
                                                  right, top);
        // End rip.

        // Do whatever you want to do here

         // remove the zoombox
         this.removeZoomBox();

        }
    }
}



On 12/11/06, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> On Mon, Dec 11, 2006 at 03:37:33PM -0500, Xiaopeng Xiong wrote:
> > I am curious is it possible to disable the functionality of zoom-in when a
> > user draws a rectangluar region using mouse?
> > My application just wants users to draw a query region on the map instead of
> > have the map zoomed in...
>
> This would be a non-trivial modification to
> OpenLayers.Control.MouseDefaults. I suggest you read and understand the
> code there to start: if you have questions on it, please feel free to
> come back to the list for explanations.
>
> Regards,
> --
> Christopher Schmidt
> MetaCarta
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list