예제 #1
0
        protected async void SetSnapping()
        {
            var myMap = MapView.Active.Map;

            //using ArcGIS.Desktop.Mapping
            //enable snapping
            Snapping.IsEnabled = true;

            //enable a snap mode, others are not changed.
            Snapping.SetSnapMode(SnapMode.Point, true);

            //set multiple snap modes exclusively. All others will be disabled.
            Snapping.SetSnapModes(SnapMode.Edge, SnapMode.Point);

            await QueuedTask.Run(() =>
            {
                //set snapping options via get/set options
                var snapOptions = Snapping.GetOptions(myMap);
                snapOptions.SnapToSketchEnabled = true;
                snapOptions.XYTolerance         = 100;
                Snapping.SetOptions(myMap, snapOptions);
            });


            var myFeatureLayer = MapView.Active.GetSelectedLayers().First() as FeatureLayer;

            //read snapping availability for a layer
            var canSnap = myFeatureLayer.IsSnappable;

            //set snapping availability for a layer
            var featLayerDef = myFeatureLayer.GetDefinition() as ArcGIS.Core.CIM.CIMGeoFeatureLayerBase;

            featLayerDef.Snappable = true;
            myFeatureLayer.SetDefinition(featLayerDef);
        }