Search This Blog

Friday, December 20, 2013

Identify feature DotSpatial Map

DotSpatial > Controls > Map

Identify feature DotSpatial Map on MouseUP event.


private void map1_MouseUp(object sender, MouseEventArgs e)
{
      Coordinate cor =  map1.PixelToProj(e.Location);
      Extent ex = new Extent(cor.X, cor.Y, cor.X, cor.Y);
      var  mLayer = map1.Layers[0];
      IFeatureLayer il = (IFeatureLayer) mLayer;
      List<IFeature> result = il.DataSet.Select(ex);
      if (result.Count>0) 
      {
           IFeature ift = result.FirstOrDefault();
           MessageBox.Show(ift.DataRow[0].ToString());
       }
}