arcgis for js 之 QueryTask查询

require([
         "esri/graphic",
        "esri/layers/GraphicsLayer",
         "esri/tasks/query",
         "esri/tasks/QueryTask",
         "esri/Color",
         "esri/InfoTemplate",
         "esri/geometry/Extent"],
         function(Graphic,GraphicsLayer,Query,QueryTask,Color,InfoTemplate,Extent){
            var tield="1=1"
            switch(true){//多条件查询
                case id!="": tield+=" and WBMC like '%"+wbname+"%'";
                case name!="": tield+=" and FRXM like '%"+wbfaren+"%'";
                case sex!="": tield+=" and FRLXDH like '%"+wbphone+"%'";
                case number!="": tield+=" and WBBM like '%"+wanumber+"%'";
                case wbaddress!="": tield+=" and DZJC like '%"+wbaddress+"%'";

            }

            var url="https://192.x.x.x:8888/arcgis/rest/services/MapServer/0";   

            var queryTask = new QueryTask(url);//查询图层
             //设置查询参数
             var query = new Query();
             query.returnGeometry = false;//不需要返回Geometry
             //需要返回的字段
             query.outFields = ["ID","NAME","NUMBER","SEX","UPDATETIME"];
             query.where = tield; //查询条件
             //4.进行查询,完成后调用showResults方法    
             queryTask.execute(query,showResults);
             

             function showResults(results){

                for(var a=0;a                    var data=results.features[a].attributes;//查询结果的每条记录

                }

                ………………

             }

你可能感兴趣的:(ArcGis,for,js)