<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Are layers in the map?? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/are-layers-in-the-map/m-p/767460#M493</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK.&amp;nbsp; It looks like the problem is a C# issue with the || operator and those null values.&amp;nbsp; Not exactly sure why, but this seems to fix the problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Map map = MapView.Active.Map;&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; gridLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.LAND_Grid", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; localMunicipalityLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.LAND_LocalMunicipality", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; administrativeAreaLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.LAND_AdministrativeArea", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; communitiesLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.LAND_Communities", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; depotAreaLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.LAND_DepotArea", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; pressureZoneLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.WAT_PressureZone", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;/P&gt;&lt;P&gt;if (gridLayer.Count() == 0 || localMunicipalityLayer.Count() == 0 || administrativeAreaLayer.Count() == 0 || communitiesLayer.Count() == 0 || depotAreaLayer.Count() == 0 || pressureZoneLayer.Count() == 0)&lt;BR /&gt; {&lt;BR /&gt; ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Please add the LAND and Water Pressure Zone layers before proceeding.", "Missing Layers");&lt;BR /&gt; return;&lt;BR /&gt; }&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Nov 2017 18:18:45 GMT</pubDate>
    <dc:creator>BrianBulla</dc:creator>
    <dc:date>2017-11-17T18:18:45Z</dc:date>
    <item>
      <title>Are layers in the map??</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/are-layers-in-the-map/m-p/767459#M492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to determine if specific layers are in the map before proceeding with more code.&amp;nbsp; The following produces an error at the line where I am checking to the value == null of each layer.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this the best way to do this?&amp;nbsp; Or is there a better way to check for specific layers in the map??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;protected override void OnClick()&lt;BR /&gt; {&lt;BR /&gt; var gridLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_Grid").FirstOrDefault() as BasicFeatureLayer;&lt;BR /&gt; var localMunicipalityLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_LocalMunicipality").FirstOrDefault() as BasicFeatureLayer;&lt;BR /&gt; var administrativeAreaLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_AdministrativeArea").FirstOrDefault() as BasicFeatureLayer;&lt;BR /&gt; var communitiesLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_Communities").FirstOrDefault() as BasicFeatureLayer;&lt;BR /&gt; var depotAreaLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_DepotArea").FirstOrDefault() as BasicFeatureLayer;&lt;BR /&gt; var pressureZoneLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_PressureZone").FirstOrDefault() as BasicFeatureLayer;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;****This is where I get the error!!&amp;nbsp; If I check these one at a time, it works, but when combining with the || is when the error happens.&amp;nbsp; In ArcMap 10.2, I have similar code running with no problems.****&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if ((gridLayer == null) || (localMunicipalityLayer == null) || (administrativeAreaLayer == null) || (communitiesLayer == null) || (depotAreaLayer == null) || (pressureZoneLayer = null))&lt;BR /&gt; {&lt;BR /&gt; ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Please add the LAND and Water Pressure Zone layers before proceeding.");&lt;BR /&gt; return;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("All the layers are there!!");&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Nov 2017 14:48:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/are-layers-in-the-map/m-p/767459#M492</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2017-11-17T14:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Are layers in the map??</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/are-layers-in-the-map/m-p/767460#M493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK.&amp;nbsp; It looks like the problem is a C# issue with the || operator and those null values.&amp;nbsp; Not exactly sure why, but this seems to fix the problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Map map = MapView.Active.Map;&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; gridLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.LAND_Grid", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; localMunicipalityLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.LAND_LocalMunicipality", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; administrativeAreaLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.LAND_AdministrativeArea", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; communitiesLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.LAND_Communities", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; depotAreaLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.LAND_DepotArea", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;BR /&gt; IEnumerable&amp;lt;Layer&amp;gt; pressureZoneLayer = map.GetLayersAsFlattenedList().Where(l =&amp;gt; l.Name.IndexOf("GISWRKS1.WORKS.WAT_PressureZone", StringComparison.CurrentCultureIgnoreCase) &amp;gt;= 0);&lt;/P&gt;&lt;P&gt;if (gridLayer.Count() == 0 || localMunicipalityLayer.Count() == 0 || administrativeAreaLayer.Count() == 0 || communitiesLayer.Count() == 0 || depotAreaLayer.Count() == 0 || pressureZoneLayer.Count() == 0)&lt;BR /&gt; {&lt;BR /&gt; ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Please add the LAND and Water Pressure Zone layers before proceeding.", "Missing Layers");&lt;BR /&gt; return;&lt;BR /&gt; }&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Nov 2017 18:18:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/are-layers-in-the-map/m-p/767460#M493</guid>
      <dc:creator>BrianBulla</dc:creator>
      <dc:date>2017-11-17T18:18:45Z</dc:date>
    </item>
  </channel>
</rss>

