Do you need to draw graphics on the screen?

Before ArcGIS 10 (formally called 9.4) you could manage the location, rendering and movement of graphics on your map or globe using either a GraphicsContainer, a graphics layer, or a custom layer. The globe display needs one code solution, the map display requires another and a dynamic display needs yet more complex code.

To simplify this experience, at ArcGIS 10, we have introduced the GraphicTracker class so that you can use the same code for all three display mode. For example, if you want to display a graphic on a map just

//Initialize the GraphicTracker with a Map object
IGraphicTracker myGraphicTracker = new GraphicTrackerClass();
myGraphicTracker.Initialize(axMapControl1.Map as IBasicMap);

//Make the 2D GraphicTrackerSymbol
myGraphicTrackerSymbol = myGraphicTracker.CreateSymbol(my2DSymbol, null);

//Add the GraphicTrackerSymbol to the GraphicTracker
int myId = myGraphicTracker.Add(myGeometry, myGraphicTrackerSymbol);

If you want to display the graphic in dynamic map simply enable it

IDynamicMap myDynamicMap = (IDynamicMap)axMapControl1.Map;
myDynamicMap.DynamicMapEnabled = true;

If you want to use the globe simply initialize the GraphicsTracker with a globe object. 

//Initialize the GraphicTracker with a Globe object
myGraphicTracker.Initialize(axGlobeControl1.Globe as IGlobe);

//Make the 3D GraphicTrackerSymbol
myGraphicTrackerSymbol = myGraphicTracker.CreateSymbol(null,my3DSymbol);

The GraphicTracker, itself, will manage all rendering and map refresh issues so you don’t need to. For more information please read the document: Using a GraphicTracker

Note – Please test GraphicTracker with at least Beta 2 of ArcGIS Engine

This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

Leave a Reply