In this topic
- About using the MapControl
- Loading map documents
- Saving map documents
- Managing layers
- Altering the display
About using the MapControl
The MapControl corresponds to the data view in ArcMap and encapsulates the Map object. Map documents preauthored with ArcMap can be loaded into the MapControl, eliminating the need to programmatically compose the cartography. See the following screen shot:
The map document can be set at design time though the MapControl property pages (in development environments that support property page capability). Alternatively, a map document can be loaded into the MapControl programmatically using the checkMxFile method to determine whether the document is valid and the loadMxFile method to load the map document. The readMxMaps method can be used in conjunction with the loadMxFile method to load a specific map from a map document into the MapControl. See the following code example:
[Java]
String ArcGISInstallDir = System.getenv("AGSDEVKITJAVA");
String filePath = ArcGISInstallDir + "java/samples/data/mxds/brazil.mxd";
if (mapControl.checkMxFile(filePath))
mapControl.loadMxFile("filePath", null, null);
Saving map documents
In addition to reading map documents, MapControl can also write map documents (*.mxd). MapControl implements the IMxdContents interface, which enables the MapDocument object to write the contents of the MapControl to a new map document.
Managing layers
MapControl offers frequently used methods of the Map object, such as addLayer(), deleteLayer(), and clearLayers(), and helper members, such as addLayerFromFile, addShapefile, and moveLayerTo, to manage the individual layers within the map.
Altering the display
MapControl's display area can be altered by using the setvisibleRegion() method to change the shape of the display area and the setRotation() method to alter the angle at which data is drawn on the display. Also, methods such as trackRectangle(), trackPolygon(), trackLine(), and trackCircle() exist on the MapControl for tracking or "rubber banding" shapes on the display. For example, to zoom in on the display, set the Envelope returned from the trackRectangle() method into the setExtent() method. Shapes can be drawn on the display with the drawShape(), drawText(), and flashShape() methods, typically in the IMapControlEvents2.onAfterDraw() event.
See Also:
Controls library overviewWorking with the map
Working with the map display
How to get started with the MapControl property pages
Development licensing | Deployment licensing |
---|---|
Engine Developer Kit | Engine |
ArcGIS for Desktop Basic | |
ArcGIS for Desktop Standard | |
ArcGIS for Desktop Advanced |