Select to view content in your preferred language

clear tooltips for selected features?

752
2
10-22-2010 01:10 PM
CharlieRichman
Emerging Contributor
I'm sure this is obvious... but I don't see it!

I have a FeatureLayer that I populate via its FeatureCollection.  I trap the selectionComplete event and set tooltips for the selected features. (They're selected by IDs.)  Each selection event creates a new selection set (with my tooltips), but the tooltips from the prior selection remain.

I've tried trapping the selectionClear event, but it doesn't seem to be called automatically; even when I call it myself the features collection seems to be null, so I can't iterate through it to remove the stale tooltips.

I'm sure there's got to be an easy way to do this...

Thanks,

Charlie Richman
DC Office of Planning
Tags (2)
0 Kudos
2 Replies
DasaPaddock
Esri Regular Contributor
There's not an easy way to handle this now. I'll enter an enhancement request to have FeatureLayerEvent.features populated for a "selectionClear" event.

In the meantime, try doing this when you get a "selectionComplete" event:

var featureLayer:FeatureLayer = event.featureLayer;
var selectedFeatures:Array = featureLayer.selectedFeatures;

for each (var graphic:Graphic in featureLayer.graphicProvider)
{
    if (graphic.toolTip && selectedFeatures.indexOf(graphic) == -1)
    {
        graphic.toolTip = null;
    }
}
0 Kudos
CharlieRichman
Emerging Contributor
Thanks, Dasa.  I think that will be a very useful enhancement.

Charlie Richman
DC Office of Planning
0 Kudos