[Users] GeoExt Action question

geographika geographika at gmail.com
Tue Nov 16 22:27:48 CET 2010


You can definitely have both a hover tool and select tool working on the 
same layer at the same time. However you can only have one "active" tool 
in a GeoExt toolbar (unless you start overriding events etc.).
If you want a select tool to work while panning and zooming then just 
add it directly to the map.

  var hoverTool = new OpenLayers.Control.SelectFeature(layer, {
             hover: true,
             highlightOnly: true,
             eventListeners: {
                 featurehighlighted:function(){//stuff},
                 featureunhighlighted: :function(){//other stuff}
             }

         });

map.addControl(hoverTool );

You can then activate and deactivate this tool when needed from another 
GeoExt tool e.g.

myGeoExtTool.control.events.on({
                 "featurehighlighted": featureSelected,
                 "featureunhighlighted": featureUnSelected,
                 "activate": selectToolActivated, //function name - 
write a function to activate your select or hover tool
                 "deactivate": selectToolDeactivated
             });

On 16/11/2010 21:21, Dan Ramage wrote:
> Still haven't figured out what the heck is going on, but after more
> experimentation I've found that if in the GeoExt.Action configuration I
> define the handler instead of a toggleHandler, the problem does not occur.
>
> Currently I have 2 SelectFeature controls on the same layer, a hover and the
> click(the one which quits working). I also discovered if I remove the hover
> SelectFeature I do not get the problem. I've seen some discussion in the
> OpenLayers forum about having 2 SelectFeatures on the same layer so perhaps
> it still does not work 100%.
>
> My best guess is there is something happening in the OpenLayers where the
> SelectFeature control is no longer in the event chain.
> Does anyone know where I could put a breakpoint to see how events flow to
> the controls on the map?
>
> Sorry for the rambling thread.
>
> Dan


More information about the Users mailing list