Does anyone have a bit of code to plot a multiline? I just want to add some IPoints to a collection and display in a particular color and width, but I can't find a good way to do this.

Right now I'm using this after a dynamic draw event: dynamicDisplay.DrawMultipleLines(pointcollection);
But there's no clear place to set the graphic attributes, and it plots incorrectly.

  • Are you setting the projection on each IPoint or the IPointCollection? That may account for the incorrect plot. – BlinkyBill Aug 30 '10 at 22:54
  • @eldac PointCollection doesn't appear to have a project method, as far as I can tell the only way to set projections is on a point by point basis. – patrick Aug 31 '10 at 13:49
  • If your IPointCollection is a Multipoint instance, you can project using its IGeometry.Project method. You do not need to project if your point coordinates are in the map's coordinate system. Anyway, just to clear this up a bit, is there a reason why you are using dynamic display instead of classic IDisplay? – Petr Krebs Aug 31 '10 at 16:57
  • @petr k. display.drawPolyLine throws a COM error. Also I don't really know the difference between the two so I am just trying different things. – patrick Aug 31 '10 at 17:10

You can use a GraphicsLayer to do this, create a line element and add to the GraphicsContainer. Snippet: Add Graphic to Map Snippet


Here's what I did

I inherited BaseDynamicLayer and called AddLayer from my axMapControl. Then I overrode DrawDynamicLayer and did a iDynamicDisplay.DrawPolyline

But the trick was I used a IPointCollection4 obj and NOT a IPointCollection5 obj as an argument to the DrawPolyLine

IPointCollection4 myPolyLine = new PolylineClass(); //IPointCollection5 DID NOT WORK FOR ME
//add some points

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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