I am drawing a dynamic moving vehicle like this:

m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, this.bluePoliceCarGlyph);
m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, .3f, .3f);
currentUnitPosition = getNextPosition();

Does anyone know an easy way to do a hit test on my vehicle? I am having trouble with this code example, http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_identify_objects_in_dynamic_display/0001000004s2000000/

One of the issues I have with the example is that ESRI states:

ArcGIS versions 9.2 and later have the following three display systems that use OpenGL as their underlying drawing pipe—ArcGlobe/GlobeControl, ArcScene/SceneControl, and MapControl's dynamic display.

So I am trying to get a hit test for a dynamic display object, but according to the tutorial, part 1 (link above), I have to use the OpenGL display system to give my dynamic display object a watermark in order for the hit test to work. This makes no sense at all.

uint ID = Convert.ToUInt32(r[0]);

Another issue I have is when this code is called

IArray dynamicHitArray = m_dynamicDisplay.Locate(x, y,
    esriDynamicSelectionMode.esriDSMLayers, this as IDynamicLayer);

Another event is fired off to DrawDynamicLayer and I will get a stackoverflow unless I do this

    someBool = true; 
    IArray dynamicHitArray = m_dynamicDisplay.Locate(x, y,
        esriDynamicSelectionMode.esriDSMLayers, this as IDynamicLayer);

  someBool = false; 

1 Answer 1


I grabbed the OpenGL files from this sample: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Sample_Dynamic_display_compass/0001000004nq000000/

Then in my DynamicLayer (CustomDynamicLayer) I do this:

public override void DrawDynamicLayer(esriDynamicDrawPhase DynamicDrawPhase, IDisplay iDisplay, IDynamicDisplay iDynamicDisplay) 

OpenGL.GL.glLoadName(id); //id is arbitrary
m_dynamicSymbolProperties.set_DynamicGlyph(esriDynamicSymbolType.esriDSymbolMarker, unitIcon);
m_dynamicSymbolProperties.SetScale(esriDynamicSymbolType.esriDSymbolMarker, .3f, .3f);

Then in my main app I have an event handler for AfterDynamicDraw

public void OnAfterDynamicDraw(esriDynamicMapDrawPhase dynamicMapDrawPhase, IDisplay Display, IDynamicDisplay dynamicDisplay) 

  IDynamicDisplay2 dynamicDisplay2 = dynamicDisplay as IDynamicDisplay2; 

  //test some x,y that i know i hit
  IArray thisArray = dynamicDisplay2.Locate(674, 249,   esriDynamicSelectionMode.esriDSMLayers, this.customDynamicLayer as IDynamicLayer);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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