ESRI.ArcGIS.ADF.IMS
ScaleBar Class
Members  Example  See Also 
ESRI.ArcGIS.ADF.IMS.Display.AcetateElement Namespace : ScaleBar Class




A specific kind of AcetateElement representing a scale bar.

Object Model



Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Class ScaleBar 
   Inherits AcetateElement
Visual Basic (Usage)Copy Code
Dim instance As ScaleBar
C# 
[SerializableAttribute()]
public class ScaleBar : AcetateElement 

Example

This example adds two scalebars to the map. The first scalebar is sized based on screen pixels and displays its length in kilometers. The second scalebar is a clone of the first scalebar, but is changed to display miles, and its length based on map distance.

Visual BasicCopy Code
' Create an acetate layer and add it to the map

Dim aceLyr As New AcetateLayer("mapGraphics")

mapView.Layers.Add(aceLyr)



' Create the font settings for the scalebar

Dim fontInfo As New FontInfo("Arial", 16, Drawing.Color.Navy, FontStyle.Italic)



' Create first scalebar and set properties

Dim scalebar As New ScaleBar(AcetateUnits.Pixel)

scalebar.Location = New Point(30, imgMap.Height.Value - 20)

scalebar.Antialiasing = True

scalebar.Color = Drawing.Color.Ivory

scalebar.Font = fontInfo

' Set scalebar to 200 pixels (screen size)

scalebar.Length = 200

scalebar.LengthUnits = ScaleBarLengthUnits.Pixel

scalebar.MapUnits = MapUnits.Degrees

scalebar.Mode = ScaleBarMode.Geodesic

scalebar.Precision = 1

scalebar.ScaleBarUnits = ScaleBarUnits.Kilometers

scalebar.TextOutlineColor = Drawing.Color.Ivory

scalebar.TextTransparency = 30

scalebar.Transparency = 30

scalebar.Width = 8



' Copy the previous scalebar to a new one

Dim scalebar2 = scalebar.Clone

scalebar2.Location = New Point(30, imgMap.Height.Value - 40)

' Set second scalebar to 5000 miles (map distance)

scalebar2.Length = 5000

scalebar2.LengthUnits = ScaleBarLengthUnits.ScaleBarUnits

scalebar2.ScaleBarUnits = ScaleBarUnits.Miles



' Add both scalebars to the acetate layer

aceLyr.AcetateElements.Add(scalebar)

aceLyr.AcetateElements.Add(scalebar2)

C#Copy Code
// Create an acetate layer and add it to the map 

AcetateLayer aceLyr = new AcetateLayer("mapGraphics"); 

mapView.Layers.Add(aceLyr); 

  

// Create the font settings for the scalebar 

FontInfo fontInfo = new FontInfo("Arial", 16, Drawing.Color.Navy, FontStyle.Italic); 

  

// Create first scalebar and set properties 

ScaleBar scalebar = new ScaleBar(AcetateUnits.Pixel); 

scalebar.Location = new Point(30, imgMap.Height.Value - 20); 

scalebar.Antialiasing = true; 

scalebar.Color = Drawing.Color.Ivory; 

scalebar.Font = fontInfo; 

// Set scalebar to 200 pixels (screen size) 

scalebar.Length = 200; 

scalebar.LengthUnits = ScaleBarLengthUnits.Pixel; 

scalebar.MapUnits = MapUnits.Degrees; 

scalebar.Mode = ScaleBarMode.Geodesic; 

scalebar.Precision = 1; 

scalebar.ScaleBarUnits = ScaleBarUnits.Kilometers; 

scalebar.TextOutlineColor = Drawing.Color.Ivory; 

scalebar.TextTransparency = 30; 

scalebar.Transparency = 30; 

scalebar.Width = 8; 

  

// Copy the previous scalebar to a new one 

Scalebar scalebar2 = scalebar.Clone(); 

scalebar2.Location = new Point(30, imgMap.Height.Value - 40); 

// Set second scalebar to 5000 miles (map distance) 

scalebar2.Length = 5000; 

scalebar2.LengthUnits = ScaleBarLengthUnits.ScaleBarUnits; 

scalebar2.ScaleBarUnits = ScaleBarUnits.Miles; 

  

// Add both scalebars to the acetate layer 

aceLyr.AcetateElements.Add(scalebar); 

aceLyr.AcetateElements.Add(scalebar2); 

    

Remarks

How the length of the scalebar is determined

  • If LengthUnits is set to Pixel, then the scalebar will be the number of pixels set with Length. The length of the scalebar will not depend on the map scale. The map distance represented by the scalebar will depend on the scale.
  • If LengthUnits is set to ScaleBarUnits, then the scalebar will be length of the map distance specified by Length in terms of the ScaleBarUnits setting. For example, if Length is set to 2000 and ScaleBarUnits is set to Feet, then the scalebar will represent 2000 feet on the map. The pixel length of this scalebar will depend on the scale of the map.

Some properties of ScaleBar are ignored by ArcMap Server image services. See individual properties for details.

Inheritance Hierarchy

System.Object
   ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.AcetateElement
      ESRI.ArcGIS.ADF.IMS.Display.AcetateElement.ScaleBar

See Also

© 2010 All Rights Reserved.