Hi there,
I am using ISnappingEnvironment for a snap to a point feature in a feature layer in ArcMap 10.3. And I draw a IMarkerElement(IMarkerSymbol) at the point of successfull snap(first position). If user clicks to far from a point (not with actual tolerance of the snap) I also draw another IMarkerElement(IMarkerSymbol) at this second position.
I am wondering how to snap to graphic that I created at the second position. Could IGraphicsLayer help in this case? I guess that snap could work with feature layers and (probably) with graphics layers?
I tried to add a graphic layer to the map, but I don't see it included in the snap:
//create IMarkerElement pMarkerElement here
...
IMap pMap = pActiveView.FocusMap;
ICompositeGraphicsLayer compositeGraphicsLayer = (ICompositeGraphicsLayer)pMap.BasicGraphicsLayer;
IGraphicsLayer graphicsLayer = null;
try
{graphicsLayer = compositeGraphicsLayer.FindLayer(strGraphicLayerName);}
catch (Exception ex) { }
if (graphicsLayer == null)
{
graphicsLayer = compositeGraphicsLayer.AddLayer(strGraphicLayerName, null);
}
graphicsLayer.Activate(pActiveView.ScreenDisplay);
pMap.ActiveGraphicsLayer = (ILayer)graphicsLayer;
pGraphicsContainer = graphicsLayer as IGraphicsContainer;
pGraphicsContainer.AddElement(pMarkerElement, 0);