ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Map Class / SpatialReference Property
Example

In This Topic
    SpatialReference Property (Map)
    In This Topic
    Gets the spatial reference of the map.
    Syntax
    public SpatialReference SpatialReference {get;}
    Public ReadOnly Property SpatialReference As SpatialReference
    Example
    Zoom To a Point
    public Task<bool> ZoomToPoint(double x, double y, ArcGIS.Core.Geometry.SpatialReference spatialReference)
    {
      //Get the active map view.
      var mapView = MapView.Active;
      if (mapView == null)
        return Task.FromResult(false);
    
      return QueuedTask.Run(() =>
      {
        //Note: Run within QueuedTask
        //Create a point
        var pt = MapPointBuilderEx.CreateMapPoint(x, y, spatialReference);
        //Buffer it - for purpose of zoom
        var poly = GeometryEngine.Instance.Buffer(pt, buffer_size);
    
        //do we need to project the buffer polygon?
        if (!MapView.Active.Map.SpatialReference.IsEqual(poly.SpatialReference))
        {
          //project the polygon
          poly = GeometryEngine.Instance.Project(poly, MapView.Active.Map.SpatialReference);
        }
    
        //Zoom - add in a delay for animation effect
        return mapView.ZoomTo(poly, new TimeSpan(0, 0, 0, 3));
      });
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also