Making a group layer (or layer) in memory

562
6
Jump to solution
04-16-2020 10:12 AM
Vidar
by
Occasional Contributor II

I know you can use this method for creating a group layer:

   LayerFactory.Instance.CreateGroupLayer(map, 0, "mygrouplayer");

This seems to instantly create a group layer in the map, but, is there a way to create a group layer without it being instantly created and then add it in later?, i.e. create it in memory first.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

The links should work now. I have edited the typos.  

Also, in the ProSnippets: Map Authoring page there are 3 code snippets that use the LayerDocument to configure Feature Layers prior to adding it to the map. They create FeatureLayers, but the concept to create Group Layers is similar.

Thanks

View solution in original post

0 Kudos
6 Replies
KirkKuykendall2
Occasional Contributor

Have you considered creating a CIMGroupLayer, populating it with what you need, then turning it into a layer by calling CreateGroupLayer followed by GroupLayer.SetDefinition ?

0 Kudos
Vidar
by
Occasional Contributor II

Not in the slightest  - wasn't aware of that at all - but I will have a dig around on what you describe.

Thanks Kirk.

0 Kudos
UmaHarano
Esri Regular Contributor

Hi Simon

LayerDocument class allows you to configure a layer's properties prior to adding it to the map.  You can either create a new LayerDocument (using the available constructors) from an existing lyrx file or an existing feature layer in a map. Note: You also have the option of creating a blank LayerDocument and configuring all the properties from scratch if you want. But this is rare.

You can then use the configured LayerDocument and Create a layer (or Group Layer)  using the CreateLayer method. The specific overload you will need is this:

https://pro.arcgis.com/en/pro-app/sdk/api-reference/index.html#topic26527.html 

I will post a snippet on how to do this if you need further help with this.

Thanks

Uma

0 Kudos
Vidar
by
Occasional Contributor II

Hi

The link https://pro.arcgis.com/en/pro-app/sdk/api-reference/index.html#topic26527.html

doesn't seem to work - I get the following in the browser:

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

The link seems to be different

Your link as shown

 https://pro.arcgis.com/en/pro-app/sdk/api-reference/index.html#topic26527.html

Where it links to

" https://prodev.arcgis.com/en/pro-app/sdk/api-reference/index.html#topic26527.html "

when you examine its link versus the text.

Try editing the link to see if that is the issue

0 Kudos
UmaHarano
Esri Regular Contributor

The links should work now. I have edited the typos.  

Also, in the ProSnippets: Map Authoring page there are 3 code snippets that use the LayerDocument to configure Feature Layers prior to adding it to the map. They create FeatureLayers, but the concept to create Group Layers is similar.

Thanks

0 Kudos