首页 > 代码库 > MapControl图层删除或添加触发监听事件

MapControl图层删除或添加触发监听事件

 

监听MapControl中对于图层添加和删除的事件

 

IActiveViewEvents_Event m_MapActiveViewEvents = m_mapControl.Map as IActiveViewEvents_Event;

 

//添加图层事件

m_MapActiveViewEvents.ItemAdded += new IActiveViewEvents_ItemAddedEventHandler(m_MapActiveViewEvents_ItemAdded);

//删除图层事件

m_MapActiveViewEvents.ItemDeleted += new IActiveViewEvents_ItemDeletedEventHandler(m_MapActiveViewEvents_ItemDeleted);

 

//事件处理

void m_MapActiveViewEvents_ItemDeleted(object item)
{
  ILayer pLayer = item as ILayer;
  //...
}
void m_MapActiveViewEvents_ItemAdded(object item)
{
  ILayer pLayer = item as ILayer;
  //...
}

MapControl图层删除或添加触发监听事件