public void SetSnappable( bool isSnappable )
Public Sub SetSnappable( _ ByVal isSnappable As Boolean _ )
Parameters
- isSnappable
- A boolean to toggle snappability.
public void SetSnappable( bool isSnappable )
Public Sub SetSnappable( _ ByVal isSnappable As Boolean _ )
Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This method or property must be called within the lambda passed to QueuedTask.Run. |
// is the layer snappable? bool isSnappable = fLayer.IsSnappable; // set snappability for a specific layer - needs to run on the MCT await QueuedTask.Run(() => { // use an extension method fLayer.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 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 ArcGIS.Desktop.Mapping.Snapping.IsEnabled = true; // turn all application snapModes off //At 2.x - ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(); ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(null); // set application snapMode vertex on ArcGIS.Desktop.Mapping.Snapping.SetSnapMode(SnapMode.Vertex, true); // ensure layer snapping is on await QueuedTask.Run(() => { fLayer.SetSnappable(true); }); // set vertex snapping only var vertexOnly = new LayerSnapModes(false); vertexOnly.Vertex = true; // set vertex only for the specific layer, clearing all others var dict = new Dictionary<Layer, LayerSnapModes>(); dict.Add(fLayer, vertexOnly); ArcGIS.Desktop.Mapping.Snapping.SetLayerSnapModes(dict, true); // true = reset other layers
if (!layer.IsVisible) layer.SetVisibility(true); if (layer is FeatureLayer featureLayer) { if (!featureLayer.IsEditable) featureLayer.SetEditable(true); if (!featureLayer.IsSnappable) featureLayer.SetSnappable(true); }
Target Platforms: Windows 11, Windows 10, Windows 8.1