Select to view content in your preferred language

How to add scale (not scale bar) to a layout?

518
1
Jump to solution
10-25-2023 01:38 AM
ViktorSafar
Frequent Contributor

I can get the value from the map and put it into a text element. But that will require me to write more logic handling the scale changes. Is there a component I can use? 

0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

You can create a Dynamic Text element to write out the Map Frame's scale. 

 

var layout = LayoutView.Active.Layout;
if (layout == null)
  return;
//Construct the dynamic text string.
//You can create the dynamic text in the UI to get a hint as to how to compose the string in code.
String title = @"Scale: <dyn type=""mapFrame"" name=""Map Frame"" property=""scale"" preStr=""1:""/>";
Coordinate2D llTitle = new Coordinate2D(6, 2.5);
await QueuedTask.Run( () => {
  TextElement titleGraphics = ElementFactory.Instance.CreateTextGraphicElement(
                layout, TextType.RectangleParagraph, llTitle.ToMapPoint(), null, title) as TextElement;
});

View solution in original post

0 Kudos
1 Reply
UmaHarano
Esri Regular Contributor

You can create a Dynamic Text element to write out the Map Frame's scale. 

 

var layout = LayoutView.Active.Layout;
if (layout == null)
  return;
//Construct the dynamic text string.
//You can create the dynamic text in the UI to get a hint as to how to compose the string in code.
String title = @"Scale: <dyn type=""mapFrame"" name=""Map Frame"" property=""scale"" preStr=""1:""/>";
Coordinate2D llTitle = new Coordinate2D(6, 2.5);
await QueuedTask.Run( () => {
  TextElement titleGraphics = ElementFactory.Instance.CreateTextGraphicElement(
                layout, TextType.RectangleParagraph, llTitle.ToMapPoint(), null, title) as TextElement;
});
0 Kudos