ThinkGeo.com    |     Documentation    |     Premium Support

Unable to highlight a ploygon

hello,
we are trying to highlight a polygon on mouse hover but we are facing an problem of polygon not highlighting
when two different size polygon are overlapping each other the internal small size polygon is not been highlighted.we are using the following code for highlighting.
private void HighlightAFeatureContainingPoint(PointShape mousePosition)
{

        testMap.Overlays["HighlightOverlay"].IsVisible = true;
         highlightOverlay = (LayerOverlay)testMap.Overlays["HighlightOverlay"];
        InMemoryFeatureLayer featureLayer = (InMemoryFeatureLayer)((LayerOverlay)testMap.Overlays["PolyLayer"]).Layers["polygonFeatureLayer"];
        highlightLayer = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"];

        featureLayer.Open();
         Collection<Feature> features = featureLayer.QueryTools.GetFeaturesContaining(mousePosition, ReturningColumnsType.AllColumns);
       
        featureLayer.Close();

        if (features.Count != 0)
        {
     
                highlightLayer.Open();
                highlightLayer.InternalFeatures.Clear();
                highlightLayer.InternalFeatures.Add(feature[0]);
                highlightLayer.Close();
            
           
        }
        else
        {
            highlightLayer.Open();
            highlightLayer.InternalFeatures.Clear();
            highlightLayer.Close();
        }
        highlightOverlay.Refresh();
    }

the screen shot is as shown


regards,
hrishikesh

Hi Hrishikesh,

Your code only add the first feature into hightlight layer like this: highlightLayer.InternalFeatures.Add(feature[0]);

You can loop the Collection features and add all of them into the highlightLayer will solve this problem.

Regards,

Ethan