Adding a layer to a map from a layer file
This operation is performed using the MapDocument class, which can open layer files, as well as map documents (.mxds) and published map files (.pmfs). See the following code:
[Java]
static void addLayerFileToMap(IMap map, String path)throws Exception{
IMapDocument document = new MapDocument();
//Use the map document class to open the layer.
document.open(path, "");
//When opening a layer with the map document class,
//the layer is added to a new document as the first
//layer in the first map.
map.addLayer(document.getMap(0).getLayer(0));
}
Development licensing | Deployment licensing |
---|---|
ArcView | ArcView |
ArcEditor | ArcEditor |
ArcInfo | ArcInfo |
Engine Developer Kit | Engine Runtime |