[OpenLayers-Users] disable Zoom-in function?
Xiaopeng Xiong
xpxiong at purdue.edu
Tue Dec 12 09:56:56 EST 2006
Thanks Chris and Erik.
I changed the .js using Erik's suggestion, and it actually works. But the
remaining problem is that the rect region immediately disappear when
the mouse is released. If I disable the "this.removeZoomBox();", the rect
region will never be cleaned out so there will be multiple rects.
I also tried to put the removeZoomBox() call to "defaultMouseDown" funciton,
it seems not working neither.
Thanks,
Xiaopeng
----- Original Message -----
From: "Erik Uzureau" <euzuro at gmail.com>
To: "Christopher Schmidt" <crschmidt at metacarta.com>
Cc: "Xiaopeng Xiong" <xpxiong at purdue.edu>; <users at openlayers.org>
Sent: Tuesday, December 12, 2006 7:46 AM
Subject: Re: [OpenLayers-Users] disable Zoom-in function?
> 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