[OpenLayers-Users] ext toolbar issue

brad brad at numaps.com.au
Thu Jun 16 21:26:59 EDT 2011


List, I am a new user of geoExt and am having a particular problem with the
button behaviour in a toolbar.

 

I have a series of nav buttons working just fine but have added a
getFeatureInfo (GFI) mode button to this group. That registers a map click
event that carries out a getFeatureInfo request. 

 

I want the user to be able to click this button down to set the GFI mode and
then click the map. When done just click the same button to 'pop' it and
exit GFI mode OR if they change to panning mode or zoomin mode (other
buttons in group) the same will occur.

 

Because I am using a map event and not a control (I think) I am unable to
activate/deactivate this event so I use a handler to do this using a mode
flag. I have also had to put this unregister event in each of the group
buttons to make sure that when they are selected the GFI mode is
deactivated.

 

However, Firebug tells me that the control is not initiated on the first
button click which depresses the button. Then when you click it again the
button stays down and the handler fires setting the event and allowing me to
do a GFI request. If I then click it to turn off GFI mode it fires off the
handler and takles you out of GFI mode but the button is not popped.

 

Sorry about the long email but I am hoping for someone who knows how to do
this will help me out or point me somewhere.

 

Hers is my toolbar code:

action = new GeoExt.Action({

                                                control: new
OpenLayers.Control.ZoomBox(),

                                                map: map,


                                                tooltip: "Zoom in: click in
the map or use the left mouse button and drag to create a rectangle",

                                                toggleGroup: "nav",

                                                group: "nav",

                                                iconCls: 'zoomin',

                                                handler: function()

                                                {
getFeatureInfoClick(false); clickOn = false;           }

                                });                           

                                toolbarItems.push(action);

                                

                                action = new GeoExt.Action({


                                                control: new
OpenLayers.Control.ZoomBox({out:true}),

                                                map: map,


                                                tooltip: "Zoom out: click in
the map or use the left mouse button and drag to create a rectangle",

                                                toggleGroup: "nav",

                                                group: "nav",

                                                iconCls: 'zoomout',

                                                handler: function()

                                                {
getFeatureInfoClick(false); clickOn = false;                           }

                                });                           

                                toolbarItems.push(action);

                                

                                action = new GeoExt.Action({

                                                control: new
OpenLayers.Control.DragPan(),

                                                map: map,


                                                tooltip: "Pan map: keep the
left mouse button pressed and drag the map",

                                                toggleGroup: "nav",

                                                group: "nav",

                                                iconCls: 'pan',

                                                handler: function()

                                                {
getFeatureInfoClick(false); clickOn = false;                           }

                                });                           

                                toolbarItems.push(action);

 

                                action = new GeoExt.Action({


                                                control:
getFeatureInfoClick(false),         // this does remove all click events

                                                //id: 'gfiButton',

                                                map: map,

                                                pressed: false,

                                                allowDepress: false,

                                                enableToggle: true,

                                                tooltip: "Get Feature Info:
Click this button then click any map feature.",


                                                toggleGroup: "nav",

                                                group: "nav",

                                                iconCls: 'selectfeature',

                                                handler: function()

                                                {

 
alert(clickOn)

 
if(clickOn){getFeatureInfoClick(false);  }

                                                                else
{getFeatureInfoClick(true);  }

                                                }

                                });

                                toolbarItems.push(action);         

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110617/e0989f28/attachment-0001.html


More information about the Users mailing list