[OpenLayers-Users] vector selectFeatures: hover and onclick

Eric Lemoine eric.c2c at gmail.com
Sat Oct 13 16:45:05 EDT 2007


On 10/13/07, Josh Livni <josh at livniconsulting.com> wrote:
> I am wondering if there's an easy way to get a different effect for
> hover/mouseover and onclick for vector features.  For example, if I want
> to call functionH for a hover, and functionC for onclick.

You can try this:

select = new OpenLayers.Control.SelectFeature(vectorLayer, {
    callbacks: {
        click: functionC,
        over: functionH,
        out: functionO
    }
});

By doing so note that:

 * you're going beyond the SelectFeature API, in other words things
could change from under your feet and your code could eventually fail

 * the provided callbacks override the default callbacks defined in
the select feature control, meaning you're totally on your own. For
example, no styling will be applied to the selected features.

> It seems that if I activate two SelectFeature for the same vector layer,
> one (the hover) seems to clobber the other (click)....

There seems to be an order issue. Try to activate "hover" first and then click.

Hope this helps,
--
Eric



More information about the Users mailing list