Working with the map


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


Introducing the Map component

The Map, known as the data frame in the ArcMap user interface (UI), is the primary object used for the display and organization of geographic information in ArcGIS. To support this, the Map is maintained as a collection of layers. The Map object also has properties that operate on all layers within the map, that is, spatial reference, map scale, label engine, and methods that manipulate the map's layers. Additionally, the Map has global properties that aid in the analysis and navigation of the map. The Map object is a primary point for developer tasks because it not only manages layers of data, it is also a view and manages the drawing of all its data. Typical tasks with the Map object include adding a new layer, panning the display, changing the view extent (zooming functions), changing the spatial reference, and getting the currently selected features and elements.
Like most classes, the Map can be created and worked with as an object in applications. However, it is more common to obtain a reference to an existing map through map documents of other higher level objects. Instantiating a new Map object automatically creates the following related objects on which it relies: 
For additional information about working with the map, including topics and code samples, see the following:

IMap interface

The IMap interface is a starting point for many of the tasks you can do with a map. Use IMap to add, delete, and access map layers containing data from various sources, including feature layers and graphics layers; associate map surround objects (for example, legends, scale bars, and so on) with the map; access the various properties of a map, including the area of interest (AOI), the current map units, and the spatial reference; select features; and access the Map object's current selection.

IActiveView interface

The IActiveView interface provides access to view related properties and methods for managing the display of the map. It also provides access to the map's ScreenDisplay, which is a key access point for low-level display operations. For detailed information on working with the map via this interface, see the IActiveView interface documentation.

Map as a collection of layers

The Map object manages a collection of layer objects. There are many different types of layers that can be added to a map. Different data sources often have an associated layer responsible for displaying the data on the map, for example, vector features are handled by the FeatureLayer object, raster data by the RasterLayer, triangulated irregular network (TIN) data by the TinLayer, and so on.  For more information about the types of layers available in ArcGIS, see Working with layers and renderers.

Each layer has a spatial reference. A spatial reference defines a precision and a coordinate system. The map coordinate system is automatically set to the coordinate system of the first layer loaded in the map.

The Map manages a CompositeGraphicsLayer object, which contains a collection of graphics layers. This layer, also known as the basic graphics layer, is the default graphics layer of the Map where all graphics are drawn by default. The Map provides direct access to this layer with the IMap.BasicGraphicsLayer property. You can also access the Map object through the IGraphicsContainer interface to access its active graphics layer. This always returns a reference to the Map's active graphics layer, which might or might not be the basic graphics layer.

The Map's basic graphics layer is both a graphics layer on which to draw and the composite graphics layer that contains sub-graphic layers. The Map's basic graphics layer cannot be deleted. You can obtain a reference to the Map's basic graphics layer through the ICompositeGraphicsLayer interface to manage the layers it contains. This way, graphics layers can be added to or deleted from the map.

The layer collection returned from the IMap.Layers property does not include the graphics layers managed by the Map's CompositeGraphicsLayer. To access them, use the IMap.ActiveGraphicsLayer property. This property returns a reference to the graphics layer that is the current drawing target. This can be the basic graphics layer, a layer in the Map's CompositeGraphicsLayer, or a feature layer, such as an FDOGraphicsLayer.

Selecting in the map

Feature selection is an important part of map analysis. While selection can be seen as a layer property, the Map manages selection as a whole and has methods to modify and access the selection. For more information on how to work with the map selection, see the previously mentioned topic, How to perform map selection.

Map frames and surrounds

Map objects on a PageLayout are always contained by MapFrame objects. This is common when dealing with maps in a map document where a PageLayout is always present. In this case, the PageLayout object actually manages all the MapFrame objects and each MapFrame manages a Map.

MapSurround objects are PageLayout elements that are related to a Map. Types of map surrounds include legends, north arrows, and scale bars. The Map object exposes several properties and methods for accessing the map surrounds associated with it. All map surrounds are actually contained by a MapSurroundFrame, which, like a MapFrame, is ultimately managed by the PageLayout object.

Working with Map events

The following describes Map events:
  • Active view events—The IActiveViewEvents interface is the default outbound interface on the Map object. The Map object exposes IActiveViewEvents so that clients can listen and respond to specific events related to the active view, such as AfterDraw and SelectionChanged. Many classes implement this interface and each of them fires events differently. The Map object's implementation of IActiveView is different from the PageLayout object's implementation. For example, the Map object does not fire the FocusMapChanged event, whereas the PageLayout object does. Similarly, the Map object fires the ItemDeleted event when a layer is removed from the Map, and the PageLayout object fires the same event when elements, such as a map frame or graphic, are deleted. The AfterItemDraw event does not fire unless IViewManager.VerboseEvents is set to true.
  • Map events—The Map object exposes the IMapEvents interface, enabling clients to listen and respond to the following events occurring inside a mapFeatureClassChanged and VersionChanged. These events are related to changing the version the map's layers are working with. For example, if someone changes the version an edit session is working with, the Editor has to know about all the new feature classes so that it can reset the snapping environment.
  • IViewManager interface— IViewManager is a low-level interface to the properties defining the behavior of the active view. One commonly used property managed by the IViewManager interface is VerboseEvents. When VerboseEvents is set to false, the default IActiveViewEvents.AfterItemDraw is not fired. To listen for this event, set VerboseEvents equal to true.

Additional Map properties

The following describes additional Map properties:
  • Barriers—Barriers are used by labeling engines to signal that a label should not be placed in a particular region. Barriers include annotation, graphic elements, and symbols generated from renderers. For example, a feature layer using a pie chart renderer does not want labels to appear directly above the pie chart's symbols. In this case, pie chart symbols act as barriers, informing the label engine that no labels should be placed on top of them. The IMapBarriers interface returns a list of all the barriers and their weights from all the layers in the Map. Layers with barriers include those layers that implement IBarrierProperties—the CompositeGraphicsLayer, CoverageAnnotationLayer, and FDOGraphicsLayer. When working with low-level label engine components, it might be necessary to access barriers in the map.
  • Label engine—The map always has an assigned label engine. By default, the standard label engine is used. The label engine of the map is accessible via the IMap.AnnotationEngine property. The MaplexAnnotateMap object can be set here to change the map to be a Maplex labeled map.
  • Spatial bookmarks—All spatial bookmarks are managed by and are persisted in the Map object. Bookmarks save map extents along with a name identifying them and therefore, make it easy to jump to a specific location on the map. Map's bookmarks are managed by the IMapBookmarks interface. Use IMapBookmarks to access existing bookmarks, add new ones, and delete old ones. Once you have a reference to a particular bookmark, you can make the map's extent equal to that stored in the bookmark. The following are two types of available spatial bookmarks:
    • AOI bookmarks—AOI bookmarks store information about a map extent.
    • Feature bookmarks—Feature bookmarks allow you to find a particular feature on the map.
  • ITableCollection interface—In addition to layers, the Map also contains a collection of tables. The ITableCollection interface is used to manage tables associated with a map. Use this interface to add new tables to a map, remove old tables, or access a table already loaded.






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