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.6 SDK)
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 (ArcObjects .NET 10.6 SDK)

How to create a dynamic glyph from a marker symbol


Summary
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:
[C#]
if (m_bOnce)
{
    //Get the DynamicGlyphFactory from the DynamicDisplay.
    m_dynamicGlyphFactory=DynamicDisplay.DynamicGlyphFactory;
    //Cast the DynamicDisplay into DynamicSymbolProperties.
    m_dynamicSymbolProps=DynamicDisplay as IDynamicSymbolProperties;
    � � � 
    //Do other initializations here.
    //Call a method to create your glyph.
    CreateMarkerGlyph();

    m_bOnce=false;
}
[VB.NET]
If m_bOnce Then
    'Get the DynamicGlyphFactory from the DynamicDisplay.
    m_dynamicGlyphFactory=DynamicDisplay.DynamicGlyphFactory
    'Cast the DynamicDisplay into DynamicSymbolProperties.
    m_dynamicSymbolProps=TryCast(DynamicDisplay, IDynamicSymbolProperties)
    …
    / / Do other initializations here.
    / / Call a method To create your glyph.
    CreateMarkerGlyph()
    
    m_bOnce=False
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:
[C#]
private void CreateMarkerGlyph(){}
[VB.NET]
Private Sub CreateMarkerGlyph()
End Sub
  1. Set the color that will be used as a background by the DynamicGlyph. See the following code example:
[C#]
//Set the background color to white.
IRgbColor color=new RgbColorClass();
color.Red=255;
color.Green=255;
color.Blue=255;
[VB.NET]
'Set the background color to white.
Dim color As IRgbColor=New RgbColorClass()
color.Red=255
color.Green=255
color.Blue=255
  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:
[C#]
ICharacterMarkerSymbol charMarkerSymbol=new CharacterMarkerSymbolClass();
charMarkerSymbol.Font=ESRI.ArcGIS.ADF.Converter.ToStdFont(new Font(new FontFamily(
    "ESRI Default Marker")));
[VB.NET]
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:
[C#]
charMarkerSymbol.CharacterIndex=96;
charMarkerSymbol.Size=12.0;
charMarkerSymbol.Color=(IColor)color;
[VB.NET]
charMarkerSymbol.CharacterIndex=96
charMarkerSymbol.Size=40
charMarkerSymbol.Color=TryCast(color, IColor)
  1. Use the previously cached DynamicGlyphFactory to generate the glyph. See the following code example:
[C#]
m_markerGlyph=m_dynamicGlyphFactory.CreateDynamicGlyph(charMarkerSymbol as ISymbol)
    ;
[VB.NET]
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:
[C#]
m_dynamicSymbolProps.set_Heading(esriDynamicSymbolType.esriDSymbolMarker, (float)
    heading);
[VB.NET]
m_dynamicSymbolProps.Heading(esriDynamicSymbolType.esriDSymbolMarker)=CSng(heading)
  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:
[C#]
//Set the symbol's alignment to align with the symbol's heading.
m_dynamicSymbolProps.set_RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker,
    esriDynamicSymbolRotationAlignment.esriDSRAHeading);
[VB.NET]
'Set the symbol's alignment to align with the symbol's heading.
m_dynamicSymbolProps.RotationAlignment(esriDynamicSymbolType.esriDSymbolMarker)=esriDynamicSymbolRotationAlignment.esriDSRAHeading
  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:
[C#]
m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.1f, 1.1f);
[VB.NET]
m_dynamicSymbolProps.SetScale(esriDynamicSymbolType.esriDSymbolMarker, 1.1F, 1.1F)
  1. Assign color to the symbol. See the following code example:
[C#]
m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 0.0f, 1.0f,
    0.6f, 1.0f); // GREEN
[VB.NET]
m_dynamicSymbolProps.SetColor(esriDynamicSymbolType.esriDSymbolMarker, 0.0F, 1.0F, 0.6F, 1.0F) ' GREEN
  1. Set the dynamic glyph. See the following code example:
[C#]
m_dynamicSymbolProps.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker,
    m_markerGlyph);
[VB.NET]
m_dynamicSymbolProps.DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker)=m_markerGlyph
  1. Draw the marker symbol. You need a point geometry to specify where the marker will be drawn. See the following code example:
[C#]
DynamicDisplay.DrawMarker(m_point);
[VB.NET]
DynamicDisplay.DrawMarker(m_point)


See Also:

Dynamic display
Maximizing performance in dynamic display
Samples:




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