[OpenLayers-Dev] SelectFeature control

Eric Lemoine eric.c2c at gmail.com
Fri Mar 6 03:12:25 EST 2009


On Thu, Mar 5, 2009 at 5:09 PM, Alexandre Dube <adube at mapgears.com> wrote:
> Sorry, I should have written :
>
> Control #1, select on click, color: blue
> Control #2, highlight on hover, color: yellow, highlightOnly
>
>
> The problem is that control #2 :
>
> highlight a feature even if it's selected
> doesn't unhighlight a feature that is selected
>
> so, a blue-selected-feature becomes yellow, and then moving out it remains
> yellow.  Do you see what I mean ?

You are so right!

How about that: unhighlight only if I'm the last drawer of the
feature, and unhighlight to the previous render intent. The
implementation would look like this:

(1) the select feature control places a reference to itself in the
feature it is about to highlight (whether highlightOnly is set or not)

feature._drawer = this;
this.layer.drawFeature(feature, selectStyle);

(2) before highlighting a feature store in the feature it current renderIntent

feature._previousRenderIntent = feature.renderIntent;

(3) unhighlight only if I'm the last drawer of the feature

if(feature._drawer == this) {
    this.layer.drawFeature(feature, feature._previousRenderIntent);
}


It looks better to me, tell me if this is flawed again.

Thanks for the collaboration on this Alexandre.

--
Eric



More information about the Dev mailing list