Adding multiple feature layers from the same feature service

05-07-2018 07:08 AM
New Contributor

In my addin, I can successfully add a feature layer from a feature server to the current map using the LayerFactory, for example, adding layer 0:


LayerFactory.Instance.CreateFeatureLayer(new Uri("http://localhost:port/.../FeatureServer/0"), map);


If I try to add a different layer (from the same server), say layer 1, such as:


LayerFactory.Instance.CreateFeatureLayer(new Uri("http://localhost:port/.../FeatureServer/1"), map);


The function returns null.  Using a tool like Fiddler shows that ArcGIS does not even attempt to contact the server given the URL.


Is there a particular process one should follow when adding feature layers from the same feature server?

0 Kudos
2 Replies
Esri Regular Contributor

Try using the path to the FeatureServer itself. You should get a parent composite layer ("group") that contains all of the individual layer end points (however many there are).

LayerFactory.Instance.CreateLayer(new Uri("http://....url here.../FeatureServer", UriKind.Absolute), MapView.Active.Map);
New Contributor

Thanks for the response, Charles.  Adding the feature server does create a group layer containing all the feature layers.

A follow-up question: it is possible for the FeatureServer to get updated with a new layer.  How would I add this new layer to the group, or somehow "refresh" the group layer for any new layers?  I tried something like:

// groupLayer = the existing group layer

// "layer 5" is the newly available layer in the FeatureServer

LayerFactory.Instance.CreateLayer(new Uri("http://... url here.../FeatureServer/5"), groupLayer);

But returns null as before.

0 Kudos