IDynamicLayer Interface (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > ArcObjects namespaces > Carto > ESRI.ArcGIS.Carto > Interfaces > ID > IDynamicLayer Interface (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (Carto)  

IDynamicLayer Interface

Provides access to members that work with dynamic display.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

IDynamicLayer is the interface that designates a custom layer to be a dynamic layer

Members

Name Description
Method DrawDynamicLayer Draws the layer to the specified display for the given draw phase.
Read/write property DynamicLayerDirty Indicates if the dynamic layer has changed since last drawn for the specified draw phase.
Read-only property DynamicRecompileRate Recompile Rate is the interval in milliseconds by which the dynamic layer draw method will be called, with the compiled draw phase.

CoClasses that implement IDynamicLayer

CoClasses and Classes Description
TemporalFeatureLayer (esriTrackingAnalyst) Defines the coclass IDL parameters and attributes of the TemporalFeatureLayer COM object.

Remarks

A dynamic layer is a custom layer. At minimum, each dynamic layer must implement the interfaces ILayer, IDynamicLayer and IGeoDataset.

Since a dynamic layer is a custom layer, the implementer needs to implement the underlying data structure of the layer as well as the drawing, selection, identification etc. Since a dynamic layer is implementing both IDynamicLayer and ILayer, it actually has two drawing methods. The IDynamicLayer.DrawDynamicLayer method will get called when the dynamic map is enabled and ILayer.Draw method will get called when the dynamic map is disabled. That way, if your layer must draw both in standard drawing mode and in dynamic mode, you can implement both methods. When implementing the IDynamicLayer.DrawDynamicLayer method, use the Dynamic Display API and/or the OpenGL API. When implementing the ILayer.Draw method, use the standard drawing commands (e.g. ISymbol.Draw) and/or GDI/GDI+ API.

Dynamic layers can be drawn in two different ways, and therefore have two drawing phases – immediate and compiled. In each of them, when a new set of draw commands needs to be generated, the DrawDynamicLayer method needs to iterate through the layer’s underlying data-structure and generate the corresponding draw commands for each item. In the compiled phase the draw commands are being compiled into an internal dedicated Display List of the Dynamic Layer.

Every dynamic cycle, the Dynamic Map checks each Dynamic Layer’s state. If there is a Dynamic Layer that needs to be redrawn, meaning the dynamic layer needs to regenerate a new set of draw commands, the Dynamic Map will call the Dynamic Layer’s DrawDynamicLayer method, with the corresponding draw phase, and the dynamic layer will generate a new set of draw commands. If there is at least one Dynamic Layer that needs to regenerate its drawing commands, the entire Dynamic Display needs to get repainted.

A Dynamic layer needs to regenerate its drawing commands (get redrawn), according to the draw phase it is drawing in:

  1. With the Immediate Phase, if it reports that its immediate phase is dirty.
  2. In that case the draw commands will be executed immediately.
  3. With the Compiled Phase, if it reports that its Compiled phase is dirty, and its Recompile Rate interval had elapsed. 
    In that case the display list has expired, and the dynamic layer’s draw commands will be recompiled into the display list. This display list will be reused for rendering, every dynamic cycle that the dynamic display needs to get repainted, that is if the dynamic layer is not reporting that the display list has expired (and therefore the display list doesn’t need to get recompiled).

Every dynamic cycle that the Dynamic Display needs to get repainted, the Dynamic Map will call all of the Dynamic Layers DrawDynamicLayer with the Immediate Phase, but will reuse the display lists of the Dynamic Layers with the Compiled Phase.

The difference between the phases is that when the dynamic display needs to be repainted, the Dynamic Map can reuse the display lists that were generated by the Dynamic Layers that draw in the Compiled phase, but has to regenerate the drawing commands for the Dynamic Layers that draw in the immediate phase. In other words, the immediate draw phase will be called every cycle the display needs to be repainted, but the compiled draw phase will be called only when the Dynamic Map is signaled that the display list has expired (when the DynamicRecompileRate interval has elapsed and the DynamicLayerDirty dirty flag for the esriDDCompiled phase is true).

As a good practice, it is recommended for the Dynamic Layer to draw in one of the draw phases, but not in both of them.

As a rule of thumb, it is preferable to use the Compiled Phase, since using it will minimize the CPU usage and the bus traffic to the graphic card, by minimizing the frequency in which the dynamic layer draw commands are being regenerated (the layer items are being iterated and the draw commands are being called). As an example, please refer to the RSSWeatherLayer sample. If the layer items are being updated very frequently, and therefore the compiled phase display list needs to be recompiled very frequently, it is preferable to render the layer items in the Immediate Phase, instead of in the Compiled Phase. For an example, please refer to the MyDynamicLayer sample.

Another advantage of the Compiled Phase over the Immediate Phase is that when using the Immediate Phase, every change in any of the layers (or any other reason that causes a repaint of the display), will cause all of the other layers that are using the Immediate phase to regenerate their drawing code, even when there was no real reason (no change) for them to do so.

[C#]

For DotNet, there is a base class for dynamic layer that implements most of the needed functionality of a dynamic layer. When using the base class, the dynamic layer needs to inherit from the base class ESRI.ArcGIS.ADF.BaseClasses.BaseDynamicLayer, and override the method DrawDynamicLayer (which is defined as an abstract method). For more information see the sample DynamicLogoLayer.

[Visual Basic .NET]

For DotNet, there is a base class for dynamic layer that implements most of the needed functionality of a dynamic layer. When using the base class, the dynamic layer needs to inherit from the base class ESRI.ArcGIS.ADF.BaseClasses.BaseDynamicLayer, and override the method DrawDynamicLayer (which is defined as an abstract method). For more information see the sample DynamicLogoLayer.