[OpenLayers-Users] NavToolBar events

Andreas Hocevar ahocevar at opengeo.org
Fri Jun 12 04:29:57 EDT 2009


Hi,

On Fri, Jun 12, 2009 at 9:11 AM, Brad Spencer<brad at cubewerx.com.au> wrote:
> A little more explanation, I use doubleclick for picking polygons
> interactively and drag-mouse-shift for picking a whole bunch within a drag
> area in my 'select mode'. The user can switch to viewing mode via my mode
> toggle button and happily use the default alternatives. However, if they do
> not consciously toggle off the select mode and hit the mouse-zoom button (of
> the OpenLayers.Control.NavToolbar fame) instead, the defaults are
> automatically restored and I am unable to pop my toggle button to keep in
> sync with the functionality.

Oh, now I see. I had entirely forgotten about Control.NavToolbar
because I never use that one. When I need functionality like yours, I
create a custom Control.Panel and add a button for a
Control.Navigation there. This will then work without taking extra
care. You have to be aware that Control.NavToolbar is also just a
Control.Panel. But see below for a solution for your original
question.

> I will have a look at the movend/zoomend but I will not be able to pop my
> button until they do some map navigation therefore the button will be
> incorrectly set during that period. However, I can make sure that the button
> does not pop when doing panning and zooming in select mode by setting a
> status flag, so I think it work that way just fine.
>
> What I would really like is an event triggered when the user hits the
> mouse-zoom button. Then I could pop my button immediately highlighting to
> the user that they are now in viewing mode.

You can do that already:

var control = new OpenLayers.Control.NavToolbar();
// controls[0] is the Navigation control inside the NavToolbar
control.controls[0].events.on({
    "activate": function() {
        // deactivate your select mode here
    }
});

I think this should help now.

Regards,
Andreas.

-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list