Select to view content in your preferred language

Create Text Point Element -

433
2
Jump to solution
07-07-2022 11:36 AM
PeteVitt
Frequent Contributor

Hi I'm having trouble with the Create Point Text Element 1 code snippet: 

https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-Layouts#create-point-text-element-1

on this line:

var ptTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
    container, TextType.PointText, coord2D.ToMapPoint(), sym, textString,
                       "New Point Text", true, elemInfo);

for 'container' variable I'm getting an error: The name 'container' does not exist in the current context.  As I look at the snippet I don't see that container has been defined above this point

Thanks

Pete

0 Kudos
1 Solution

Accepted Solutions
CharlesMacleod
Esri Regular Contributor

when creating graphic elements, container can be one of:

a layout - eg var container = LayoutView.Active.Layout;

a graphicslayer - eg var container = MapView.Active.Map.GetLayersAsFlattenedList().OfType<GraphicsLayer>().First();

a group element. - eg var container = layout.GetElementsAsFlattenedList().OfType<GroupElement>().First();

View solution in original post

2 Replies
CharlesMacleod
Esri Regular Contributor

when creating graphic elements, container can be one of:

a layout - eg var container = LayoutView.Active.Layout;

a graphicslayer - eg var container = MapView.Active.Map.GetLayersAsFlattenedList().OfType<GraphicsLayer>().First();

a group element. - eg var container = layout.GetElementsAsFlattenedList().OfType<GroupElement>().First();

PeteVitt
Frequent Contributor

thanks.  using layout as container worked

0 Kudos