A specific kind of AcetateElement representing a scale bar.
Object Model
Syntax
Visual Basic (Usage) | Copy Code |
---|
Dim instance As ScaleBar |
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 Basic | Copy 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
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also