ArcObjects Library Reference  (Carto)    

IMap.MapUnits Property

The units for the map.

[Visual Basic 6.0]
Property MapUnits As esriUnits
[Visual Basic .NET]
Public Property MapUnits As esriUnits
[C#]
public esriUnits MapUnits {get; set;}
[Java]
public  getMapUnits (
    esriUnits unitsCode
)
[Java]
public void setMapUnits(
    esriUnits unitsCode
)
throws
    IOException,
    AutomationException
[C++]
HRESULT get_MapUnits(
  esriUnits* unitsCode
);
[C++]
HRESULT put_MapUnits(
  esriUnits unitsCode

);

[C++]

Parameters

unitsCode [out, retval]

  unitsCode is a parameter of type esriUnits

unitsCode [in]

  unitsCode is a parameter of type esriUnits

Product Availability

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

Remarks

MapUnits is the predefined enumeration (esriUnits) data type currently associated with the Map object.
AddLayer automatically attempts to set the Map's SpatialReference property if a coordinate system has not yet been defined for the map.  When the SpatialReference property is set, the Map's MapUnits and DistanceUnits properties are set as well.
When multiple layers are added simultaneously with AddLayers, the first spatial reference found is used.
If no layers have a spatial reference, AddLayer checks the extent of the first layer (ILayer::AreaOfInterest) and if it has coordinates that look like geographic coordinates (XMin >= -180 and XMax <= 180 and YMin >= -90 and YMax <= 90), ArcMap assumes the data is in decimal degrees and sets the MapUnits to esriDecimalDegrees and DistanceUnits to esriMiles.
If no spatial reference is found and the coordinates do not look like geographic coordinates, ArcMap sets no spatial reference and sets the MapUnits to esriMeters and the DistanceUnits to esriMeters.
[Visual Basic 6.0]
The MapUnits property is really a shortcut to IDisplayTransformation::Units.  Below is a simple VBA example that demonstates this.
Sub CompareMapUnits()
    Dim pMxDocument As IMxDocument
    Dim pMap As IMap
    Dim pSpatialReference As ISpatialReference
    Dim pProjectedCoordinateSystem As IProjectedCoordinateSystem
    Dim pLinearUnit As ILinearUnit
    Dim pSpatialReferenceInfo As ISpatialReferenceInfo
   
    Set pMxDocument = Application.Document
    Set pMap = pMxDocument.FocusMap
    MsgBox pMap.MapUnits
   
    Set pSpatialReference = pMap.SpatialReference
    Set pProjectedCoordinateSystem = pSpatialReference 'QI
    Set pLinearUnit = pProjectedCoordinateSystem.CoordinateUnit
    Set pSpatialReferenceInfo = pLinearUnit 'QI
    MsgBox pSpatialReferenceInfo.FactoryCode
   
End Sub

Here are how the factory codes translate.

    9001:  // PE_U_METER
    9031:  // PE_U_METER_GERMAN
    esriMeters   9002:  // PE_U_FOOT
    9003:  // PE_U_FOOT_MA
    9004:  // PE_U_FOOT_MA
    9005:  // PE_U_FOOT_CLARKE
    9006:  // PE_U_FOOT_INDIAN
    9032:  // PE_U_FOOT_SEARS
    esriFeet     9012: //PE_U_YARD_SEARS     9013:  //PE_U_YARD_INDIAN     esriYards     case 9030:  // PE_U_NAUTICAL_MILE     esriMiles     9102:  // PE_U_DEGREE     esriDecimalDegrees

See Also

IMap Interface

 


Feedback Send feedback on this page