How do you get a FeatureSource from a MapLayer in ESRI mobile 10.1.1

532
1
05-03-2013 03:46 PM
JoshPritt
New Contributor III
In the 9.3 code you could just do a MapLayer.Layer to get the FeatureLayer. But in 10.1.1 they changed FeatureLayer to FeatureSource AND removed the Layer property from MapLayer.

Here's the old code someone else wrote that I'm upgrading:

    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;
    }
0 Kudos
1 Reply
MichaelSalahoris
New Contributor II
I thing than in 10.1.1 the FeatureType object is used for layer. If so, perhaps the following piece of code is useful.

public static FeatureType FindFeatureTypeByName(string name)
{
foreach (FeatureSourceInfo fsinfo in MobileApplication.Current.Project.EnumerateFeatureSourceInfos())
{

foreach (FeatureType featureType in fsinfo.FeatureTypes)
{
if (featureType.Name.ToLower() == name.ToLower())
return featureType;
}

}
return null;
}

Best Regards
Michael Salahoris
0 Kudos