[OpenLayers-Dev] SelectFeature control

Alexandre Dube adube at mapgears.com
Fri Mar 6 08:50:26 EST 2009


Hi Eric,

  This looks flawless but the easiest way to know would be to test it.  
I would be glad to test this.

  One thing to though is that a SelectFeature control can draw features 
depending on its renderIntent value OR selectStyle value.  So, instead 
of storing the previous renderIntent, it could be the previous drawer ( 
i.e. control ) and call feature._previousdrawer.drawFeature(feature) and 
the previous control itself would draw the feature depending if it has a 
selectStyle or renderIntent.

  Your solution looks simple and great.  It has this concept :

  this == current drawer
  feature._previousdrawer ( or previousrenderintent ) == the previous drawer

  With our 2 controls example that is enough.  Plus, as long as we keep 
the selectedFeature array in the layer objet, there's no need to know 
more than "current" and "previous".  If we have let's say ( silly ) 6 
select features at the same time, having all their own colors, a feature 
is selected/highlighted and unselected/unhighlighted one at a time so 
"curent" and "previous" drawer is enough.  With that in mind, no need 
for a "stack" of renderIntent or a "stack" of _previousDrawer.

  What do you think ?

Alexandre

Eric Lemoine wrote:
> 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
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Dev mailing list