Select to view content in your preferred language

Highlight features on mouseover in an ArcMap tool

1083
1
03-01-2011 09:15 AM
ScottBrown
Deactivated User
Hello,

I'm looking for the recommended workflow for quickly identifying the nearest feature to the cursor in ArcMap (version 9.3 using .NET) and highlighting it.

I've tried three approaches. First I formed an envelope around the mouse in device units (pixels), and used IFocusMap.SelectByShape(..., ..., true) to fetch and highlight a single feature from the layer. Obviously this wasn't ideal.

I considered using IFeatureIndex.NearestFeature(), but I'm concerned about overhead, as each time the tool performs its function it changes the underlying features, invalidating the index.

I settled on using IFeatureSnapAgent. This quickly gives me the nearest point on the nearest feature. However, to find and highlight the feature itself seems to require an intersection search with the snapped point to fetch an IFeature. This seems redundant and inefficient.

Could someone suggest how I might efficiently highlight a feature on mouseover?

Thanks!
- Scott
0 Kudos
1 Reply
ScottBrown
Deactivated User
In the end, I used IHitTest to quickly find features, which I stored in an IFeatureCache to prevent repeated queries, and used the IScreenDisplay Draw methods for the highlight. It worked quite well.

Cheers,
- Scott
0 Kudos