is it posible ?
I use javascript 4.11
'https://js.arcgis.com/4.11/esri/themes/light/main.css', 'https://js.arcgis.com/4.11/', "https://unpkg.com/angular-esri-map@2.0.5/dist/angular-esri-map.js"
const view = new MapView({ container: "viewDiv", map: new WebMap({ basemap: "satellite", layers: [ new FeatureLayer({ url: https://portalgis.sinopecarg.com.ar/arcgis/rest/services/SERVICIOS_GIS/InstalacionesPozos_GSJ/MapServer/1, new FeatureLayer({ url: https://portalgis.sinopecarg.com.ar/arcgis/rest/services/SERVICIOS_GIS/InstalacionesPozos_GSJ/MapServer/2 ] }),
I need do a query by:
const pozosA = view.map.layers.getItemAt(1); const pozosI = view.map.layers.getItemAt(2);How have I to do ???Regards
Eduardo
You can wrap multiple requests in a Promise.all
Promise<SPAN class="punctuation token">.</SPAN><SPAN class="token function">all</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN> layer1<SPAN class="punctuation token">.</SPAN><SPAN class="token function">queryFeatures</SPAN><SPAN class="punctuation token">(</SPAN>query1<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> layer2<SPAN class="punctuation token">.</SPAN><SPAN class="token function">queryFeatures</SPAN><SPAN class="punctuation token">(</SPAN>query2<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">then</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>result1<SPAN class="punctuation token">,</SPAN> result2<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">// use your results</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><SPAN></SPAN></SPAN>
Only issue in this case, is if one request errors, they are both rejected. We have a utility in the API to handle this called esri/core/promiseUtils#eachAlways
There is a native Promise.allSettled that has the same behavior and will resolve when all promises are fulfilled, or rejected.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.