[OpenLayers-Users] Custom box activation

Simo D simone.dalmasso at gmail.com
Thu Aug 7 06:14:28 EDT 2008


Hi all, I've create a select menu in which one option is to draw a rectangle
that return his bounds coordinates. The select has an onchange listener that
removes the pan and zoom controls and activate the rectangle selecion. I'
used the code in the examples but without the keyMask:

		var control  = new OpenLayers.Control();
    OpenLayers.Util.extend(control, {
        draw: function () {
            // this Handler.Box will intercept the shift-mousedown
            // before Control.MouseDefault gets to see it
            this.box = new OpenLayers.Handler.Box(control,
                {"done": this.notice});
            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)); 
            $('info').update(ll.lon.toFixed(4) + ", " + 
                  ll.lat.toFixed(4) + ", " + 
                  ur.lon.toFixed(4) + ", " + 
                  ur.lat.toFixed(4));
									this.box.deactivate();
        }
    });
		map.addControl(control);		

It works but it requires a click on the map to be activated. Is it possible
to activate it immediately when I select the option in the menu?

Thanks
Simone
-- 
View this message in context: http://www.nabble.com/Custom-box-activation-tp18867498p18867498.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list