Select feature using mouse click

Mar 30, 2012 at 3:59 AM
Edited Mar 30, 2012 at 10:16 AM

I am new to SotSpatial Framework and struggling to write code to select features using mouse click.

I have written following code:

private void IdentifyFeature()
{
    IEnvelope outEnv;

    map1.ClearSelection(out outEnv);
    map1.SelectionEnabled = true;

    Coordinate c1 = new Coordinate(cursorCoordinate.X - 0.1, cursorCoordinate.Y - 0.1);
    Coordinate c2 = new Coordinate(cursorCoordinate.X + 0.1, cursorCoordinate.Y + 0.1);

    IEnvelope env = new Envelope(c1, c2);

    Extent ext = new Extent(env);
    ext.SetCenter(cursorCoordinate);

    bool b = map1.Select(ext.ToEnvelope(), ext.ToEnvelope(), DotSpatial.Symbology.SelectionMode.Covers, out outEnv);
    if (!b)
    {
	b = map1.Select(ext.ToEnvelope(), ext.ToEnvelope(), DotSpatial.Symbology.SelectionMode.Intersects, out outEnv);
    }
    
}

I want to know, Is this an effective way to select a feature using mouse click?

Someone please help me out.

 

Thanks & Regards.

Chandan Kumar Rath