public NorthArrowStyleItem NorthArrowStyleItem {get; set;}
Public Property NorthArrowStyleItem As NorthArrowStyleItem
public NorthArrowStyleItem NorthArrowStyleItem {get; set;}
Public Property NorthArrowStyleItem As NorthArrowStyleItem
//Create a north arrow for a specific map frame and assign a north arrow style item. //Construct on the worker thread await QueuedTask.Run(() => { //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 10")[0]; //Build geometry Coordinate2D center = new Coordinate2D(7, 5.5); //Reference MF, create north arrow and add to layout MapFrame mf = layout.FindElement("New Map Frame") as MapFrame; if (mf == null) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING"); return; } //At 2.x - //NorthArrow arrowElm = LayoutElementFactory.Instance.CreateNorthArrow(layout, center, mf, naStyleItm); //arrowElm.SetName("New North Arrow"); //arrowElm.SetHeight(1.75); //arrowElm.SetX(7); //arrowElm.SetY(6); var naInfo = new NorthArrowInfo() { MapFrameName = mf.Name, NorthArrowStyleItem = naStyleItm }; var arrowElm = ElementFactory.Instance.CreateMapSurroundElement( layout, center.ToMapPoint(), naInfo, "New North Arrow") as NorthArrow; arrowElm.SetHeight(1.75); arrowElm.SetX(7); arrowElm.SetY(6); });
//Create a north arrow using a style. //Search for a style project item by name StyleProjectItem arcgis2dStyles = Project.Current.GetItems<StyleProjectItem>() .First(si => si.Name == "ArcGIS 2D"); //Construct on the worker thread await QueuedTask.Run(() => { NorthArrowStyleItem naStyleItem = arcgis2dStyles.SearchNorthArrows( "ArcGIS North 13").FirstOrDefault(); //Reference the map frame and define the location MapFrame newFrame = layout.FindElement("New Map Frame") as MapFrame; Coordinate2D nArrow = new Coordinate2D(6, 2.5); //Construct the north arrow //At 2.x - var newNorthArrow = LayoutElementFactory.Instance.CreateNorthArrow( // layout, nArrow, newFrame, naStyleItem); var naInfo = new NorthArrowInfo() { MapFrameName = newFrame.Name, NorthArrowStyleItem = naStyleItem }; var newNorthArrow = ElementFactory.Instance.CreateMapSurroundElement( layout, nArrow.ToMapPoint(), naInfo); });
//Must be on QueuedTask.Run(() => { ... //Build geometry Coordinate2D center = new Coordinate2D(7, 5.5); //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 10")[0]; //Reference MF, create north arrow and add to layout //var mf = container.FindElement("New Map Frame") as MapFrame; var mf = layout.FindElement(MapFrameName) as MapFrame; var narrow_info = new NorthArrowInfo() { MapFrameName = mf.Name, NorthArrowStyleItem = naStyleItm }; var arrowElm = (NorthArrow)ElementFactory.Instance.CreateMapSurroundElement( layout, center.ToMapPoint(), narrow_info) as NorthArrow; arrowElm.SetName("New North Arrow"); arrowElm.SetHeight(1.75); arrowElm.SetX(7); arrowElm.SetY(6);
Target Platforms: Windows 11, Windows 10, Windows 8.1