Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

In my PageLayoutControl I add a ScaleBar. Additionaly I like to show the map scale/ratio (e.g. "1:20.000") next to it, but didn't find a way to achieve this with the ScaleBar. Am I missing something or is there another way to do this?

Here is, how I add the ScaleBar:

  IEnvelope envelope = new EnvelopeClass();
  envelope.PutCoords(5, 0.1, 12.4, 1); // Specify the location and size of the scalebar
  IUID uid = new UIDClass();
  uid.Value = "esriCarto.ScaleLine";

  // Create a Surround. Set the geometry of the MapSurroundFrame to give it a location
  // Activate it and add it to the PageLayout's graphics container
  IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer;
  IActiveView activeView = pageLayout as IActiveView;
  IFrameElement frameElement = graphicsContainer.FindFrame(map);
  IMapFrame mapFrame = frameElement as IMapFrame;
  IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as UID, null);
  IElement element = mapSurroundFrame as IElement;
  element.Geometry = envelope;
  element.Activate(activeView.ScreenDisplay);
  graphicsContainer.AddElement(element, 0);
  IMapSurround mapSurround = mapSurroundFrame.MapSurround;

  IScaleBar markerScaleBar = (IScaleBar)mapSurround;
  markerScaleBar.LabelPosition = esriVertPosEnum.esriBelow;
  markerScaleBar.UseMapSettings();
share|improve this question
    
Not sure if this is the answer but there is some Java documentation on Map Surrounds that may hel at resources.esri.com/help/9.3/arcgisengine/java/engineexamples/… –  PolyGeo Oct 19 '11 at 22:40
    
@PolyGeo: Thanks, that pointed me in the right direction. See my answer. –  gumo Oct 20 '11 at 7:55
add comment

2 Answers

up vote 1 down vote accepted

ScaleText is the way to go. PolyGeo's link pointed me in the right direction. Thanks.

I use the same code as above apart from setting a ScaleText instead of a ScaleText (line 4)

uid.Value = "esriCarto.ScaleText";

and setting different Options (last paragraph):

IScaleText2 markerScaleText = (IScaleText2)mapSurround;
markerScaleText.Separator = ":";
markerScaleText.Style = esriScaleTextStyleEnum.esriScaleTextAbsolute;
share|improve this answer
add comment

As mentioned in my comment, the key information that pointed gumo in the right direction can be found in the Add Map Surrounds resource of ArcGIS Engine.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.