AnsweredAssumed Answered

Multiple query tasks

Question asked by MoritzP12 on Jul 6, 2015
Latest reply on Jul 7, 2015 by MoritzP12

Hi, I have carried out a queryTask on a map service that returns a polygon when I input a postcode. Within the same service, there is an additional layer where I want to query a local authority name on. I would like to carry out a querytask on this layer at the same time so that the map returns a polygon relating to the postcode input and also tells me what local authority it is contained within. I will ultimately show the local authority as text in a separate widget. Can anyone help please? Here's my code so far with the second queryTask cancelled out near the middle as I'm not sure where it should go??

var query = new Query();
  query.returnGeometry = true;
  query.outFields = [
  "POSTCODE"
  ];

  on(dom.byId("execute"), "click", execute);

  function execute() {
  query.text = dom.byId("Postcode").value;
  queryTask.execute(query, showResults);
  }
  function showResults(results) {
  var resultItems = [];
  var resultCount = results.features.length;
  for (var i = 0; i < resultCount; i++) {
  var featureAttributes = results.features[i].attributes;

  var graphic = results.features[i];
  graphic.setSymbol(symbol);
  map.graphics.add(graphic);

  //var queryTask2 = new QueryTask("http://rest/services/live/SEARCH/MapServer/15");
  //query2 = new.esri.tasks.Query();
  //query2.returnGeometry - false;
  //query2.where = ""
var strNum = 100;
  var newExtent = graphic.geometry.getExtent();
  newExtent.xmin = newExtent.xmin - strNum;
  newExtent.ymin = newExtent.ymin - strNum;
  newExtent.xmax = newExtent.xmax + strNum;
  newExtent.ymax = newExtent.ymax + strNum;
  map.setExtent(newExtent);

  for (var attr in featureAttributes) {
  resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>");
  }
  resultItems.push("<br>");
  }
  dom.byId("info").innerHTML = resultItems.join("");

  }
  dom.byId("results")

  function addToMap(result) {
  debugger;
  }
 });

Outcomes