Parameters
- height
- Double
Exception | Description |
---|---|
ArcGIS.Core.CalledOnWrongThreadException | This method must be called within the lambda passed to QueuedTask.Run. |
System.InvalidOperationException | This element requires its mapview to be active |
//Modify an element's hieght. //Perform on the worker thread await QueuedTask.Run(() => { double elmHeight = element.GetHeight(); elmHeight = 11; element.SetHeight(elmHeight); //You don't have to get to set; a shortcut would be: element.SetHieght(11); });
//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); });
//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