<?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: How to Iterate/Loop through all layers of a map service in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550519#M14898</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shaning,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have access to an &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//003z000000rq000000" rel="nofollow noopener noreferrer" target="_blank"&gt;IServerObjectHelper&amp;nbsp;object&lt;/A&gt;, you can then get an &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/#/IMapLayerInfos_Interface/0012000008w7000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;IMapLayerInfos object&lt;/A&gt;, which is a collection of &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/#/IMapLayerInfo4_Interface/001200000v4r000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;IMapLayerInfo&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only way I've done this is when using SOI and SOE's and in that case you get an IServerObjectHelper instantiated when the SOI/SOE starts up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;/// IServerObjectExtension implementation&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;/// This method is called when then service with this SOI is started&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;/// &amp;lt;param name="pSOH"&amp;gt;&amp;lt;/param&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;public&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Init&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;IServerObjectHelper pSOH&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IMapLayerInfos layerInfos &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pSOH&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapServer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;GetServerInfo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pSOH&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapServer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;DefaultMapName&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapLayerInfos&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// Now you can iterate through layerInfos&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IMapLayerInfo layerInfo&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; layerInfos&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Count&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; i&lt;SPAN class="operator token"&gt;++&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerInfo &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; layerInfos&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;get_Element&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure how to get access to the IServerObjectHelper object if you're not writing an SOI or SOE. Perhaps someone else can fill in that part!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Jordan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 23:48:53 GMT</pubDate>
    <dc:creator>JordanKing3</dc:creator>
    <dc:date>2021-12-11T23:48:53Z</dc:date>
    <item>
      <title>How to Iterate/Loop through all layers of a map service</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550515#M14894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to find a piece of ArcObjects code to Iterate/Loop through all layers of a map service.&amp;nbsp; Appreciate if you can provide the source.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Aug 2017 15:17:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550515#M14894</guid>
      <dc:creator>ShaningYu</dc:creator>
      <dc:date>2017-08-15T15:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Iterate/Loop through all layers of a map service</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550516#M14895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Shaning,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know how to do this in Python but not ArcObjects. Must your solution be ArcObjects (presuming C#, Java, or VB)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Micah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Aug 2017 15:36:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550516#M14895</guid>
      <dc:creator>MicahBabinski</dc:creator>
      <dc:date>2017-08-15T15:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Iterate/Loop through all layers of a map service</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550517#M14896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My project is an Add-In project.&amp;nbsp; Therefore, I have to use C#.&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Aug 2017 16:18:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550517#M14896</guid>
      <dc:creator>ShaningYu</dc:creator>
      <dc:date>2017-08-15T16:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Iterate/Loop through all layers of a map service</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550518#M14897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shaning,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ok, no problem. I think the same concepts will apply. You'll need to make an http request on the service with JSON as the response format. From there you can retrieve the layer list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider this service:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-bare" href="https://services.nationalmap.gov/arcgis/rest/services/transportation/MapServer" title="https://services.nationalmap.gov/arcgis/rest/services/transportation/MapServer"&gt;https://services.nationalmap.gov/arcgis/rest/services/transportation/MapServer&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following HTTP request will get you a JSON representation of that service:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://services.nationalmap.gov/arcgis/rest/services/transportation/MapServer?f=pjson" title="https://services.nationalmap.gov/arcgis/rest/services/transportation/MapServer?f=pjson"&gt;https://services.nationalmap.gov/arcgis/rest/services/transportation/MapServer?f=pjson&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notice that within the response there is a key called "layers" - the corresponding value is a representation of all the layers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/367069_pastedImage_4.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P style="text-align: center;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;To request more layer-specific info, just modify the request to include the layer ID and you can go deeper into the properties of each layer.&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;I googled "Make HTTP request C#" and here is the top result:&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;A class="link-titled" href="https://stackoverflow.com/questions/4015324/http-request-with-post" title="https://stackoverflow.com/questions/4015324/http-request-with-post"&gt;c# - HTTP request with post - Stack Overflow&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;Hope this helps.&lt;/P&gt;&lt;P style="text-align: left;"&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;Micah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Aug 2017 16:54:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550518#M14897</guid>
      <dc:creator>MicahBabinski</dc:creator>
      <dc:date>2017-08-15T16:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to Iterate/Loop through all layers of a map service</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550519#M14898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shaning,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have access to an &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//003z000000rq000000" rel="nofollow noopener noreferrer" target="_blank"&gt;IServerObjectHelper&amp;nbsp;object&lt;/A&gt;, you can then get an &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/#/IMapLayerInfos_Interface/0012000008w7000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;IMapLayerInfos object&lt;/A&gt;, which is a collection of &lt;A href="http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/#/IMapLayerInfo4_Interface/001200000v4r000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;IMapLayerInfo&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only way I've done this is when using SOI and SOE's and in that case you get an IServerObjectHelper instantiated when the SOI/SOE starts up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;/// &amp;lt;summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;/// IServerObjectExtension implementation&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;/// This method is called when then service with this SOI is started&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;/// &amp;lt;/summary&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;/// &amp;lt;param name="pSOH"&amp;gt;&amp;lt;/param&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;public&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Init&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;IServerObjectHelper pSOH&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IMapLayerInfos layerInfos &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pSOH&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapServer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;GetServerInfo&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pSOH&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapServer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;DefaultMapName&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapLayerInfos&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;// Now you can iterate through layerInfos&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; IMapLayerInfo layerInfo&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; layerInfos&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Count&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; i&lt;SPAN class="operator token"&gt;++&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerInfo &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; layerInfos&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;get_Element&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure how to get access to the IServerObjectHelper object if you're not writing an SOI or SOE. Perhaps someone else can fill in that part!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Jordan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:48:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-to-iterate-loop-through-all-layers-of-a-map/m-p/550519#M14898</guid>
      <dc:creator>JordanKing3</dc:creator>
      <dc:date>2021-12-11T23:48:53Z</dc:date>
    </item>
  </channel>
</rss>

