[GIS] How is a “Map Package” created programmatically

arcgis-10.0arcgis-enginec

Given a loaded map document (mxd) how do I find the geodatabase objects related to the contained layers? I want to copy them with the map document so the map can be moved onto each user's local machine from a network share. Is there an API to do this? Can someone point to source code that does this?

To clarify (after all the great feedback): How is a "Map Package" created programmatically using the ArcEngine API? Is this even possible?

Best Answer

This is what ESRI told me. Of course this uses the ArcPy toolbox. But ArcPy is installed with every version of ArcGIS software (including the runtime engine.) Note that you have to pass the full pathname for the map file and the target package file. In addition, the help warns you that you must set the "Description" for the map file or this WILL NOT WORK. Of course there is no such thing as a "Description" property for a map file. Your file "SAVE" must include: documentInfo.Comments = "Some Comment required."; (Cast MapDocument to IDocumentInfo (or IDocumentInfo2) and set the Comments property.)

using ESRI.ArcGIS.Geoprocessor;
using ESRI.ArcGIS.DataManagementTools;

Geoprocessor geoprocessor = new Geoprocessor();
PackageMap packageMap = new PackageMap();
packageMap.in_map = mapFile;
packageMap.output_file = packageFile;
geoprocessor.Execute( packageMap, null );

For now I'll live with this - I sure hope they decide to provide lower level code in 10.1.1 (even tho 10.1 is trying to abstract more.)