ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Map Class / GetLocationUnitFormat Method
Example

In This Topic
    GetLocationUnitFormat Method
    In This Topic
    Gets the current map location unit format for the current project. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    Map location unit formats are used to format the coordinate system display at the bottom of the map or scene as well as format the scale combo box.
    Display units
    Example
    Get the Current Map Location Unit
    //var map = MapView.Active.Map;
    //Must be on the QueuedTask.Run()
    
    //Get the current location unit
    var loc_unit = map.GetLocationUnitFormat();
    var line = $"{loc_unit.DisplayName}, {loc_unit.UnitCode}";
    System.Diagnostics.Debug.WriteLine(line);
    
    Format a Location Using the Current Map Location Unit
    var mv = MapView.Active;
    var map = mv.Map;
    
    QueuedTask.Run(() =>
    {
      //Get the current view camera location
      var center_pt = new Coordinate2D(mv.Camera.X, mv.Camera.Y);
      //Get the current location unit
      var loc_unit = map.GetLocationUnitFormat();
    
      //Format the camera location
      var str = loc_unit.FormatLocation(center_pt, map.SpatialReference);
      System.Diagnostics.Debug.WriteLine($"Formatted location: {str}");
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also