如何从ESRI mobile 10.1.1中的MapLayer获取FeatureSource
在9.3代码中,您只需执行MapLayer.Layer即可获得FeatureLayer。 但在10.1.1中,他们将FeatureLayer更改为FeatureSource,并从MapLayer中删除了图层特性 这是别人写的我正在升级的旧代码:如何从ESRI mobile 10.1.1中的MapLayer获取FeatureSource,mobile,esri,Mobile,Esri,在9.3代码中,您只需执行MapLayer.Layer即可获得FeatureLayer。 但在10.1.1中,他们将FeatureLayer更改为FeatureSource,并从MapLayer中删除了图层特性 这是别人写的我正在升级的旧代码: static public MapLayer FindMapLayer(string sLayerName, Map theMap) { MapLayer lyr = null; try {
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;
}
我想出来了。您必须查看mobilecache.FeatureSources集合。该名称将与您在MXD中为图层命名的名称(目录中显示的确切字符串)相匹配,该图层在ArcGIS Server中作为服务发布
public static FeatureSource FindFeatureLayer(string featureSourceName, Map theMap)
{
//TODO: this may not work if the feature source name doesn't match the map layer name!
FeatureSource featSource = null;
//10.1.1
//Just grab the first map layer in order to get at the mobile cache and its
// collection of feature sources.
MobileCacheMapLayer cacheMapLayer = GetMobileCacheLayer(theMap);
if (cacheMapLayer != null)
{
featSource = cacheMapLayer.MobileCache.FeatureSources[featureSourceName];
}
return featSource;
}
public static MobileCacheMapLayer GetMobileCacheLayer(Map theMap)
{
foreach (var layer in theMap.MapLayers)
{
if(layer is MobileCacheMapLayer)
return (MobileCacheMapLayer)layer;
}
return null;
}