//**************************************************
版权所有,转载请保留作者信息。
//------------------------------------------------------------------
名 称:VC6.0+ArcGIS二次开发------将IFEATURECLASS添加进IMAP
作 者:www.gisfoot.com
MSN: gisfoot@hotmail.com
时 间:2007-10-8 周一
//**************************************************
IFeatureLayerPtr ipFeatLayer(CLSID_FeatureLayer);
ipFeatLayer->put_Name( bstrFtClsName );
ipFeatLayer->putref_FeatureClass( ipFtCls );
//在IMAP中添加图层
ipMap->AddLayer( (ILayerPtr)ipFeatLayer );
另外,对于拓扑数据的添加需要做类似的工作。
//获得当前选中要素所在的要素类
IFeatureClassContainerPtr ipFtClsContainer( m_ipTopology );
if( ipFtClsContainer == NULL ) return ;
IFeatureClassPtr ipFtCls;
CComBSTR bstrFtClsName;
long nCount;
ipFtClsContainer->get_ClassCount( &nCount );
for( long i=0; i<nCount; i++ )
{
IFeatureLayerPtr ipFeatLayer(CLSID_FeatureLayer);
ipFeatLayer->putref_FeatureClass( ipFtCls );
//在IMAP中添加图层
ipMap->AddLayer( (ILayerPtr)ipFeatLayer );
}
ITopologyLayerPtr iptopoLayer(CLSID_TopologyLayer);
iptopoLayer->putref_Topology( m_ipTopology );
ipMap->AddLayer( (ILayerPtr)iptopoLayer );