I am trying to use identify task with layerOption "all" ("visible" would be better but IIRC that has never worked and I don't have time to deal with that right now) to return items from all the layers in a map service when the user clicks the map. If multiple points from one layer are overlapping, it returns those, but if there are overlapping items from multiple layers in the MapImageService it only returns a response with items from that one layer.
I think dynamic layers are enabled in the map service, but I am not using that functionality in my script.
<SPAN class="keyword token">var</SPAN> fieldDataImageLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">MapImageLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"https://myRESTurl/MapServer/"</SPAN><SPAN class="punctuation token">,</SPAN>
title<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Field Data"</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="token function">executeIdentifyTask</SPAN><SPAN class="punctuation token">(</SPAN>event<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//set up identify task for different layer types.</SPAN>
tasks <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
fieldDataIdentifyTask <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">IdentifyTask</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
url<SPAN class="punctuation token">:</SPAN> fieldDataImageLayer<SPAN class="punctuation token">.</SPAN>url<SPAN class="punctuation token">,</SPAN>
layerOption<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"all"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="comment token">//layerIds: [0,1,2,3,4,5,6,7,8,9,] - this didn't help</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
tasks<SPAN class="punctuation token">.</SPAN><SPAN class="token function">push</SPAN><SPAN class="punctuation token">(</SPAN>fieldDataIdentifyTask<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//common parameters</SPAN>
params <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">IdentifyParameters</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
params<SPAN class="punctuation token">.</SPAN>tolerance <SPAN class="operator token">=</SPAN> <SPAN class="number token">12</SPAN><SPAN class="punctuation token">;</SPAN>
params<SPAN class="punctuation token">.</SPAN>returnGeometry <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">;</SPAN>
params<SPAN class="punctuation token">.</SPAN>width <SPAN class="operator token">=</SPAN> view<SPAN class="punctuation token">.</SPAN>width<SPAN class="punctuation token">;</SPAN>
params<SPAN class="punctuation token">.</SPAN>height <SPAN class="operator token">=</SPAN> view<SPAN class="punctuation token">.</SPAN>height<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//allow picking top layer only (default behavior)</SPAN>
params<SPAN class="punctuation token">.</SPAN>geometry <SPAN class="operator token">=</SPAN> event<SPAN class="punctuation token">.</SPAN>mapPoint<SPAN class="punctuation token">;</SPAN>
params<SPAN class="punctuation token">.</SPAN>mapExtent <SPAN class="operator token">=</SPAN> view<SPAN class="punctuation token">.</SPAN>extent<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">//process and resolve multiple promises at once</SPAN>
<SPAN class="keyword token">var</SPAN> promises <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">for</SPAN> <SPAN class="punctuation token">(</SPAN>i <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN> i <SPAN class="operator token"><</SPAN> tasks<SPAN class="punctuation token">.</SPAN>length<SPAN class="punctuation token">;</SPAN> i<SPAN class="operator token">++</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
promises<SPAN class="punctuation token">.</SPAN><SPAN class="token function">push</SPAN><SPAN class="punctuation token">(</SPAN>tasks<SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">execute</SPAN><SPAN class="punctuation token">(</SPAN>params<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">var</SPAN> responses <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">all</SPAN><SPAN class="punctuation token">(</SPAN>promises<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> responses<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>the promises thing initially made more sense when I was targeting multiple map image services
Do I just need to convert everything to 10 different feature layers and just use HitTest() at this point? Would that mess up the layerlist groupings and map render speed? There are thousands of points.
ETA: It looks like when I specify the "layerIds: [5]" or whatever single sublayer, and click on an item from another sublayer, it still returns results even thought that layerId isn't in the array.