com.esri.arcgis.display
Interface IMapContext

All Superinterfaces:
Serializable
All Known Implementing Classes:
MapContext

public interface IMapContext
extends Serializable

Provides access to the context in which geometric effects and marker placements work.

Remarks

Spatial Reference and Reference Scale information is used to define a Map Context.

A Feature Representation has to be initiated with a map context to make itself valid.

'How to initialize mapcontext

Dim pMapContext As IMapContext

Dim pGFClass As IGeoDataset

Set pMapContext = New MapContext

Set pGFClass = pFClass

pMapContext.Init pGFClass.SpatialReference, 25000, pGFClass.Extent

Set pRepresentation = pRepClass.GetRepresentation(pFeat, pMapContext)

'where pFeat is reference to a Feature object and pFClass is reference to a FeatureClass object
  'How to Initialize a mapcontext using the DisplayTransformation 
Dim pMC As IMapContext
Set pMC = New MapContext
Dim pDisp As IDisplayTransformation
Dim pAV as IActiveView
Set pAV = pMxDoc.ActiveView
Set pDisp = pAV.ScreenDisplay.DisplayTransformation
pMC.InitFromDisplay pDisp

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


Method Summary
 IGeometry fromGeographyToMap(IGeometry ingeom)
          Converts geographic geometry to map context geometry.
 IGeometry fromMapToGeography(IGeometry ingeom)
          Converts map context geometry to geographic geometry.
 double fromPoints(double ptDist)
          Converts a distance expressed in points into a geographic distance.
 double getReferenceScale()
          The reference scale of the map.
 ISpatialReference getSpatialReference()
          The spatial reference of the map.
 void init(ISpatialReference mapProj, double mapRefScale, IEnvelope mapExtent)
          Initializes the map context.
 void initFromDisplay(IDisplayTransformation displayTransform)
          Initializes the map context using a display transformation.
 double toPoints(double mapDist)
          Converts a geographic distance into a distance expressed in points.
 

Method Detail

initFromDisplay

void initFromDisplay(IDisplayTransformation displayTransform)
                     throws IOException,
                            AutomationException
Initializes the map context using a display transformation.

Remarks

Use this method when you create a reference to a new MapContext object to initialize the mapcontext using a DisplayTransformation that exists. If a reference to a DisplayTransformation does not exist, then use IMapContext::Init method to initialize the map context. It is important to initialize the map context as this will help in getting correct context for displaying and drawing geometric effects and marker placements.

Use the following code snippet to initialize a MapContext using display settings from a map document


Dim pMxDoc As IMxDocument
Dim pMap As IMap
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap

'set the MapContext object from current display settings
Dim pMapContext As IMapContext
Dim pMxApp As IMxApplication
Set pMxApp = Application 'QI
Set pMapContext = New MapContext
pMapContext.InitFromDisplay pMxApp.Display.DisplayTransformation

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
displayTransform - A reference to a com.esri.arcgis.display.IDisplayTransformation (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

init

void init(ISpatialReference mapProj,
          double mapRefScale,
          IEnvelope mapExtent)
          throws IOException,
                 AutomationException
Initializes the map context.

Remarks

Use this method when you create a reference to a new MapContext object to initialize the mapcontext. If a reference to a DisplayTransformation exists, then use IMapContext::InitFromDisplay method to initialize the map context. It is important to initialize the map context as this will help in getting correct context for displaying and drawing geometric effects and marker placements.

'initialize new mapcontext using a feature class's spatial reference and extent

Dim pMapContext As IMapContext

Dim pGFClass As IGeoDataset

Set pMapContext = New MapContext

Set pGFClass = pFClass

pMapContext.Init pGFClass.SpatialReference, 25000, pGFClass.Extent

Set pRepresentation = pRepClass.GetRepresentation(pFeat, pMapContext)

'where pFeat is reference to a Feature object and pFClass is reference to a FeatureClass object

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
mapProj - A reference to a com.esri.arcgis.geometry.ISpatialReference (in)
mapRefScale - The mapRefScale (in)
mapExtent - A reference to a com.esri.arcgis.geometry.IEnvelope (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

fromGeographyToMap

IGeometry fromGeographyToMap(IGeometry ingeom)
                             throws IOException,
                                    AutomationException
Converts geographic geometry to map context geometry.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
ingeom - A reference to a com.esri.arcgis.geometry.IGeometry (in)
Returns:
A reference to a com.esri.arcgis.geometry.IGeometry
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

fromMapToGeography

IGeometry fromMapToGeography(IGeometry ingeom)
                             throws IOException,
                                    AutomationException
Converts map context geometry to geographic geometry.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
ingeom - A reference to a com.esri.arcgis.geometry.IGeometry (in)
Returns:
A reference to a com.esri.arcgis.geometry.IGeometry
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getReferenceScale

double getReferenceScale()
                         throws IOException,
                                AutomationException
The reference scale of the map.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Returns:
The refScale
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getSpatialReference

ISpatialReference getSpatialReference()
                                      throws IOException,
                                             AutomationException
The spatial reference of the map.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Returns:
A reference to a com.esri.arcgis.geometry.ISpatialReference
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

fromPoints

double fromPoints(double ptDist)
                  throws IOException,
                         AutomationException
Converts a distance expressed in points into a geographic distance.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
ptDist - The ptDist (in)
Returns:
The mapDist
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

toPoints

double toPoints(double mapDist)
                throws IOException,
                       AutomationException
Converts a geographic distance into a distance expressed in points.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Parameters:
mapDist - The mapDist (in)
Returns:
The ptDist
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.