<?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 identify layer type in a web map in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136158#M12649</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Robert - I tried this code and it worked, but when I create a new map to do the test, like you did in the example, it breaks other parts of my code, which I probably could have fixed given a fair amount of work.&amp;nbsp; While working on some alternate ways to implement your suggested code, I stumbled upon this thread:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/95441"&gt;Finding service layer 'declaredClass' property (type) in AMD?&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which shows using instanceof.&amp;nbsp; I gave that a shot and it worked for me!&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;webMapLayers.forEach(function(element)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(element instanceof (ArcGISDynamicMapServiceLayer)) {&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks so much for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 Aug 2018 20:38:36 GMT</pubDate>
    <dc:creator>JacksonTrappett</dc:creator>
    <dc:date>2018-08-08T20:38:36Z</dc:date>
    <item>
      <title>How to identify layer type in a web map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136153#M12644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have many web maps on Portal that have several web layers in each.&amp;nbsp; They include dynamic services which are "map image layers" on portal, vector tile layers, and a cached basemap.&amp;nbsp; I'm writing some code (API 3.24) that will run an identify task on only the dynamic layers (map image layers) in the map, and I want to ignore the rest of the layers.&amp;nbsp; I used this code:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var webMapLayers = arrayUtils.map(this.map.layerIds, lang.hitch(this, function (layerId) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return this.map.getLayer(layerId);&lt;BR /&gt; }));&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;to get a list of the layers in the map.&amp;nbsp; If I log those on the console like this:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;webMapLayers&lt;/SPAN&gt;.forEach(function(element) { console.log(element); });&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I see this in the browser console:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN&gt;{_attrs: {…}, url: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fmyserver%2Farcgis%2Frest%2Fservices%2FBaseMap%2FBaseImage%2FMapServer" rel="nofollow" target="_blank"&gt;https://myserver/arcgis/rest/services/BaseMap/BaseImage/MapServer&lt;/A&gt;&lt;SPAN&gt;", _url: {…}, spatialReference: {…}, initialExtent: {…},&amp;nbsp;…}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{_attrs: {…}, url: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" rel="nofollow" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;myserver&lt;/SPAN&gt;/arcgis/rest/services/Hosted/MAPvectorTiles/VectorTileServer", _url: {…}, spatialReference: {…}, initialExtent: {…},&amp;nbsp;…}&lt;BR /&gt;&lt;SPAN&gt;{_attrs: {…}, url: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" rel="nofollow" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;myserver&lt;/SPAN&gt;/arcgis/rest/services…Tiles/VectorTileServer/resources/styles/root.json", _url: {…}, spatialReference: {…}, initialExtent: {…},&amp;nbsp;…}&lt;BR /&gt;&lt;SPAN&gt;{_attrs: {…}, url: "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" rel="nofollow" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;myserver&lt;/SPAN&gt;/arcgis/rest/services/TownMap_MIL1/MapServer", _url: {…}, spatialReference: {…}, initialExtent: {…},&amp;nbsp;…}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I can expand these and see hundreds, if not thousands of properties on each of these layers.&amp;nbsp; I was hoping to find one property in there somewhere that would let me determine which layer(s) are "map image layers" or dynamic layers, so I can only use those layers for the identify Task, but after spending quite a bit of time combing through, and also looking at the API documentation, I can't find any common property between those four layer types that lets me tell them apart.&amp;nbsp; I can of course manually tell which service is which by the service names, but I have a lot of webmaps all with different combinations of layers, and I want to write this code in a generic way so that no matter what is in the map, it will only pick out the dynamic (map image) layers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know an easy way to do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2018 22:02:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136153#M12644</guid>
      <dc:creator>JacksonTrappett</dc:creator>
      <dc:date>2018-07-13T22:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify layer type in a web map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136154#M12645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class=""&gt;Jackson,&lt;/P&gt;&lt;P class=""&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp; &amp;nbsp;It should be as simple as if(typeof(element) === ArcGISDynamicMapServiceLayer) {&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp; //do something&lt;/P&gt;&lt;P class=""&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Jul 2018 14:31:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136154#M12645</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-07-14T14:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify layer type in a web map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136155#M12646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Robert!&amp;nbsp; I gave this a try and it doesn't seem to be working for me:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;/P&gt;var webMapLayers = arrayUtils.map(this.map.layerIds, lang.hitch(this, function (layerId) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return this.map.getLayer(layerId);&lt;BR /&gt; }));&lt;BR /&gt;&lt;BR /&gt; webMapLayers.forEach(function(element)&lt;BR /&gt; {&lt;BR /&gt; console.log(element.id); //log 'id' outside if to show which layers we have&lt;BR /&gt; if(typeof(element) === ArcGISDynamicMapServiceLayer)&lt;BR /&gt; {&lt;BR /&gt; console.log(element.url); //log 'url' inside the loop to show which ones met the criteria&lt;BR /&gt; }&lt;BR /&gt; });&lt;/BLOCKQUOTE&gt;&lt;P&gt;and the results are:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;GJBaseImage_5386&lt;BR /&gt;17a8da996e40453e88d220cc7e59a462&lt;BR /&gt;VectorTile_3761&lt;BR /&gt;c44870356b774668891921a4aa44908f&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The first console.log returned 4 layer ids, outside the if statement, but the console.log inside the if statement didn't return anything because none of the layers met the criteria, even though the layer with the ID&lt;/P&gt;&lt;P&gt;"c44870356b774668891921a4aa44908f" is a dyamic (map image) layer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Jul 2018 15:19:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136155#M12646</guid>
      <dc:creator>JacksonTrappett</dc:creator>
      <dc:date>2018-07-18T15:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify layer type in a web map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136156#M12647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I also tried:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;if(typeof(element) === MapImageLayer)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;with the same result - it is false for all 4 layers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jul 2018 16:09:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136156#M12647</guid>
      <dc:creator>JacksonTrappett</dc:creator>
      <dc:date>2018-07-20T16:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify layer type in a web map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136157#M12648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jackson,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Sorry for the delay.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcgisUtils&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;createMap&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"4abe6a830b8f466dacf8abfde567a781"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"map"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;then&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;response&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; legendLayers &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcgisUtils&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;getLegendLayers&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;response&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; legendLayers&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;forEach&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;element&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;info&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;element&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;declaredClass&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&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="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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can use declaredClass for that&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:34:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136157#M12648</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-11T07:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to identify layer type in a web map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136158#M12649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Robert - I tried this code and it worked, but when I create a new map to do the test, like you did in the example, it breaks other parts of my code, which I probably could have fixed given a fair amount of work.&amp;nbsp; While working on some alternate ways to implement your suggested code, I stumbled upon this thread:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/95441"&gt;Finding service layer 'declaredClass' property (type) in AMD?&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which shows using instanceof.&amp;nbsp; I gave that a shot and it worked for me!&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;webMapLayers.forEach(function(element)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if(element instanceof (ArcGISDynamicMapServiceLayer)) {&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks so much for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2018 20:38:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-identify-layer-type-in-a-web-map/m-p/136158#M12649</guid>
      <dc:creator>JacksonTrappett</dc:creator>
      <dc:date>2018-08-08T20:38:36Z</dc:date>
    </item>
  </channel>
</rss>

