<?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: IdentifyTask with multiple map services in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifytask-with-multiple-map-services/m-p/26844#M2316</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In a nutshell you will probably want to loop through an array of IdentifyTasks that each point to your repective services and properties.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you have your array built up or something similar then you might want to look at Dojo.DeferredList of more current implementation of Dojo.PromiseAll.&amp;nbsp; Note that the IdentifyTask.execute return a Dojo.Deferred object this is key in being able to use the methods mentioned above. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The DeferredList allows you to make asynch calls to the server simultaneously and it will wait until the excute tasks have all finished. Below is some sample code that uses the DeferredList to execute select statements to the server simulateously. In your case, you would build your DeferredList (or better PromiseAll) of dojo.deferred array objects and them make the request to the server (identifyTask.execute()) and wait until the calls have finished (dl.then ..) .&amp;nbsp; The within the deferredList.then is used to build up the results that are returned and then turn the values back in some kind of order that makes sense to you and your application. In my example below, I return a custom object "selectionLayers" that I need for processing (returnDeferred.resolve({ 'success': true, 'selectionLayers': selectionLayers }) )&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am sure there are other ways to do this, but so far without having to create a custom service that does all this for me, I have found this to work for me when I am making multiple simultaneous requests to the server - if a deferred object is returned from the Javascript API.&amp;nbsp; Good Luck!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;//sample code - not for production //should consider using Promise and PromiseAll function getSelectionLayerDeferred(featureLayerArray, selectQuery) { &amp;nbsp; var returnDeferred = null; &amp;nbsp; var selectionLayers = []; &amp;nbsp; var defferredCallArray = [];&amp;nbsp; &amp;nbsp; require(["dojo/DeferredList", "dojo/Deferred"], function (DeferredList, Deferred) { &amp;nbsp;&amp;nbsp;&amp;nbsp; returnDeferred = new Deferred();&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.forEach(featureLayerArray, function (flayer) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var defferredCall = flayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //cast the dojo.deferred to a promise so we can use the new&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //dojo/promise/all in lieu of dojo/DeferredList (deprecated at v 1.8) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; defferredCallArray.push(defferredCall); &amp;nbsp;&amp;nbsp;&amp;nbsp; });&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var dl = new DeferredList(defferredCallArray); &amp;nbsp;&amp;nbsp;&amp;nbsp; dl.then(function (results) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Executed when all deferred resolved &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (results.length &amp;gt; 0) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.forEach(results, function (result) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (result[0] === true &amp;amp;&amp;amp; result[1].length &amp;gt; 0) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectionLayers.push({ 'featureLayer': result[1][0].getLayer(), 'features': result[1] }); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnDeferred.resolve({ 'success': true, 'selectionLayers': selectionLayers }); &amp;nbsp;&amp;nbsp;&amp;nbsp; }, function (err) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnDeferred.resolve({ 'success': false, 'selectionLayers': null, 'error': err }); &amp;nbsp;&amp;nbsp;&amp;nbsp; }); &amp;nbsp; }); &amp;nbsp; return returnDeferred; }&amp;nbsp; //here is some sample code of how I implement it //not for production //select related records &amp;nbsp; var selQuery = new esri.tasks.Query(); &amp;nbsp; selQuery.where = "GAZ_ID = " + updateGraphic.attributes["GAZ_ID"]; var deferred = getSelectionLayerDeferred([landformAllpointFeatureService], selectQuery); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deferred.then(function (results) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (results.success &amp;amp;&amp;amp; results.selectionLayers) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //bind to data to add to grid &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //TODO: work in progress ...&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buildDataStore(results.selectionLayers[0].features) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setDisableToolbarControls(ToolbarType.Editor_Select, false); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hideProcessingDialog(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; refreshMap(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setDisableToolbarControls(ToolbarType.Editor_Select, true); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hideProcessingDialog(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } }, function (error) { &amp;nbsp;&amp;nbsp;&amp;nbsp; // Do something on failure. &amp;nbsp;&amp;nbsp;&amp;nbsp; hideProcessingDialog(); &amp;nbsp;&amp;nbsp;&amp;nbsp; drawToolbar.deactivate(); &amp;nbsp;&amp;nbsp;&amp;nbsp; //var err = results.error; &amp;nbsp;&amp;nbsp;&amp;nbsp; alert("Error ...")&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Mar 2013 20:34:34 GMT</pubDate>
    <dc:creator>DianaBenedict</dc:creator>
    <dc:date>2013-03-19T20:34:34Z</dc:date>
    <item>
      <title>IdentifyTask with multiple map services</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifytask-with-multiple-map-services/m-p/26843#M2315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to figure out what is the best way to go about using the IdentifyTask with multiple map services.&amp;nbsp; All the map services are on the same ArcGIS Server instance, but I have several map services that need to have identify capability.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a best practice that people are using to make this work?&amp;nbsp; Seems like this is a "common" requirement, but I did not see anything in the docs that talk about it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Charlie&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 20:04:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifytask-with-multiple-map-services/m-p/26843#M2315</guid>
      <dc:creator>DougCollins</dc:creator>
      <dc:date>2013-03-19T20:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: IdentifyTask with multiple map services</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifytask-with-multiple-map-services/m-p/26844#M2316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In a nutshell you will probably want to loop through an array of IdentifyTasks that each point to your repective services and properties.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you have your array built up or something similar then you might want to look at Dojo.DeferredList of more current implementation of Dojo.PromiseAll.&amp;nbsp; Note that the IdentifyTask.execute return a Dojo.Deferred object this is key in being able to use the methods mentioned above. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The DeferredList allows you to make asynch calls to the server simultaneously and it will wait until the excute tasks have all finished. Below is some sample code that uses the DeferredList to execute select statements to the server simulateously. In your case, you would build your DeferredList (or better PromiseAll) of dojo.deferred array objects and them make the request to the server (identifyTask.execute()) and wait until the calls have finished (dl.then ..) .&amp;nbsp; The within the deferredList.then is used to build up the results that are returned and then turn the values back in some kind of order that makes sense to you and your application. In my example below, I return a custom object "selectionLayers" that I need for processing (returnDeferred.resolve({ 'success': true, 'selectionLayers': selectionLayers }) )&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am sure there are other ways to do this, but so far without having to create a custom service that does all this for me, I have found this to work for me when I am making multiple simultaneous requests to the server - if a deferred object is returned from the Javascript API.&amp;nbsp; Good Luck!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;//sample code - not for production //should consider using Promise and PromiseAll function getSelectionLayerDeferred(featureLayerArray, selectQuery) { &amp;nbsp; var returnDeferred = null; &amp;nbsp; var selectionLayers = []; &amp;nbsp; var defferredCallArray = [];&amp;nbsp; &amp;nbsp; require(["dojo/DeferredList", "dojo/Deferred"], function (DeferredList, Deferred) { &amp;nbsp;&amp;nbsp;&amp;nbsp; returnDeferred = new Deferred();&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.forEach(featureLayerArray, function (flayer) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var defferredCall = flayer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //cast the dojo.deferred to a promise so we can use the new&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //dojo/promise/all in lieu of dojo/DeferredList (deprecated at v 1.8) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; defferredCallArray.push(defferredCall); &amp;nbsp;&amp;nbsp;&amp;nbsp; });&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var dl = new DeferredList(defferredCallArray); &amp;nbsp;&amp;nbsp;&amp;nbsp; dl.then(function (results) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Executed when all deferred resolved &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (results.length &amp;gt; 0) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.forEach(results, function (result) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (result[0] === true &amp;amp;&amp;amp; result[1].length &amp;gt; 0) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; selectionLayers.push({ 'featureLayer': result[1][0].getLayer(), 'features': result[1] }); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnDeferred.resolve({ 'success': true, 'selectionLayers': selectionLayers }); &amp;nbsp;&amp;nbsp;&amp;nbsp; }, function (err) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnDeferred.resolve({ 'success': false, 'selectionLayers': null, 'error': err }); &amp;nbsp;&amp;nbsp;&amp;nbsp; }); &amp;nbsp; }); &amp;nbsp; return returnDeferred; }&amp;nbsp; //here is some sample code of how I implement it //not for production //select related records &amp;nbsp; var selQuery = new esri.tasks.Query(); &amp;nbsp; selQuery.where = "GAZ_ID = " + updateGraphic.attributes["GAZ_ID"]; var deferred = getSelectionLayerDeferred([landformAllpointFeatureService], selectQuery); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; deferred.then(function (results) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (results.success &amp;amp;&amp;amp; results.selectionLayers) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //bind to data to add to grid &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //TODO: work in progress ...&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buildDataStore(results.selectionLayers[0].features) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setDisableToolbarControls(ToolbarType.Editor_Select, false); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hideProcessingDialog(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; refreshMap(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; setDisableToolbarControls(ToolbarType.Editor_Select, true); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hideProcessingDialog(); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } }, function (error) { &amp;nbsp;&amp;nbsp;&amp;nbsp; // Do something on failure. &amp;nbsp;&amp;nbsp;&amp;nbsp; hideProcessingDialog(); &amp;nbsp;&amp;nbsp;&amp;nbsp; drawToolbar.deactivate(); &amp;nbsp;&amp;nbsp;&amp;nbsp; //var err = results.error; &amp;nbsp;&amp;nbsp;&amp;nbsp; alert("Error ...")&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 20:34:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifytask-with-multiple-map-services/m-p/26844#M2316</guid>
      <dc:creator>DianaBenedict</dc:creator>
      <dc:date>2013-03-19T20:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: IdentifyTask with multiple map services</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifytask-with-multiple-map-services/m-p/26845#M2317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;use a bunch of dojo/Deferred's for each IdentifyTask in a dojo/DeferredList.&amp;nbsp; I think I used this example as a start: &lt;/SPAN&gt;&lt;A href="http://jsfiddle.net/blordcastillo/mULcz/"&gt;http://jsfiddle.net/blordcastillo/mULcz/&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Mar 2013 20:34:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifytask-with-multiple-map-services/m-p/26845#M2317</guid>
      <dc:creator>deleted-user-RAnWn8DDSd1P</dc:creator>
      <dc:date>2013-03-19T20:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: IdentifyTask with multiple map services</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifytask-with-multiple-map-services/m-p/26846#M2318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for replies, this helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Charlie&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 18:40:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identifytask-with-multiple-map-services/m-p/26846#M2318</guid>
      <dc:creator>DougCollins</dc:creator>
      <dc:date>2013-03-25T18:40:46Z</dc:date>
    </item>
  </channel>
</rss>

