在 9.3 代码中,您只需执行 MapLayer.Layer 即可获得 FeatureLayer。但在 10.1.1 中,他们将 FeatureLayer 更改为 FeatureSource 并从 MapLayer 中删除了 Layer 属性。
这是别人写的我正在升级的旧代码:
static public MapLayer FindMapLayer(string sLayerName, Map theMap)
{
MapLayer lyr = null;
try
{
lyr = theMap.MapLayers[sLayerName];
}
catch { }
return lyr;
}
static public FeatureLayer FindFeatureLayer(string sLayerName, Map theMap)
{
FeatureLayer featLyr = null;
MapLayer lyr = FindMapLayer(sLayerName, theMap);
if (lyr != null)
{
featLyr = lyr.Layer;
}
return featLyr;
}