Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using OpenLayers. When a user holds Shift, clicks on map and moves the mouse, the box is shown. When user releases the mouse button, I intercept the event and use the coordinates of the box.

        var boxControl = new OpenLayers.Control();
        OpenLayers.Util.extend(boxControl, {
            draw: function () {
                // this Handler.Box will intercept the shift-mousedown
                // before Control.MouseDefault gets to see it
       = new OpenLayers.Handler.Box(boxControl,
                        { "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,;
                doSomething(ll, ur);

It works when with Shift button. But when I change MOD_SHIFT to MOD_ALT, my code is ignored, the bounding box is never shown on screen and "notice" function is never called.

Could you help to fix it (for either Alt or Control buttons), please?

PS. I cannot use OpenLayers.Control.Select

share|improve this question

Can you also put your map initializing code here? I'm not 100% sure, but please note when you initialize map object without any controls provided, the map object will be created associated with 4 controls, and among the is the OpenLayers.Control.Navigation control by which you can draw zoombox on map (behind it is a OpenLayers.Handler.Box handler with default MOD_SHIFT keymask). So I doubt if this boxControl actually takes effect.

share|improve this answer
I will check, thanks! – Maxim Eliseev Jun 26 '13 at 11:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.