[OpenLayers-Users] hover selectFeature : keep selection until new hover

Eric Lemoine eric.c2c at gmail.com
Mon Feb 4 14:22:06 EST 2008


On Feb 4, 2008 4:45 PM, Jean Pommier (IGE) <jean.pommier at ige.fr> wrote:
> Hi,

Hi Jean

> I'm using a selectFeature with hover:true, to change the style of some GML
> data (using an SLD file), and perform some actions. It works nicely, except
> for one thing : i'd like the last selected feature to keep it's "selected"
> style until a new feature is selected. Can someone tell me how to do this ?
>  Thanks

I guess you'd need to override the outFeature callback, which is
called when the mouse goes out of a feature. You'd possibly need to
modify the overFeature callback as well (to unselect the previously
selected feature).

To override the callbacks do something like that:

var sc = new OpenLayers.Control.SelectFeature(layer, {
    hover: true,
    callbacks: {
        out: function(feature) {
            // your code here
        }, {
        over: function(feature) {
            // your code here
        }
    }
);

Hope this helps,

--
Eric



More information about the Users mailing list