ScaleBar control


In this topic


About the ScaleBar control

Use the ScaleBar control to create a scale bar shown on a map. By default, the scale bar is rendered on the client using dynamic Hypertext Markup Language (HTML) and JavaScript. This provides a consistent view regardless of data sources used on the map and does not require an explicit server request to render again. 
Some properties, such as color, font, height, and units on a scale bar can be modified via public properties. If rendered on the server, the appearance of the scale bar is determined by the type of primary map resource in the Map control buddied with the ScaleBar control.  
ArcGIS for Server and ArcIMS map services can generate scale bar images. The following illustration shows differences in a scale bar's appearance based on the resource type:
The scale bar can report incorrect scales if the map resource reports incorrect units. For example, if using an ArcIMS service and the ArcXML definition file for the service contains no or incorrect map units, the scale can be incorrect on the scale bar.

Using the control

Do the following to use the control:
  1. To add controls to the page, open or create a Web site in Visual Studio. Open a Web form in design mode, select the Toolbox panel, and expand the ArcGIS Web Controls tab. Drag and drop a MapResourceManager control, Map control, and ScaleBar control onto the Web form.
  2. Add one or more resources to the MapResourceManager and set the Map control's MapResourceManager property to Map1. See the following screen shot that shows the page in Visual Studio:


  3. To set ScaleBar control properties, select the ScaleBar control. Do the following on the Properties page: 
    1. Set the Map property to Map1 on the Map control previously added. 
    2. By default, the RenderOnClient property is set to true, which indicates the scale bar is rendered on the client using HTML and JavaScript. If set to false, a scale bar image is generated by an ArcGIS for Server or ArcIMS map service (usually, this property is set to true).    
    3. Set the BarUnits property to the units (options are, Feet, Kilometers, Meters, and Miles) for the scale bar.
    4. Set the Width property to the width for the scale bar (or resize the control on the design page by clicking and dragging the edges). The width includes the scale bar and the distance text.
    5. Additional properties can be configured to change the scale bar's appearance, which includes the following:
      • BarFont—Font properties for the scale bar's text.
      • BackColor—Background color of the scale bar. The default is transparent.
      • BarColor—Bar color of the scale bar image.
      • ForeColor—Color of the scale bar's text.
      • Height—Height of the ScaleBar control, including the bar, text, and background.

        See the following screen shot that shows the additional properties:

Members

The following table shows a list of properties related to the ScaleBar control. For more information, see the ScaleBar control in the Library Reference section.
Property name
Type
Description
BackColor
color
Background color of the ScaleBar control.
BarColor
color
Bar color of the scale bar image.
BarFont
font
Font used for the scale bar's text labels.
BarHeight
int
Scale bar's height in points (1/72 inch).
BarUnits
ScaleBarUnits
Units of the scale bar to report.
ForeColor
color
Color of the scale bar's text.
Height
unit
Height of the ScaleBar control.
Map
string
Map control associated with the ScaleBar control.
RenderOnClient
bool
Determines if the service associated with the primary map resource generates a scale bar image (false) or if dynamic HTML and JavaScript are used to render the scale bar on the client (true).
RequestMimeData
bool
Gets or sets a value indicating whether Mime data for the image should be requested.
Width
unit
Width of the ScaleBar control.


See Also:

Web controls
Customizing the Web Mapping Application




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
  • ESRI.ArcGIS.ADF.Web.UI.WebControls