Working with map documents (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Interacting with and configuring maps, layers, and graphics > Working with map documents (ArcObjects .NET 10.6 SDK)

Working with map documents


Summary
This topic provides an overview of working with map documents in ArcGIS.

In this topic


About working with map documents

In ArcGIS, a map document is a file that contains one or more maps; one page layout; and the associated layers, tables, charts, and reports. Map document files have a .mxd extension. Map documents are the most common way to persist and distribute maps and other cartographic information or data. Many common development tasks begin with a pre-authored map document, so knowing how to access and work with the content in a map document is an essential part of ArcObjects development.
Map documents can be accessed and opened by several different components in ArcGIS. The component chosen typically depends on the situation and the ArcGIS product being used. For an ArcGIS Desktop developer, the most common way to access and modify a map document is through the MxDocument class. For an ArcGIS Engine developer, the way to access and modify a map document is through the MapControl, PageLayoutControl, MapDocument, or MapReader class.

MxDocument

The MxDocument class represents a map document as loaded in the ArcMap application. Typically, a reference to MxDocument is obtained via the application hook when working with a component in the ArcMap application. (See Building add-ins for ArcGIS Desktop or the HookHelper class for more information on working with application hooks.) MxDocument operates within the process space of the ArcMap application, so creating an MxDocument class instance creates an ArcMap process. For this reason, it is recommended that the MxDocument class be accessed within the ArcMap process. Otherwise, you must be careful to use the class across process boundaries in an automation fashion. For more information about using automation with the ArcGIS applications, see Automate ArcGIS Desktop applications. Modifying map documents without the ArcMap application process overhead is described in the MapDocument section.
Unlike other components that are discussed in this topic, MxDocument is the premier map document component, and it provides access to all the properties of a map document. This includes user interface-specific properties as well as features that are not available outside ArcGIS Desktop (such as graphs) and application-specific map elements (such as OleFrames). Commonly accessed properties, such as maps in the document and the document's page layout, are also accessible.
Maps can be accessed via the IMxDocument interface. The Maps property provides access to all the maps in the document, while the FocusMap property provides access to the map that is currently the focus map. The page layout is accessible via the PageLayout property. See How to access maps and layers via the MxDocument for an example of the component in use.
Graphs can be accessed via the IDataGraphCollection interface.

MapControl and PageLayoutControl

ArcGIS Engine provides a number of controls for embedding ArcGIS components in your application. The MapControl and PageLayoutControl work with map documents as a way to display documents and also provide update capabilities. For more information on working with these controls, see the following topics:

MapDocument

The MapDocument class provides the ability to read and modify commonly accessed properties of a map document without the ArcMap application. Since MapDocument is not tied to the ArcMap application, it is created within the process space of the application in which it is created.
MapDocument presents a simplified form of the map document, since application-specific items are not accessible. In fact, updating the document drops these items from the document storage. Despite these limitations, MapDocument is useful for batch operations, low-level document access, and modification of simple map documents. For example, to update the contents of many map document files, you can write an application to loop through the files, open them with MapDocument, update the contents, then save the document. See How to access maps and layers via the MapDocument for an example of the component in use.

MapReader

The MapReader class is a simplified form of MapDocument that provides read-only access to map document properties. Use this class when you want to read documents but not update them.
For more information on working with the map and page layout objects, see Working with the map and Working with the page layout. These topics contain references to more detailed information for items, such as layers and elements.


See Also:

Working with the map
Working with the page layout
Working with graphs




Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
Engine Developer Kit Engine