AnsweredAssumed Answered

Issue Combining ProSnippets for arcgis pro sdk

Question asked by mrs_robbins on Jan 17, 2019
Latest reply on Jan 18, 2019 by mrs_robbins

I am trying to use two ProSnippets within a SINGLE ArcGIS Pro tool and need help.  Here are the two snippets, but I cannot seem to make them both work within a single tool.  I did this within an Add-In tool in ArcGIS Desktop, but I'm not sure what is going on with Pro.  Can anyone steer me in the right direction.  I want a single click to give me  Coordinates AND access to the underlying layers.  (Once coded, I don't really need the info in MessageBoxes)

 

Create a tool to the return coordinates of the point clicked in the map

internal class GetMapCoordinates : MapTool

{

    protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e)

    {

        if (e.ChangedButton == System.Windows.Input.MouseButton.Left)

            e.Handled = true; //Handle the event args to get the call to the corresponding async method

    }

     protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e)

    {        return QueuedTask.Run(() =>

        {

        //Convert the clicked point in client coordinates to the corresponding map coordinates.

        var mapPoint = MapView.Active.ClientToMap(e.ClientPoint);

            ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(string.Format("X: {0} Y: {1} Z: {2}",                mapPoint.X, mapPoint.Y, mapPoint.Z), "Map Coordinates");

        });

    }

}

 

Create a tool to identify the features that intersect the sketch geometry

internal class CustomIdentify : MapTool

{    public CustomIdentify()

    {

        IsSketchTool = true;

        SketchType = SketchGeometryType.Point;  //In the Snippet this is Rectangle, I just want it the point.

         //To perform a interactive selection or identify in 3D or 2D, sketch must be created in screen coordinates.

        SketchOutputMode = SketchOutputMode.Screen;

    }

     protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)

    {        return QueuedTask.Run(() =>

        {

            var mapView = MapView.Active;

            if (mapView == null)

                return true;

         //Get all the features that intersect the sketch geometry and flash them in the view.

        var results = mapView.GetFeatures(geometry);

            mapView.FlashFeature(results);

         //Show a message box reporting each layer the number of the features.

        MessageBox.Show(

            String.Join("\n", results.Select(kvp => String.Format("{0}: {1}", kvp.Key.Name, kvp.Value.Count()))),

            "Identify Result");

            return true;

        });

    }

}

Outcomes