In this topic
- About using the MapControl
- Loading map documents
- Saving map documents
- Managing layers
- Altering the display
MapControl corresponds to the data view of the ArcMap application and encapsulates the Map object. Map documents preauthored with the ArcMap application can be loaded into MapControl, eliminating the need to programmatically compose the cartography.
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.
[Java]
String ArcGISInstallDir = System.getenv("ARCGISHOME");
String filePath = ArcGISInstallDir + "java/samples/data/mxds/brazil.mxd";
if (mapControl.checkMxFile(filePath))
mapControl.loadMxFile("filePath", null, null);
In addition to reading map documents, MapControl can also write map documents (*.mxd). MapControl implements the IMxdContents interface that enables the MapDocument object to write the contents of the MapControl to a new map document.
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.
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
Sample: MapBean, TocBean and ToolbarBean
Development licensing | Deployment licensing |
---|---|
Engine Developer Kit | Engine Runtime |
ArcView | |
ArcEditor | |
ArcInfo |