Select to view content in your preferred language

Query a layer with multiple search criterias

4785
28
Jump to solution
04-09-2014 08:05 PM
kiranbodhasrungi
New Contributor
hi,

i have a requirement in my project where i have to query the layer with the help of multiple search fields.How can i achieve this?

till now i have been doing it like this:

findParams.layerIds = [1];
findParams.searchFields = ["STREET_NAME", "STREET_NUMBER"];

findTask.execute(findParams, showResults);

I have  a single text box and i query the map with the help street name OR number.How can i combine both(similar to AND) to filter results?

thanks in advance.

keran.
0 Kudos
28 Replies
MayJeff
Occasional Contributor

Can you post the entire code in JSFiddle? Thanks.

0 Kudos
kiranbodhasrungi
New Contributor

let me know if need the complete source code i can share it with you,i never used jsfiddle.

0 Kudos
MayJeff
Occasional Contributor

That will be great if you can post your complete source code.  Thanks for your time.

0 Kudos
kiranbodhasrungi
New Contributor

Hi,

i have attached the complete code.this is a simple eclipse web applicaiton,taket he web contents and ingore the rest.

Let me know if you have any issues.

0 Kudos
MayJeff
Occasional Contributor

Thank you for posting your code.  I run your index.html but no result return.  Am I missing something?

0 Kudos
kiranbodhasrungi
New Contributor

What are you trying to do?what is your requirement?

0 Kudos
MayJeff
Occasional Contributor

I try to find a sample query able to search subdivision, city, parcel by address & parcel id when using enter information in the text box. Then return results in datagrid.  I only find sample using Find task but not using query Task. Besides that, would like to have select option for city so able to select and zoom to the city boundary.

Thanks.

0 Kudos
kiranbodhasrungi
New Contributor

Here is the code to query a layer:

function init() {

  center = [-72.65065, 41.56232];

        zoom = 11;

        map = new esri.Map("map", {

          basemap: "topo",

         // center: center,

          zoom: zoom

        });

  var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer(

  "http://12.132.106.112:6080/arcgis/rest/services/MidParcelFabric/MapServer");

  map.addLayer(dynamicMapServiceLayer);

  queryTask = new esri.tasks.QueryTask(

  "http://12.132.106.112:6080/arcgis/rest/services/MidParcelFabric/MapServer/1");

  query = new esri.tasks.Query();

  query.returnGeometry = true;

  query.outFields = [ "OLD_MBL_1", "MAPLOT_1" , "MAP_1", "LOT_1", "CAMAACCT_1", "pid", "PROPERTY_LOCATIO", "STREET_NUMBER", "STREET_NAME" ,"UNIT__", "GRANTEE", "CO_GRANTEE_S_NAM", "Shape_Length", "Shape_Area" ];

  symbol = new esri.symbol.SimpleFillSymbol();

  symbol.style = esri.symbol.SimpleFillSymbol.STYLE_SOLID;

  symbol.color = new dojo.Color([98, 194, 204, 0.5]);

  }

  dojo.addOnLoad(init);

  function executeQueryTask(streetName,streetNumber,ownerName,maplot,lot,unit,accountID,pid) {

  var queryString="";

  queryString+= "STREET_NAME" + " like '%" + streetName +"%'" ;

  queryString+= " OR " + "GRANTEE" + " like '%" + streetName +"%'" ;

  //queryString+= " OR " + "pid" + " = " + streetName ;

  console.log(queryString);

  query.where = queryString;

  queryTask.execute(query, showResults);

  }

Call executeQuery() upon click or a search button or enter button,pass required parameters.

Pass the city value also to this function.

If you want a dojo datagrid instead of html table use the new.html in the code that i have given you.

Let me know if this solves your problem.

0 Kudos
MayJeff
Occasional Contributor

Thank you for your time.  I will work on it and let you know.

0 Kudos