Working with the map


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

Introduction

The Map is the primary object used for the display and organization of geographic information in ArcGIS. To support this, the Map is maintains a collection of layers. The Map object has properties that operate on all layers within the map; spatial reference, map scale, etc., along with 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 customization tasks because it not only manages layers of data, but 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 simply 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: a ScreenDisplay object, which every view uses to manage the drawing window, and a new CompositeGraphicsLayer.

The IMap interface

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

The IActiveView interface

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

The 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; vector features are handled by the FeatureLayer object, raster data by the RasterLayer, TIN data by the TinLayer, etc.
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. Map provides direct access to this layer with the property IMap::BasicGraphicsLayer.
You can also access the Map object through the IGraphicsContainer interface to access its active graphics layer. This always returns a reference to Map’s active graphics layer which may or may 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 which 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 layer 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 Map’s CompositeGraphicsLayer. To access them, you can use the IMap::ActiveGraphicsLayer property. This property will return a reference to the graphics layer which is the current drawing target. This can either 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.

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

Active view events

The IActiveViewEvents interface is the default outbound interface on the Map object. It is exposed by the Map object so that clients may listen and respond to specific events related to the active view, such as AfterDraw and SelectionChanged.
Many classesimplement this interface, and each of them fires events differently. The Map object’s implementation of the IActiveView is different from the PageLayout object’s implementation. For example, the Map object does not fire the FocusMap Changed event, whereas the PageLayout object does. Similarly, the Map object fires the Item Deleted 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 AfterViewDraw event will not fire unless IViewManager::VerboseEvents is set to True.

Map events

The IMapEvents interface is exposed off the Map object, enabling clients to listen and respond to two events occurring inside a map: FeatureClassChanged and VersionChanged. Both of 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

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, you must set VerboseEvents equal to True.

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, graphical elements, and symbols generated from renderers. For example, a feature layer using a pie chart renderer doesn’t 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 may be necessary to access barriers in the 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 so 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. There are two types of spatial bookmarks available: Area of Interest bookmarks and Feature bookmarks. Area of Interest bookmarks store information about a map extent, Feature bookmarks allow you to find back one particular feature on the map.

ITableCollection

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.