拷贝地图 CopyAndOverwriteMap()

private void CopyAndOverwriteMap()
{
//Get IObjectCopy interface
IObjectCopy objectCopy = new ObjectCopyClass();

//Get IUnknown interface (map to copy)
object toCopyMap = axPageLayoutControl1.ActiveView.FocusMap;

//Each Map contained within the PageLayout encapsulated by the
//PageLayoutControl, resides within a separate MapFrame, and therefore
//have their IMap::IsFramed property set to True. A Map contained within the
//MapControl does not reside within a MapFrame. As such before
//overwriting the MapControl's map, the IMap::IsFramed property must be set
//to False. Failure to do this will lead to corrupted map documents saved
//containing the contents of the MapControl.
IMap map = toCopyMap as IMap;
map.IsFramed = false;

//Get IUnknown interface (copied map)
object copiedMap = objectCopy.Copy(toCopyMap);

//Get IUnknown interface (map to overwrite)
object toOverwriteMap = axMapControl1.Map;

//Overwrite the MapControl's map
objectCopy.Overwrite(copiedMap, ref toOverwriteMap);

SetMapExtent();
}

原文地址:https://www.cnblogs.com/gisoracle/p/4827871.html