[OpenLayers-Users] Fwd: Custom Box handler conflict?

Diego Guidi diegoguidi at gmail.com
Mon Apr 21 12:30:26 EDT 2008


I retry to make the same questions... sorry for the "spam" but I hope
to get some suggests on how to fix my problem


---------- Forwarded message ----------
From: Diego Guidi <diegoguidi at gmail.com>
Date: Wed, Apr 16, 2008 at 11:03 AM
Subject: Custom Box handler conflict?
To: OpenLayers Users <users at openlayers.org>


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();
    OpenLayers.Util.extend(customBox,
    {
        draw: function ()
        {
            this.box = new OpenLayers.Handler.Box(customBox,
                { "done": this.notice },
                { keyMask: OpenLayers.Handler.MOD_SHIFT });
            this.box.activate();
        },

        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) + ", " +
                ur.lat.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
 coordinates.
 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?



-- 
Diego Guidi
http://lacorrente.blogspot.com



More information about the Users mailing list