In this topic
The Map 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 has properties that operate on all layers within the map, such as spatial reference and map scale, as well as 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, 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. See the following:
- 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.
- 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.
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, triangulated irregular network (TIN) data by the TinLayer, and so on. More information about the types of layers available in ArcGIS can be found in the topic 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 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 that contains subgraphic 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, you can 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 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.
The following discusses 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 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 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 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, you must set VerboseEvents equal to true.
The following are 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 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 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:
- Area of Interest bookmarks—Area of Interest 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|