Select to view content in your preferred language

Set ArcMap Data Frame in Decimal Degrees Using ArcObjects

940
5
06-30-2017 10:26 AM
ShaningYu
Honored Contributor

I use a piece of code for dynamically loading feature layers.  Either before or after the loading, I need to set the Data Frame in Decimal Degrees.  Is there such a piece of code that can set / change the Data Frame's setting?  Thanks.

0 Kudos
5 Replies
KenBuja
MVP Esteemed Contributor

Use the IMap.DistanceUnits property

0 Kudos
ShaningYu
Honored Contributor

Ken:

Thanks for your hint.  Below is the code I have.  But I can't QI to Decimal Degree.  What's wrong in my code?  Thanks.

                        m_mxDoc = (IMxDocument)app.Document; //m_app.Document;
                        m_Map = m_mxDoc.FocusMap;
                        m_activeView = (IActiveView)m_Map;

                        ISpatialReference spRef = m_Map.SpatialReference;
                        IProjectedCoordinateSystem pProjectedCoordinateSystem = spRef as IProjectedCoordinateSystem;
                        ILinearUnit pLinearUnit = pProjectedCoordinateSystem.CoordinateUnit;

0 Kudos
KenBuja
MVP Esteemed Contributor

I believe you're overthinking it. Try this

m_Map = m_mxDoc.FocusMap;

m_Map.DistanceUnits = esriDecimalDegrees

0 Kudos
ShaningYu
Honored Contributor

Ken:

Thanks for your response.  I revised my program.  But after the feature layers are loaded, the frame still shows feet as the unit.  Besides, the returned values (Calculated central X & Y) are still in feet.  Any new idea?  Thanks.

0 Kudos
DuncanHornby
MVP Notable Contributor

If the underlying data is in feet then a field calculate will return feet even though the map is displaying in decimal degrees. Also there is a difference between MapUnits and DistanceUnits read the remarks section here.

0 Kudos