I am evaluating moving an existing ArcMap project to ArcGIS Pro. I need to see if there is an example of how to do this with the ArcGIS Pro SDK. I have a wizard in ArcMap where one of the steps is a screen display with a map with a layer for the user to select features for the particular polygon layer. I used the AxMapControl and AxToolbarControl to allow the user to do this selection. If I move it over to ArcGIS Pro, I would need to have the same capabilities. I was wondering if this is possible to do, or if I need to look at an additional developer api to make this work in the application. Is there any examples or documentation on how to do this?
Steve
Hi,
Take a look at these links:
ArcMap addin migration to Pro - Esri Community
Solved: ArcObjects SDK To ArcGIS Pro SDK Conversion Guide - Esri Community
ArcGIS Pro has MapControl too.
Esri ArcGIS Pro sdk community samples with MapControl here:
Thank you for the suggested articles, they were helpful, but I am now stuck with how to enable the selection of an item on the map. If I can figure out how to get something similar to the identify tool to work with the map control, then I think I have a complete path in order to get 90% of the functionality I need. I appreciate the help you have given me on this.
Steve
Explore Esri ArcGIS Pro sdk community samples.
OK, I looked at the code you suggested, which was helped a little bit further. Now, I have the following code:
var uri = new Uri(out_feature_class); // out_feature_class = 'C:\db\test.gdb\resultsInfo'
var featureLayerParams = new FeatureLayerCreationParams(uri);
FeatureLayer featureLayer = null;
Map currentMap = null;
try
{
await QueuedTask.Run(() =>
{
currentMap = MapFactory.Instance.CreateMap("tempMap", basemap: Basemap.None);
//TODO: use the map...
});
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
// now I assign the map I just created to the ViewContent of mapcontrol to display it
mapControl.ViewContent = MapControlContentFactory.Create(currentMap,initialExtent, MapViewingMode.Map);
await QueuedTask.Run(() =>
{
featureLayer = LayerFactory.Instance.CreateLayer<FeatureLayer>(featureLayerParams, currentMap);
}); // to add the layer to the created map that was added to the mapcontrol
The next step was to create a tool to allow for selecting one or more polygons from the results layer:
I took the code from the above example:
class SelectAndZoom : MapTool
{
/// <summary>
/// Constructor
/// </summary>
public SelectAndZoom()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Rectangle; // rectangle sketch tool
SketchOutputMode = SketchOutputMode.Screen;
}
/// <summary>
/// On sketch completion select the intersecting features and zoom
/// </summary>
/// <param name="geometry"></param>
/// <returns></returns>
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
return QueuedTask.Run(() =>
{
//select features that intersect the sketch geometry
var selection = MapView.Active.SelectFeatures(geometry, SelectionCombinationMethod.New);
//zoom to selection
return MapView.Active.ZoomToAsync(selection, TimeSpan.FromSeconds(1.5), true);
});
}
However, the OnSketchCompleteAsync never executes, even if I just try to change this to be just a single point select by changing SketchType to Point and CompleteSketchOnMouseUp= true. I believe the problem is that it does not capture the map control's map view (which is defined in its own dialog box). It appears that I need to have it attach to the mapcontrol's map or mapview, but I do see how to change it from MapView.Active to the mapControl.GetMap() or mapControl.GetMapView() or even to mapControl.GetMapView().ToMapView().
I am stuck at this juncture, since all this does, including setting ActivateSelectAsync(true) in the constructor of the tool and cause the mapcontrol to pan and zoom.
Take a look at Magnifier_MapTool how to bind your tool to mapcontrol