Label Polygon corner /vertices coordinate  as graphic

2910
4
08-30-2014 11:35 AM
NajdALHanahnah
New Contributor III

Dear All

 

I am working now on ArcObject .Net to develop an gis application , i need your help in certain area , i can now get Polygon corner (vertices ) but how i can show the corner /vertices as graphic with it's label .

 

 

Thanks

0 Kudos
4 Replies
NajdALHanahnah
New Contributor III

any help or advice Plz.

0 Kudos
NajdALHanahnah
New Contributor III

This what i meant :

GIS123.png

0 Kudos
RiyasDeen
Occasional Contributor III

Hi Najad,

Have look at AddTextElement method in this sample ArcObjects 10 .NET SDK Help .

Iterate through your polygon vertices by casting it as IPointCollection to get vertex geometry.

0 Kudos
RavishankarJayaraman
New Contributor II

Here is a small piece of code that does what you need.  The code should work as it is pretty simple and I have not tested even for compilation. But this should get you started with ArcObjects.

//Get the Polygon from the Feature.Shape property

public void AddPolygonVertexText(IMap map, IPolygon polygon)

{

  IPointCollection ptCollection = (IPointCollection)polygon;

  IPoint outPoint=new PointClass();

  IGraphicsContainer graphicsContainer = map as IGraphicsContainer;

  IElement txtElement=null;

  for(int ptCount=0;ptCount<ptCollection.PointCount;ptCount++)

  {

  ptCollection.QueryPoint(ptCount,outPoint);

  GetTextElement(outPoint,ptCount+1);

  graphicsContainer.AddElement(element, 0);

  }

  ((IActiveView)map).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

}

//Creates a TextElement and sends the result to the calling class

private ITextElement AddTextElement(IPoint pt,string labelTxt)

{

  IElement element = new TextElementClass();

  ITextElement textElement = element as ITextElement;

  IPoint point = new PointClass();

    point.X = pt.X;

    point.Y = pt.Y;

    element.Geometry = point;

    textElement.Text = labelText;

  return textElement;

}