This document is archived and information here might be outdated.  Recommended version.

How to create a dynamic glyph from a marker symbol (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Interacting with the map display > Displaying moving objects > Dynamic display > Using dynamic data > How to create a dynamic glyph from a marker symbol

How to create a dynamic glyph from a marker symbol

Drawing dynamic content to the dynamic display is done with dynamic glyphs. Dynamic glyphs handle the necessary resources to be rendered by the dynamic symbol. This can be a resource for a line, marker, or text. This topic guides you through the required steps to create glyphs for a marker symbol and draw them on the map.

In this topic

Creating dynamic glyphs

Creation of dynamic glyphs must take place inside one of the dynamic drawing methods; that is, inside IDynamicLayer.DrawDynamicLayer or one of the DynamicDisplayEvents callbacks (IDynamicMapEvents.BeforeDraw and IDynamicMapEvents.AfterDraw). This is because the creation of a DynamicGlyph is done through the DynamicGlyphFactory, which is a property of the DynamicDisplay where the DynamicDisplay is a parameter of these methods.

Obtaining properties from the DynamicDisplay

Keep DynamicGlyphFactory and DynamicSymbolProperties as class members and only get them once from the DynamicDisplay, since they will be used many times throughout the lifetime of the application. See the following code example:
if (m_bOnce)
    //Get the DynamicGlyphFactory from the DynamicDisplay.
    //Cast the DynamicDisplay into DynamicSymbolProperties.
    m_dynamicSymbolProps=DynamicDisplay as IDynamicSymbolProperties;
    � � � 
    //Do other initializations here.
    //Call a method to create your glyph.

If m_bOnce Then
    'Get the DynamicGlyphFactory from the DynamicDisplay.
    'Cast the DynamicDisplay into DynamicSymbolProperties.
    m_dynamicSymbolProps=TryCast(DynamicDisplay, IDynamicSymbolProperties)
    / / Do other initializations here.
    / / Call a method To create your glyph.
End If

Implementing CreateMarkerGlyph

Do the following required steps to implement the CreateMarkerGlyph() method.
  1. At the bottom of your code, add a new CreateMarkerGlyph() private method. See the following code example:
private void CreateMarkerGlyph(){}
Private Sub CreateMarkerGlyph()
End Sub
  1. Set the color that will be used as a background by the DynamicGlyph. See the following code example:
//Set the background color to white.
IRgbColor color=new RgbColorClass();
'Set the background color to white.
Dim color As IRgbColor=New RgbColorClass()
  1. Create the marker symbol. In this example, create a character marker symbol. For convenience, use the ToStdFont() method, which converts a .NET font into stdole.IFontDisp. See the following code example:
ICharacterMarkerSymbol charMarkerSymbol=new CharacterMarkerSymbolClass();
charMarkerSymbol.Font=ESRI.ArcGIS.ADF.Converter.ToStdFont(new Font(new FontFamily(
    "ESRI Default Marker")));
charMarkersymbol=New CharacterMarkerSymbolClass()
charMarkersymbol.Font=ESRI.ArcGIS.ADF.Converter.ToStdFont(New Font(New FontFamily("ESRI Default Marker"), 10.0F, FontStyle.Regular))
  1. Set the font's character index, size, and background color. See the following code example:
charMarkerSymbol.Color=TryCast(color, IColor)
  1. Use the previously cached DynamicGlyphFactory to generate the glyph. See the following code example:
m_markerGlyph=m_dynamicGlyphFactory.CreateDynamicGlyph(charMarkerSymbol as ISymbol)
m_markerGlyph=pDynamicGlyphFactory.CreateDynamicGlyph(TryCast(charMarkerSymbol, ISymbol))
  • The glyph is created and you can use it to draw the marker on the map.

Drawing the marker element

Before drawing the element, set the dynamic symbol properties. This includes setting the heading, alignment, color, scale, and the glyph.
  1. Set the heading of the dynamic symbol. See the following code example:
m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)
  1. Set the rotation alignment of the dynamic symbol. The symbol's rotation can be aligned in the following positions: 
    • With the actual orientation of the element (set by the heading)
    • With the window
    • With the north direction (the element will always face north).

    See the following code example:
//Set the symbol's alignment to align with the symbol's heading.
'Set the symbol's alignment to align with the symbol's heading.
  1. Scale the symbol. Scaling refers to the scale relative to the original size of the active symbol. When scaling, you can use different scaling for the x- and y-axis. See the following code example:
m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.1f, 1.1f);
m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.1F, 1.1F)
  1. Assign color to the symbol. See the following code example:
m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 0.0f, 1.0f,
    0.6f, 1.0f); // GREEN
m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 0.0F, 1.0F, 0.6F, 1.0F) ' GREEN
  1. Set the dynamic glyph. See the following code example:
  1. Draw the marker symbol. You need a point geometry to specify where the marker will be drawn. See the following code example:

See Also:

Dynamic display
Maximizing performance in dynamic display

Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced