[OpenLayers-Users] Custom Box handler conflict?

Diego Guidi diegoguidi at gmail.com
Wed Apr 16 05:03:56 EDT 2008

I'm using the brand new 2.6 (well done guys!) but I haven't try with
older versions, so...
In my website I'm using OpenLayers and NavToolBar component, that
implements a ZoomBox handler for a zoom rect funtion that works well.
I've tried to add this custom components, taken from the openlayers
samples, and i have a strange behavior:

var customBox = new OpenLayers.Control();
        draw: function ()
            this.box = new OpenLayers.Handler.Box(customBox,
                { "done": this.notice },
                { keyMask: OpenLayers.Handler.MOD_SHIFT });

        notice: function (bounds)
            var ll = map.getLonLatFromPixel(new
OpenLayers.Pixel(bounds.left, bounds.bottom));
            var ur = map.getLonLatFromPixel(new
OpenLayers.Pixel(bounds.right, bounds.top));
            alert(ll.lon.toFixed(4) + ", " +
                ll.lat.toFixed(4) + ", " +
                ur.lon.toFixed(4) + ", " +

If i add this component to the map, when i try the code all works well:
the navtoolbar is in "pan" state so i could pan the map as usual, and
using shift i could drag a zoombox and show the bounding box
If i select the zoomrect tool from navtoolbar i lost the behavior of
the custom component :(
Any try to use shift + zoombox generates the behavior of the zoomrect tool.
any suggestion?

More information about the Users mailing list