Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two points, Ipoint upperRight; and Ipoint lowerLeft; points.

from the previous points i can get the height and the width for the rectangle.

How can i draw a rectangle on the map?.

I think i should use IGraphicsContainer.AddElement Method, but i don't know how, i searched through the internet but didn't find any useful example.

share|improve this question
up vote 3 down vote accepted

This is the code to draw a rectangle to page layout view.

IEnvelope env = element.Geometry.Envelope;

if (env != null) {
IPageLayout pLayout = activeView as IPageLayout;
IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer;
IRectangleElement rectangleElement = new RectangleElementClass();
IElement elem = rectangleElement as IElement;
elem.Geometry = env;
graphicsContainer .AddElement(elem, 0);
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.