<?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: Get properties of layers in a map service in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-properties-of-layers-in-a-map-service/m-p/230556#M21555</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;While this &lt;A href="https://developers.arcgis.com/javascript/jssamples/data_requestLayerInfo.html" rel="nofollow noopener noreferrer" target="_blank"&gt;sample&lt;/A&gt; shows how to get information about the fields of a layer in a service, you can query the type of layer by adding response.type in this function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function requestSucceeded(response, io){
&amp;nbsp; var fieldInfo, pad;
&amp;nbsp; pad = dojoString.pad;

&amp;nbsp; //toJson converts the given JavaScript object
&amp;nbsp; //and its properties and values into simple text 
&amp;nbsp; dojoJson.toJsonIndentStr = "&amp;nbsp; ";
&amp;nbsp; console.log("response as text:\n", dojoJson.toJson(response,true));
&amp;nbsp; dom.byId("status").innerHTML = "";
&amp;nbsp; dom.byId("content").value = response.type;

&amp;nbsp; //show field names and aliases
&amp;nbsp; if ( response.hasOwnProperty("fields") ) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("got some fields");
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldInfo = array.map(response.fields, function(f) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return pad("Field:", 8, " ", true) + pad(f.name, 25, " ", true) + 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pad("Alias:", 8, " ", true) + pad(f.alias, 25, " ", true) + 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pad("Type:", 8, " ", true) + pad(f.type, 25, " ", true);
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; dom.byId("content").value = response.type + "\n" + fieldInfo.join("\n");
&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp; dom.byId("content").value = response.type + "\n" + "No field info found. Please double-check the URL.";
&amp;nbsp; }

}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 11:12:37 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2021-12-11T11:12:37Z</dc:date>
    <item>
      <title>Get properties of layers in a map service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-properties-of-layers-in-a-map-service/m-p/230554#M21553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My app loads one of map services containing vector and raster layers. When identifying on a map, users expect to see query results from all visible vector layers in a data grid. In my case, all raster layers should be ignored because of no attribute data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when I looped through all visible layer IDs and run query tasks on each of them, I didn't see any API function or class gave info about the layer properties (such as &lt;STRONG&gt;&lt;EM&gt;Geometry Type&lt;/EM&gt; &lt;/STRONG&gt;or &lt;STRONG&gt;&lt;EM&gt;Fields&lt;/EM&gt;, &lt;/STRONG&gt;basically whatever returns from hitting a layer url in a browser). Such properties appear only with a query result. Surely a simple xhr request would return all layer info. But that's another series of another roundtrips to the server. Or maybe I missed something hidden deep in API docs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think my use case of identifying all layers is unique or peculiar. What's Esri's arugment for API not exposing or packing the complete layer properites when loading them into the Map instance? However, it already exposes some of properties such as &lt;STRONG&gt;Definition &lt;/STRONG&gt;at the service level as an array, and &lt;STRONG&gt;&lt;STRONG&gt;Default Visibility&lt;/STRONG&gt; and Max/&lt;STRONG&gt;Min Scale&lt;/STRONG&gt; &lt;/STRONG&gt;in individual&lt;STRONG&gt; LayerInfo&lt;/STRONG&gt;s. A bit strange, isn't it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Feb 2016 20:01:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-properties-of-layers-in-a-map-service/m-p/230554#M21553</guid>
      <dc:creator>ChenLiang</dc:creator>
      <dc:date>2016-02-03T20:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Get properties of layers in a map service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-properties-of-layers-in-a-map-service/m-p/230555#M21554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've been working on the same thing. There is a similar thread in the ArcGIS API for JavaScript place, authored by me (yup, I am to lazy to search and link here at the moment).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;map.getLayer(yourLayer).geometryType gives you your geometry type... is the problem that you have a service, not the layer id that map.getLayer expects? map.getLayer(yourLayer).renderer.symbol or map.getLayer(yourLayer).renderer._symbols gives you the symbol information you'd want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can get the fields/attributes from the identify task. It returns results, and you'd want thoseResults.feature.attributes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Mar 2016 11:37:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-properties-of-layers-in-a-map-service/m-p/230555#M21554</guid>
      <dc:creator>TyroneBiggums</dc:creator>
      <dc:date>2016-03-16T11:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get properties of layers in a map service</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-properties-of-layers-in-a-map-service/m-p/230556#M21555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;While this &lt;A href="https://developers.arcgis.com/javascript/jssamples/data_requestLayerInfo.html" rel="nofollow noopener noreferrer" target="_blank"&gt;sample&lt;/A&gt; shows how to get information about the fields of a layer in a service, you can query the type of layer by adding response.type in this function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function requestSucceeded(response, io){
&amp;nbsp; var fieldInfo, pad;
&amp;nbsp; pad = dojoString.pad;

&amp;nbsp; //toJson converts the given JavaScript object
&amp;nbsp; //and its properties and values into simple text 
&amp;nbsp; dojoJson.toJsonIndentStr = "&amp;nbsp; ";
&amp;nbsp; console.log("response as text:\n", dojoJson.toJson(response,true));
&amp;nbsp; dom.byId("status").innerHTML = "";
&amp;nbsp; dom.byId("content").value = response.type;

&amp;nbsp; //show field names and aliases
&amp;nbsp; if ( response.hasOwnProperty("fields") ) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("got some fields");
&amp;nbsp;&amp;nbsp;&amp;nbsp; fieldInfo = array.map(response.fields, function(f) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return pad("Field:", 8, " ", true) + pad(f.name, 25, " ", true) + 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pad("Alias:", 8, " ", true) + pad(f.alias, 25, " ", true) + 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pad("Type:", 8, " ", true) + pad(f.type, 25, " ", true);
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; dom.byId("content").value = response.type + "\n" + fieldInfo.join("\n");
&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp; dom.byId("content").value = response.type + "\n" + "No field info found. Please double-check the URL.";
&amp;nbsp; }

}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:12:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-properties-of-layers-in-a-map-service/m-p/230556#M21555</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-11T11:12:37Z</dc:date>
    </item>
  </channel>
</rss>

