Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

New Post: Highlight Features using IndexSelection

$
0
0
Have this bit of code which works fine if PolygonLayer property has a FeatureSelection as Selection. but does not highlight the features on the map when Selection property is of type IndexSelection.

What am I doing wrong?
Thanks
public void HighlightFeature(IFeature feature)
        {
            if (_ignoreSelectionChanged) return;
            _ignoreSelectionChanged = true;

            if (FeatureSet.AttributesPopulated)
            {
                //manage selection using the Selection property
                FeatureSelection sel = PolygonLayer.Selection as FeatureSelection;
                if (sel != null)
                {
                    sel.Clear();
                    sel.Add(feature);
                }
                else if (PolygonLayer.Selection is IndexSelection)
                {
                    IndexSelection isel = PolygonLayer.Selection as IndexSelection;
                    isel.Clear();
                    isel.Add(feature.Fid);
                }
                else
                {
                    PolygonLayer.Select(feature.Fid);
                }

                if (PolygonLayer != null)
                {
                    PolygonLayer.Invalidate();
                }
                _ignoreSelectionChanged = false;
            }
        }

Viewing all articles
Browse latest Browse all 3973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>