简体   繁体   English

使用 QueryTask ArcgGIS JS Api 3 进行多重查询

[英]Multiple query using QueryTask ArcgGIS JS Api 3

I am using QueryTask in ArcgGIS JS Api 3 and I want to execute multiple query in one call, I took a look at thedocumentation and I didn't find the possibility to do it我在 ArcgGIS JS Api 3 中使用 QueryTask,我想在一次调用中执行多个查询,我查看了文档,但没有找到这样做的可能性

this is what I am using这就是我正在使用的


arraygraphic.map(async (e)=>{
        let query = new esri.tasks.Query();
        query.where = "id = '"+id+"'";
        query.outFields = ["*"];
        let response = await queryTask.execute(query)
      })

and this is what I want to do这就是我想做的


let queryList=[];
arraygraphic.map(async (e)=>{
        let query = new esri.tasks.Query();
        query.where = "id = '"+id+"'";
        query.outFields = ["*"];
        queryList.push(query)
      })
let response = await queryTask.execute(queryList)

any suggestion or help?有什么建议或帮助吗? thank you in advance先感谢您

You can only have one "Query", but you can create a better where statement that searches for all the "id" in a single where statement.您只能有一个“查询”,但您可以创建一个更好的where语句,在单个where语句中搜索所有“id”。

Your where statement would end up looking something like: id in (1,2,3,4) .您的 where 语句最终看起来像: id in (1,2,3,4)

You can find more details about the supported SQL under "Request parameters" at https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer-.htm#GUID-62EE7495-8688-4BD0-B433-89F7E4476673您可以在https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer-.htm#GUID-62EE7495-8的“请求参数”下找到有关受支持的 SQL 的更多详细信息4BD0-B433-89F7E4476673

If you're not able to put all the queries in one SQL statement as Bjorn suggested (eg queries to multiple layers), then you can add the requests to an array and use promise.all to send all the requests https://developers.arcgis.com/javascript/3/jssamples/query_deferred_list.html如果您无法按照 Bjorn 的建议将所有查询放在一个 SQL 语句中(例如查询多层),那么您可以将请求添加到数组并使用 promise.all 发送所有请求Z5E056C500A1C47BADE5Z1://developers500A1C47BADE5Z1 .arcgis.com/javascript/3/jssamples/query_deferred_list.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM