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'm trying to draw a custom polygon in Dynamic Display but its really not working at all. I can get it to work if I do this:

IPointCollection pc = seg.setRectangle( as IPointCollection; 

But I want a custom polygon. I tried this following code but I'm getting -2147220968

       IPoint p0 = new PointClass(); 
        IPoint p1 = new PointClass();
        IPoint p2 = new PointClass();
        p0.SpatialReference = gcs;
        p1.SpatialReference = gcs;
        p2.SpatialReference = gcs;

        p0.PutCoords(-94.569168d, 46.697493d);
        p1.PutCoords(-94.052811d, 46.711619d);
        p2.PutCoords(-94.51561d, 46.520131d);


        ILine line = new LineClass();
        ILine line2 = new LineClass();
        ILine line3 = new LineClass();

        line.SpatialReference = mapSP;
        line2.SpatialReference = mapSP;
        line3.SpatialReference = mapSP;

        line.FromPoint= p0; 
        line.ToPoint = p1;

        line2.FromPoint= p1; 
        line2.ToPoint = p2;

        line3.FromPoint= p2; 
        line3.ToPoint = p0;

        ISegmentCollection seg = new PolygonClass();
        seg.AddSegment(line as ISegment);
        seg.AddSegment(line2 as ISegment);
        seg.AddSegment(line3 as ISegment);
        pc = seg as IPointCollection;

                           dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolFill, fillGlyph);
catch (Exception ex)
  string m= ex.Message; 
share|improve this question
up vote 0 down vote accepted

Using the above code and adding the following will get it to work.

ITopologicalOperator toppy = seg as ITopologicalOperator;
IPointCollection4 pc4 = toppy as IPointCollection4;

dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolFill, fillGlyph);

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.