ArcObjects Library Reference (Carto)  

IMapServer2.ExportScaleBar Method

Exports a scale bar to an image file. The client can create the scaleBar object and set its desired properties appropriately. If scaleBar is Nothing/Null, a default scale bar will be generated.

[Visual Basic .NET]
Public Function ExportScaleBar ( _
    ByVal Scalebar As IScaleBar, _
    ByVal mapDesc As IMapDescription, _
    ByVal pMapDisplay As IImageDisplay, _
    ByVal BackgroundColor As IColor, _
    ByVal imageDesc As IImageDescription _
) As IImageResult
public IImageResult ExportScaleBar (
    IScaleBar Scalebar,
    IMapDescription mapDesc,
    IImageDisplay pMapDisplay,
    IColor BackgroundColor,
    IImageDescription imageDesc
HRESULT ExportScaleBar(
  IScaleBar* Scalebar,
  IMapDescription* mapDesc,
  IImageDisplay* pMapDisplay,
  IColor* BackgroundColor,
  IImageDescription* imageDesc,
  IImageResult** ImageResult


Scalebar [in]

  Scalebar is a parameter of type IScaleBar

mapDesc [in]

  mapDesc is a parameter of type IMapDescription

pMapDisplay [in]

  pMapDisplay is a parameter of type IImageDisplay

BackgroundColor [in]

  BackgroundColor is a parameter of type IColor

imageDesc [in]

  imageDesc is a parameter of type IImageDescription

ImageResult [out, retval]

  ImageResult is a parameter of type IImageResult

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


Use ExportScaleBar to retrieve the map's scale bar. To customize the scale bar pass in a ScaleBar object. If you pass in Nothing/Null for the input paramter ScaleBar, a default alternating scale bar is drawn. The scale is calculated according to the height and width of the the image (pMapDisplay). This ImageDisplay object refers to the map. Another ImageDisplay object will be used (as part of the imageDesc parameter) that refers to the Scale Bar image. A color background can be set for the ScaleBar swatch by using the backgroundColor parameter. If this is Nothing/Null a white background will be used. Use TransparentColor in IImageDisplay2 if you want the background to be transparent. Size, resolution and file format are determined by ImageDescription, which includes ImageDisplay and ImageType. ExportScaleBar returns an ImageResult object.

Use the height and width properties of IImageDisplay (as part of the imageDesc parameter) to set the proper size of the scalebar. Entering a 0 for either the height or the width for ExportScaleBar output results in an error.

See Also

IMapServer2 Interface