No worries! I think I figured it out. It might not be the most efficient coding but here is what I came up with! if (map.LayerCount == 0) { MessageBox.Show("There are no layers importerd. Please add Layers and try again"); IFeatureLayer layer = null; return layer; (1) } while (featureLayer != null) { if (featureLayer.Name.ToString() (2) == layerName) { return featureLayer; } else { featureLayer = (IFeatureLayer)enumLayer.Next(); } } IFeatureLayer layer2 = null; return layer2; (3)
if (map.LayerCount == 0) { MessageBox.Show("There are no layers importerd. Please add Layers and try again"); IFeatureLayer layer = null; return layer; (1) } while (featureLayer != null) { if (featureLayer.Name.ToString() (2) == layerName) { return featureLayer; } else { featureLayer = (IFeatureLayer)enumLayer.Next(); } } IFeatureLayer layer2 = null; return layer2; (3)
/** * ESRI sample method to get feature class layer by name, instead of index. * @param layerName the layer name as String. * @return layer as <code>FeatureLayer</code>. */ public static FeatureLayer getLayerByName(String layerName) { FeatureLayer layer = null; try { for (int i = 0; i < map.getLayerCount(); i++) { if (map.getLayer(i).getName().equalsIgnoreCase(layerName)) { layer = (FeatureLayer) map.getLayer(i); break; } } } catch (AutomationException ae) { ae.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // Returns the featurelayer return layer; }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.