ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Core.UnitFormats Namespace / DisplayUnitFormat Class / FormatLocation Method / FormatLocation(MapPoint) Method
Example

In This Topic
    FormatLocation(MapPoint) Method
    In This Topic
    Format the input location using the location unit format. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overloads Function FormatLocation( _
       ByVal location As MapPoint _
    ) As String
    public string FormatLocation( 
       MapPoint location
    )

    Parameters

    location

    Return Value

    A formatted location string
    Exceptions
    ExceptionDescription
    location
    This method or property must be called within the lambda passed to QueuedTask.Run
    Remarks
    The UnitFormatType must be of type UnitFormatType.Location or an empty string will be returned.
    If the spatial reference of the MapPoint is null then WGS84 is assumed.
    Example
    Format a Location Using the Current Map Location Unit
    {
        //Get the current view camera location
        var center_pt = new Coordinate2D(mapView.Camera.X, mapView.Camera.Y);
        //Get the current location unit
        //Note: Must be on the QueuedTask.Run()
        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 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also