# How to get the Location Coordinates of the center of the Map

**URL:** <https://community.thinkgeo.com/t/how-to-get-the-location-coordinates-of-the-center-of-the-map/2333>\
**Category:** WinForms\
**Created:** [January 7, 2014, 11:04am UTC](https://community.thinkgeo.com/t/how-to-get-the-location-coordinates-of-the-center-of-the-map/2333 "2014-01-07T11:04:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arvind](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/a6a055/32.png) [@Arvind](https://community.thinkgeo.com/u/Arvind)\
**Post date:** [January 7, 2014, 11:04am UTC](https://community.thinkgeo.com/t/how-to-get-the-location-coordinates-of-the-center-of-the-map/2333/1 "2014-01-07T11:04:17Z")

</div>

Hi,&nbsp;I&nbsp;am&nbsp;using&nbsp;V2.0&nbsp;Desktop&nbsp;Edition&nbsp;in&nbsp;an&nbsp;old&nbsp;project&nbsp;&&nbsp;need&nbsp;to&nbsp;to&nbsp;know&nbsp;the&nbsp;GPS&nbsp;coordinates&nbsp;of&nbsp;the&nbsp;center&nbsp;of&nbsp;the&nbsp;Panned&nbsp;area.  
  
  
  
I&nbsp;can&nbsp;get&nbsp;the&nbsp;Center&nbsp;of&nbsp;the&nbsp;control,&nbsp;but&nbsp;how&nbsp;do&nbsp;I&nbsp;convert&nbsp;it&nbsp;to&nbsp;GPS&nbsp;long/Lattitude?  
  
  
  
MapSuite.DesktopEdition.Map&nbsp;mapControl&nbsp;;  
  
&nbsp;PointR&nbsp;r&nbsp;=&nbsp;mapControl.CurrentExtent.Centroid;  
  
  
  
Please&nbsp;help

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [January 8, 2014, 3:57am UTC](https://community.thinkgeo.com/t/how-to-get-the-location-coordinates-of-the-center-of-the-map/2333/2 "2014-01-08T03:57:16Z")

</div>

Hi&nbsp;Arvind,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Please&nbsp;try&nbsp;the&nbsp;below&nbsp;codes:&nbsp;  
&nbsp;`map1.CurrentExtent = new RectangleR(-20037508.352, 20037508.352, 20037508.352, -20030000);            PointR r = map1.CurrentExtent.Centroid;            MapSuiteProjection.TransverseMercatorProj proj = new MapSuiteProjection.TransverseMercatorProj();            double longitude, latitude;            proj.ConvertTransverseMercatorToGeodetic(r.X, r.Y, out longitude, out latitude); `&nbsp;  
&nbsp;&nbsp;  
&nbsp;If&nbsp;the&nbsp;issue&nbsp;persists,&nbsp;don’t&nbsp;hesitate&nbsp;to&nbsp;let&nbsp;us&nbsp;know.&nbsp;  
&nbsp;Johnny

---

<div class="post-metadata">

**Author:** ![Arvind](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/a6a055/32.png) [@Arvind](https://community.thinkgeo.com/u/Arvind)\
**Post date:** [January 10, 2014, 1:31pm UTC](https://community.thinkgeo.com/t/how-to-get-the-location-coordinates-of-the-center-of-the-map/2333/3 "2014-01-10T13:31:33Z")

</div>

Thanks&nbsp;for&nbsp;your&nbsp;response,&nbsp;however&nbsp;the&nbsp;code&nbsp;snippet&nbsp;does&nbsp;not&nbsp;seem&nbsp;to&nbsp;work.&nbsp;  
  
  
  
I&nbsp;am&nbsp;getting&nbsp;0.0&nbsp;for&nbsp;the&nbsp;r.X&nbsp;&&nbsp;latitude&nbsp;for&nbsp;all&nbsp;values.  
  
  
  
As&nbsp;mentioned&nbsp;we&nbsp;are&nbsp;displaying&nbsp;the&nbsp;MapSuite.DesktopEdition.Map&nbsp;&&nbsp;the&nbsp;user&nbsp;can&nbsp;zoom&nbsp;in/out,&nbsp;pan,&nbsp;drag&nbsp;map&nbsp;around.&nbsp;I&nbsp;want&nbsp;to&nbsp;get&nbsp;the&nbsp;GPS&nbsp;location&nbsp;of&nbsp;the&nbsp;center&nbsp;of&nbsp;the&nbsp;displayed&nbsp;map&nbsp;area.  
  
  
  
Also&nbsp;what&nbsp;do&nbsp;the&nbsp;following&nbsp;numbers&nbsp;mean?&nbsp;&nbsp;  
  
  
  
new&nbsp;RectangleR(-20037508.352,&nbsp;20037508.352,&nbsp;20037508.352,&nbsp;-20030000);  
  
  
  
(FYI&nbsp;:&nbsp;I&nbsp;am&nbsp;using&nbsp;the&nbsp;MapSuiteCommon.dll&nbsp;&&nbsp;DesktopEdition.dll&nbsp;&nbsp;v&nbsp;2.71.5.0)  
  
  
  
Thanks  
  
–Arvind

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [January 13, 2014, 4:11am UTC](https://community.thinkgeo.com/t/how-to-get-the-location-coordinates-of-the-center-of-the-map/2333/4 "2014-01-13T04:11:40Z")

</div>

Hi&nbsp;Arvind,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Sorry&nbsp;the&nbsp;previous&nbsp;reply&nbsp;might&nbsp;make&nbsp;you&nbsp;confused.&nbsp;The&nbsp;new&nbsp;RectangleR(-20037508.352,&nbsp;20037508.352,&nbsp;20037508.352,&nbsp;-20030000)&nbsp;is&nbsp;means&nbsp;the&nbsp;whole&nbsp;world&nbsp;extent&nbsp;under&nbsp;spherical&nbsp;mecator&nbsp;projection&nbsp;system.&nbsp;but&nbsp;don’t&nbsp;care&nbsp;about&nbsp;it&nbsp;if&nbsp;your&nbsp;map&nbsp;control&nbsp;current&nbsp;extent&nbsp;have&nbsp;been&nbsp;assigned.&nbsp;&nbsp;  
&nbsp;&nbsp;  
&nbsp;As&nbsp;for&nbsp;how&nbsp;to&nbsp;get&nbsp;the&nbsp;center&nbsp;point&nbsp;of&nbsp;map&nbsp;area,&nbsp;I&nbsp;think&nbsp;you&nbsp;can&nbsp;try&nbsp;to&nbsp;register&nbsp;the&nbsp;“CurrentExtentChanged”&nbsp;event&nbsp;to&nbsp;get&nbsp;the&nbsp;center&nbsp;point&nbsp;when&nbsp;zoom&nbsp;in/out,pan&nbsp;dynamically:&nbsp;  
&nbsp;&nbsp;  
&nbsp;` private void Form1_Load(object sender, EventArgs e)        {            Rectangle Rect = new Rectangle(0, 0, map1.Width, map1.Height);            map1.CanvasGeoBrush = new GeoLinearGradientBrush(Rect, GeoColor.GeographicColors.Ocean1, GeoColor.GeographicColors.Ocean2, GeoLinearGradientMode.ForwardDiagonal);            map1.CurrentExtentChanged += new MapSuite.DesktopEdition.Map.CurrentExtentChangedEventHandler(map1_CurrentExtentChanged);            Layer statesLayer = new Layer(@"…\Data\states.shp", true);            statesLayer.ZoomLevel01.GeoStyle = GeoAreaStyles.GetSimpleAreaStyle(GeoColor.KnownColors.Transparent, GeoColor.KnownColors.OliveDrab);            statesLayer.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.ZoomLevel18;            map1.Layers.Add(statesLayer);            map1.CurrentExtent = new RectangleR(-109, 37, -90, 24);        }        void map1_CurrentExtentChanged(RectangleR Extent, int MapWidth, int MapHeight, MapLengthUnits MapUnit)        {            PointR r = Extent.Centroid;            label3.Text = r.X.ToString();            label5.Text = r.Y.ToString();        }`&nbsp;  
&nbsp;&nbsp;  
&nbsp;Note:&nbsp;the&nbsp;codes&nbsp;sample&nbsp;is&nbsp;under&nbsp;EPSG&nbsp;4326&nbsp;projection(decimal&nbsp;degree),&nbsp;which&nbsp;is&nbsp;the&nbsp;same&nbsp;with&nbsp;GPS&nbsp;location.&nbsp;If&nbsp;your&nbsp;projection&nbsp;is&nbsp;under&nbsp;spherical&nbsp;mecator,&nbsp;then&nbsp;we&nbsp;need&nbsp;to&nbsp;do&nbsp;a&nbsp;projection&nbsp;conversion&nbsp;like:&nbsp;  
&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PointR&nbsp;r&nbsp;=&nbsp;Extent.Centroid;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MapSuiteProjection.TransverseMercatorProj&nbsp;proj&nbsp;=&nbsp;new&nbsp;MapSuiteProjection.TransverseMercatorProj();&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;double&nbsp;longitude,&nbsp;latitude;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proj.ConvertTransverseMercatorToGeodetic(r.X,&nbsp;r.Y,&nbsp;out&nbsp;longitude,&nbsp;out&nbsp;latitude);&nbsp;  
&nbsp;&nbsp;  
&nbsp;If&nbsp;there&nbsp;is&nbsp;anything&nbsp;confused,&nbsp;please&nbsp;feel&nbsp;free&nbsp;to&nbsp;let&nbsp;us&nbsp;know.&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;Johnny

---

<div class="post-metadata">

**Author:** ![Arvind](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/a6a055/32.png) [@Arvind](https://community.thinkgeo.com/u/Arvind)\
**Post date:** [January 13, 2014, 9:10am UTC](https://community.thinkgeo.com/t/how-to-get-the-location-coordinates-of-the-center-of-the-map/2333/5 "2014-01-13T09:10:35Z")

</div>

Johnny,&nbsp;  
  
  
  
Thanks&nbsp;a&nbsp;lot.&nbsp;That&nbsp;seems&nbsp;to&nbsp;work&nbsp;as&nbsp;expected.  
  
  
  
Arvind

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [January 13, 2014, 7:13pm UTC](https://community.thinkgeo.com/t/how-to-get-the-location-coordinates-of-the-center-of-the-map/2333/6 "2014-01-13T19:13:28Z")

</div>

Hi&nbsp;Arvind,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Good&nbsp;to&nbsp;hear&nbsp;it&nbsp;works.&nbsp;  
&nbsp;Any&nbsp;questions,&nbsp;don’t&nbsp;hesitate&nbsp;to&nbsp;let&nbsp;us&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;Johnny
