//Set the extent of a map frame to a bookmark. //Perform on the worker thread await QueuedTask.Run(() => { //Reference MapFrame MapFrame mf_bk = layout.FindElement("Map Frame") as MapFrame; //Reference a bookmark that belongs to a map associated with the map frame Map m = mf_bk.Map; Bookmark bk = m.GetBookmarks().FirstOrDefault(item => item.Name.Equals("Lakes")); //Set the map frame extent using the bookmark mf_bk.SetCamera(bk); });
//Set the extent of a map frame to the envelope of a feature. //Perform on the worker thread await QueuedTask.Run(() => { //Reference MapFrame MapFrame mf_env = layout.FindElement("Map Frame") as MapFrame; //Get map and a layer of interest Map m = mf_env.Map; //Get the specific layer you want from the map and its extent FeatureLayer lyr = m.FindLayers("GreatLakes").First() as FeatureLayer; Envelope lyrEnv = lyr.QueryExtent(); //Set the map frame extent to the feature layer's extent / envelope mf_env.SetCamera(lyrEnv); //Note - you could have also used the lyr as an overload option });
//Create a new table frame on the active layout. Layout layout = LayoutView.Active.Layout; //Perform on the worker thread await QueuedTask.Run(() => { //Build 2D envelope geometry Coordinate2D rec_ll = new Coordinate2D(1.0, 3.5); Coordinate2D rec_ur = new Coordinate2D(7.5, 4.5); //At 2.x - Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur); Envelope rec_env = EnvelopeBuilderEx.CreateEnvelope(rec_ll, rec_ur); //Reference map frame MapFrame mf = layout.FindElement("Map Frame") as MapFrame; //Reference layer Map m = mf.Map; FeatureLayer lyr = m.FindLayers("GreatLakes").First() as FeatureLayer; //Build fields list var fields = new[] { "NAME", "Shape_Area", "Shape_Length" }; //Construct the table frame //At 2.x - TableFrame tabFrame = LayoutElementFactory.Instance.CreateTableFrame(layout, rec_env, mf, lyr, fields); var surroundInfo = new TableFrameInfo() { FieldNames = fields, MapFrameName = mf.Name, MapMemberUri = lyr.URI }; var tabFrame = ElementFactory.Instance.CreateMapSurroundElement(layout, rec_env, surroundInfo) as TableFrame; });
//Zoom map frame to the extent of a single layer. //Perform on the worker thread await QueuedTask.Run(() => { //Reference MapFrame MapFrame mf = layout.FindElement("Map Frame") as MapFrame; //Reference map and layer Map m = mf.Map; FeatureLayer lyr = m.FindLayers("GreatLakes").First() as FeatureLayer; //Set the map frame extent to all features in the layer mf.SetCamera(lyr, false); });
Target Platforms: Windows 11, Windows 10