ArcGIS Pro二次开发-插入文本,图例和指北针
// Add text for title Coordinate2D titleTxt_ll = new Coordinate2D(4.5, 9.5); CIMTextSymbol arial36bold = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlueRGB, 80, "Arial", "Bold"); GraphicElement titleTxtElm = LayoutElementFactory.Instance.CreatePointTextGraphicElement(newLayout, titleTxt_ll, "Census Data", arial36bold); titleTxtElm.SetName("Title"); // Add north arrow // Reference a North Arrow in a style StyleProjectItem stylePrjItm = Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(item => item.Name == "ArcGIS 2D"); NorthArrowStyleItem naStyleItm = stylePrjItm.SearchNorthArrows("ArcGIS North 8")[0]; // Set the center coordinate and create the arrow on the layout Coordinate2D center = new Coordinate2D(15, 7); NorthArrow arrowElm = LayoutElementFactory.Instance.CreateNorthArrow(newLayout, center, newMapframe, naStyleItm); arrowElm.SetName("New North Arrow"); arrowElm.SetHeight(2);
// Add legend - first build 2D envelope geometry Coordinate2D leg_ll = new Coordinate2D(13.5, 0.5); Coordinate2D leg_ur = new Coordinate2D(16.5, 4.0); Envelope leg_env = EnvelopeBuilder.CreateEnvelope(leg_ll, leg_ur); // Create legend Legend legendElm = LayoutElementFactory.Instance.CreateLegend(newLayout, leg_env, newMapframe); legendElm.SetVisible(true); legendElm.SetName("New Legend"); return newLayout; }); var layoutPane = await ProApp.Panes.CreateLayoutPaneAsync(newLayout);