This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ESRI.ArcGIS.Snippets > Snippets > Change Map Spatial Reference Snippet (ArcObjects .NET 10.4 SDK) |
Use the SpatialReferenceDialog to change the coordinate system or spatial reference of the map.
///<summary>Use the SpatialReferenceDialog to change the coordinate system or spatial reference of the map.</summary> /// ///<param name="hWnd">The application window handle.</param> ///<param name="map">An IMap interface.</param> /// ///<remarks></remarks> public void ChangeMapSpatialReference(System.Int32 hWnd, ESRI.ArcGIS.Carto.IMap map) { if(map == null) { return; } ESRI.ArcGIS.CatalogUI.ISpatialReferenceDialog2 spatialReferenceDialog=new ESRI.ArcGIS.CatalogUI.SpatialReferenceDialogClass(); ESRI.ArcGIS.Geometry.ISpatialReference spatialReference=spatialReferenceDialog.DoModalCreate(true, false, false, hWnd); if ((!(map.SpatialReferenceLocked))) { map.SpatialReference=spatialReference; } }
'''<summary>Use the SpatialReferenceDialog to change the coordinate system or spatial reference of the map.</summary> ''' '''<param name="hWnd">The application window handle.</param> '''<param name="map">An IMap interface.</param> ''' '''<remarks></remarks> Public Sub ChangeMapSpatialReference(ByVal hWnd As System.Int32, ByVal map As ESRI.ArcGIS.Carto.IMap) If map Is Nothing Then Return End If Dim spatialReferenceDialog As ESRI.ArcGIS.CatalogUI.ISpatialReferenceDialog2=New ESRI.ArcGIS.CatalogUI.SpatialReferenceDialogClass Dim spatialReference As ESRI.ArcGIS.Geometry.ISpatialReference=spatialReferenceDialog.DoModalCreate(True, False, False, hWnd) If (Not (map.SpatialReferenceLocked)) Then map.SpatialReference=spatialReference End If End Sub