Public Sub SetSnappable( _ ByVal isSnappable As Boolean _ )
public void SetSnappable( bool isSnappable )
Parameters
- isSnappable
- A boolean to toggle snappability.
Public Sub SetSnappable( _ ByVal isSnappable As Boolean _ )
public void SetSnappable( bool isSnappable )
| Exception | Description |
|---|---|
| ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(); // is the layer snappable? bool isSnappable = featureLayer.IsSnappable; // set snappability for a specific layer - needs to run on the MCT await QueuedTask.Run(() => { // use an extension method featureLayer.SetSnappable(true); // or use the CIM directly //var layerDef = fLayer.GetDefinition() as ArcGIS.Core.CIM.CIMGeoFeatureLayerBase; //layerDef.Snappable = true; //fLayer.SetDefinition(layerDef); }); // turn all layers snappability off var layerList = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>(); await QueuedTask.Run(() => { foreach (var layer in layerList) { layer.SetSnappable(false); } });
// interested in only snapping to the vertices of a specific layer of interest and not the vertices of other layers // all other snapModes should be off. // snapping must be on Snapping.IsEnabled = true; // turn all application snapModes off Snapping.SetSnapModes(null); // set application snapMode vertex on Snapping.SetSnapMode(SnapMode.Vertex, true); // ensure layer snapping is on await QueuedTask.Run(() => { featureLayer.SetSnappable(true); }); // set vertex snapping only var vertexOnly = new LayerSnapModes(false) { Vertex = true }; // set vertex only for the specific layer, clearing all others var dict = new Dictionary<Layer, LayerSnapModes>(); dict.Add(featureLayer, vertexOnly); Snapping.SetLayerSnapModes(dict, true); // true = reset other layers
{
if (!layer.IsVisible)
layer.SetVisibility(true);
if (layer is FeatureLayer featureLayerToChange)
{
if (!featureLayer.IsEditable)
featureLayer.SetEditable(true);
if (!featureLayer.IsSnappable)
featureLayer.SetSnappable(true);
}
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)