1

How do I add an existing layer to my map using ArcGIS Pro SDK?

I saw several examples where the layer is added while being created (for example

LayerFactory.Instance.CreateFeatureLayer(new Uri(strUri), map);

), however, how this is being done for, let's say, FeatureLayer from geodatabase?

3 Answers 3

3

There are lots of examples for how to do this in the help wiki. If you are trying to add a layer from a geodatabase then you would first create an object that references the gdb and then open the feature class. See here: ProConcepts Geodatabase

0

I have found the answer, so if anyone comes into this situation this is it:

LayerFactory.Instance.CopyLayer(sourceLayer, map);
0

If you have a feature class in a geodatabase then use the below, where fc is a FeatureClass object:

var layerParams = new FeatureLayerCreationParams(fc);
var layer = LayerFactory.Instance.CreateLayer<FeatureLayer>(layerParams, MapView.Active.Map);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.