GetLocationUnitFormat Method
Gets the current map location unit format for the current project. This method must
be called on the MCT. Use QueuedTask.Run.
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}");
});
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.