<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Finding the Lat/Long of the centerpoint of current map view. in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1617991#M12947</link>
    <description>&lt;P&gt;Here is what I have so far, in C#:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;await QueuedTask.Run(() =&amp;gt;
{
    var extent = MapView.Active.Extent;
    MapPoint mapPoint = MapPointBuilder.CreateMapPoint(
        (extent.XMax - extent.XMin) / 2 + extent.XMin,
        (extent.YMax - extent.YMin) / 2 + extent.YMin,
        MapView.Active.Map.SpatialReference
    );

    MessageBox.Show($"Latitude: {mapPoint.Y}\nLongitude: {mapPoint.X}", "Coordinates", MessageBoxButton.OK, MessageBoxImage.Information);
});&lt;/LI-CODE&gt;&lt;P&gt;For a specific location in Fairbanks, Alaska, this gives me:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RogerAsbury_0-1748024667430.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/133130iEBD2E8CDF2501B9D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RogerAsbury_0-1748024667430.png" alt="RogerAsbury_0-1748024667430.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, I would expect something more along the lines of&amp;nbsp;&lt;/P&gt;&lt;P&gt;Latitude: 64.8614161192099&lt;/P&gt;&lt;P&gt;Longitude: -147.90539636224&lt;/P&gt;&lt;P&gt;My guess is that in your vb code, lines 8-17 perform that conversion, but I'm uncertain how to do that in C#. The library names/classes appear to be different? My lack of knowledge on the various spatial reference types is probably not helping.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 23 May 2025 18:27:33 GMT</pubDate>
    <dc:creator>RogerAsbury</dc:creator>
    <dc:date>2025-05-23T18:27:33Z</dc:date>
    <item>
      <title>Finding the Lat/Long of the centerpoint of current map view.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1617822#M12945</link>
      <description>&lt;P&gt;I'm trying to convert some old VB code into C#, and unsure of how to proceed with code that does that task mentioned in the subject. Below is the old vb code. My problem being that I do not know the modern .net sdk equivalents for the calls in C#. It seems like it should be pretty simple to get the view extent and calculate the center, but apparently, it's a bit more involved then I expected. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Try 'TRY TO GET THE CENTER SCREEN LOCATION FROM THE ACTIVE VIEW, JUST SHOW THE FORM ON ERROR

            Dim pPoint As ESRI.ArcGIS.Geometry.IPoint
            pPoint = New ESRI.ArcGIS.Geometry.Point
            pPoint.X = (m_pArcMapAV.Extent.XMax - m_pArcMapAV.Extent.XMin) / 2 + m_pArcMapAV.Extent.XMin
            pPoint.Y = (m_pArcMapAV.Extent.YMax - m_pArcMapAV.Extent.YMin) / 2 + m_pArcMapAV.Extent.YMin

            Dim pGeoCoordSystem As ESRI.ArcGIS.Geometry.ISpatialReference
            Dim pProjCoordSystem As ESRI.ArcGIS.Geometry.ISpatialReference
            Dim pGeoTrans As ESRI.ArcGIS.Geometry.IGeoTransformation
            Dim pSpatRefFact As ESRI.ArcGIS.Geometry.ISpatialReferenceFactory


            pSpatRefFact = New ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment
            pGeoCoordSystem = pSpatRefFact.CreateGeographicCoordinateSystem(ESRI.ArcGIS.Geometry.esriSRGeoCSType.esriSRGeoCS_WGS1984)
            pProjCoordSystem = pSpatRefFact.CreateProjectedCoordinateSystem(ESRI.ArcGIS.Geometry.esriSRProjCSType.esriSRProjCS_NAD1983SPCS_AK3FT)
            pGeoTrans = pSpatRefFact.CreateGeoTransformation(ESRI.ArcGIS.Geometry.esriSRGeoTransformationType.esriSRGeoTransformation_NAD1983_To_WGS1984_2)

            Dim pGeo As ESRI.ArcGIS.Geometry.IGeometry2
            pGeo = pPoint

            pGeo.SpatialReference = pProjCoordSystem

            pGeo.ProjectEx(pGeoCoordSystem, ESRI.ArcGIS.Geometry.esriTransformDirection.esriTransformForward, pGeoTrans, 0, 0, 0)
            Me.tbxLat.Text = CStr(pPoint.Y)
            Me.tbxLon.Text = CStr(pPoint.X)

        Catch ex As Exception
            'DO NOTHING
        End Try&lt;/LI-CODE&gt;&lt;P&gt;Also, lol at the code paste feature not having a vb option.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 May 2025 22:47:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1617822#M12945</guid>
      <dc:creator>RogerAsbury</dc:creator>
      <dc:date>2025-05-22T22:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Lat/Long of the centerpoint of current map view.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1617855#M12946</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;There is one sample project for VB in Esri Community ArcGIS Pro Samples. Solution is &lt;A href="https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Geometry/Constructing-Geometries/ConstructingGeometries_VB" target="_self"&gt;here&lt;/A&gt;. Try code below for your functionality:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;        Try 'TRY TO GET THE CENTER SCREEN LOCATION FROM THE ACTIVE VIEW, JUST SHOW THE FORM ON ERROR
            Dim areaOfInterest = MapView.Active.Extent

            Dim pPoint As MapPoint
            pPoint = MapPointBuilderEx.CreateMapPoint((areaOfInterest.XMax - areaOfInterest.XMin) / 2 + areaOfInterest.XMin,
                (areaOfInterest.YMax - areaOfInterest.YMin) / 2 + areaOfInterest.YMin, MapView.Active.Map.SpatialReference)

            Dim pGeoCoordSystem As SpatialReference
            Dim pProjCoordSystem As SpatialReference
            Dim pGeoTrans As ProjectionTransformation

            pGeoCoordSystem = SpatialReferenceBuilder.CreateSpatialReference(SpatialReferences.WGS84)
            pProjCoordSystem = SpatialReferenceBuilder.CreateSpatialReference(102633)

            pGeoTrans = ProjectionTransformation.Create(pProjCoordSystem, pGeoCoordSystem)
            Dim pProjectedPoint As MapPoint
            pProjectedPoint = CType(GeometryEngine.Instance.ProjectEx(pPoint, pGeoTrans), MapPoint)
            Console.WriteLine(CStr(pProjectedPoint.Y))
            Console.WriteLine(CStr(pProjectedPoint.X))

        Catch ex As Exception
            'DO NOTHING
        End Try&lt;/LI-CODE&gt;&lt;P&gt;As I understand your map spatial reference is&amp;nbsp;esriSRProjCS_NAD1983SPCS_AK3FT. So, instead of creating&amp;nbsp;pProjCoordSystem you can use Map spatial reference&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2025 08:30:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1617855#M12946</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2025-05-23T08:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Lat/Long of the centerpoint of current map view.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1617991#M12947</link>
      <description>&lt;P&gt;Here is what I have so far, in C#:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;await QueuedTask.Run(() =&amp;gt;
{
    var extent = MapView.Active.Extent;
    MapPoint mapPoint = MapPointBuilder.CreateMapPoint(
        (extent.XMax - extent.XMin) / 2 + extent.XMin,
        (extent.YMax - extent.YMin) / 2 + extent.YMin,
        MapView.Active.Map.SpatialReference
    );

    MessageBox.Show($"Latitude: {mapPoint.Y}\nLongitude: {mapPoint.X}", "Coordinates", MessageBoxButton.OK, MessageBoxImage.Information);
});&lt;/LI-CODE&gt;&lt;P&gt;For a specific location in Fairbanks, Alaska, this gives me:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RogerAsbury_0-1748024667430.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/133130iEBD2E8CDF2501B9D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RogerAsbury_0-1748024667430.png" alt="RogerAsbury_0-1748024667430.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, I would expect something more along the lines of&amp;nbsp;&lt;/P&gt;&lt;P&gt;Latitude: 64.8614161192099&lt;/P&gt;&lt;P&gt;Longitude: -147.90539636224&lt;/P&gt;&lt;P&gt;My guess is that in your vb code, lines 8-17 perform that conversion, but I'm uncertain how to do that in C#. The library names/classes appear to be different? My lack of knowledge on the various spatial reference types is probably not helping.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 May 2025 18:27:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1617991#M12947</guid>
      <dc:creator>RogerAsbury</dc:creator>
      <dc:date>2025-05-23T18:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Lat/Long of the centerpoint of current map view.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1618158#M12948</link>
      <description>&lt;P&gt;This would get you the lat / long of your extent.&lt;/P&gt;&lt;P&gt;var extent = rmg.Common.Methods.GetMapViewExtentAsGeometry(this, mapView, null);&lt;/P&gt;&lt;P&gt;// Convert to WGS84&lt;BR /&gt;var wgs84 = new SpatialReferenceBuilder(4326).ToSpatialReference();&lt;BR /&gt;var projectedCentre = GeometryEngine.Instance.Project(extent, wgs84);&lt;/P&gt;&lt;P&gt;// Get the center of the extent&lt;BR /&gt;var center = GeometryEngine.Instance.Centroid(projectedCentre);&lt;/P&gt;&lt;P&gt;dbllat = center?.Y.ToString();&lt;BR /&gt;dbllong = center?.X.ToString();&lt;/P&gt;</description>
      <pubDate>Sat, 24 May 2025 03:49:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1618158#M12948</guid>
      <dc:creator>JonathanDewalt</dc:creator>
      <dc:date>2025-05-24T03:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Lat/Long of the centerpoint of current map view.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1618201#M12949</link>
      <description>&lt;P&gt;I understood that you need the code in VB. The same classes and methods you can call from c#.&lt;BR /&gt;8-17 lines in VB code makes projection with transformation. wkid&amp;nbsp;102633 is code for ArcObjects&amp;nbsp;&lt;SPAN&gt;esriSRProjCS_NAD1983SPCS_AK3FT.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    var areaOfInterest = MapView.Active.Extent;

    MapPoint pPoint = MapPointBuilderEx.CreateMapPoint((areaOfInterest.XMax - areaOfInterest.XMin) / (double)2 + areaOfInterest.XMin, (areaOfInterest.YMax - areaOfInterest.YMin) / (double)2 + areaOfInterest.YMin, MapView.Active.Map.SpatialReference);

    SpatialReference pGeoCoordSystem = SpatialReferenceBuilder.CreateSpatialReference(SpatialReferences.WGS84);

    SpatialReference pProjCoordSystem = SpatialReferenceBuilder.CreateSpatialReference(102633);
    ProjectionTransformation pGeoTrans = ProjectionTransformation.Create(pProjCoordSystem, pGeoCoordSystem);
    MapPoint pProjectedPoint = GeometryEngine.Instance.ProjectEx(pPoint, pGeoTrans) as MapPoint;
    Console.WriteLine(pProjectedPoint.Y);
    Console.WriteLine(pProjectedPoint.X);&lt;/LI-CODE&gt;&lt;P&gt;Documentation link is &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic8276.html" target="_self"&gt;here&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 May 2025 19:33:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1618201#M12949</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2025-05-24T19:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Lat/Long of the centerpoint of current map view.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1618206#M12950</link>
      <description>&lt;P&gt;This would get you the lat / long of your extent in c#&lt;/P&gt;&lt;P&gt;var extent = MapView.Active.Extent;&lt;/P&gt;&lt;P&gt;// Convert to WGS84&lt;BR /&gt;var wgs84 = new SpatialReferenceBuilder(4326).ToSpatialReference();&lt;BR /&gt;var projectedCentre = GeometryEngine.Instance.Project(extent, wgs84);&lt;/P&gt;&lt;P&gt;// Get the center of the extent&lt;BR /&gt;var center = GeometryEngine.Instance.Centroid(projectedCentre);&lt;/P&gt;&lt;P&gt;dbllat = center?.Y.ToString();&lt;BR /&gt;dbllong = center?.X.ToString();&lt;/P&gt;</description>
      <pubDate>Sat, 24 May 2025 22:07:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1618206#M12950</guid>
      <dc:creator>JonathanDewalt</dc:creator>
      <dc:date>2025-05-24T22:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the Lat/Long of the centerpoint of current map view.</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1618632#M12954</link>
      <description>&lt;P&gt;Thank you both. I tried both solutions and they both work. Love seeing more than one way to arrive at a solution. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Wish I could mark both as the solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Guess I was getting hung up in the conversion.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 17:35:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/finding-the-lat-long-of-the-centerpoint-of-current/m-p/1618632#M12954</guid>
      <dc:creator>RogerAsbury</dc:creator>
      <dc:date>2025-05-27T17:35:25Z</dc:date>
    </item>
  </channel>
</rss>

