AnsweredAssumed Answered

Query with multiple results

Question asked by dexconor on Apr 23, 2014
Latest reply on Apr 29, 2014 by TimSparq
 queryTask = new esri.tasks.QueryTask("http://localhost:6080/arcgis/rest/services/v1/MapInfo/MapServer/6");
    query = new esri.tasks.Query();
    query.returnGeometry = true;
    query.outSpatialReference = new esri.SpatialReference(102100);
    if (bldgV) {
  var tempNURL = new Array();
  tempNURL = bldgV.split(",");
  var queryN="";
   for(var i=0;i<tempNURL.length;i++){
    queryN += "Number = '" + tempNURL[i] + "' OR "; 
   }
  queryN = queryN.slice(0, -4);
        query.where = queryN;
  //alert(query.where);
  queryTask.execute(query, getLocRes);
    } else if (bldgAV) {
        bldgAV = bldgAV.toUpperCase();
        var tempURL = new Array();
        tempURL = bldgAV.split(",");
        var queryH = "";
   for (var i = 0; i < tempURL.length; i++) {
    queryH += "Abbrev = '" + tempURL[i] + "' OR ";
   }
        queryH = queryH.slice(0, -3);
        query.where = queryH;
  //alert(query.where);
  queryTask.execute(query, getLocRes);
    }else{//alert("pass");
 }



function getLocRes(results) {
 console.log("getLocRes",results);
 var geom;
 geom = results.features.geometry;
 console.log("geom",geom);
 var extent = geom.getExtent();
 var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([80, 0, 0]), 2), new dojo.Color([80, 0, 0, 0.5]));
 var res = results.features;
 console.log("symbol",symbol);
        alert("asdf");
 map.graphics.clear();
 for (var i = 0;i < res.length; i++) {
  var graphic = res[i];
  graphic.setSymbol(symbol);
  map.graphics.add(graphic);
 }
 alert(map.graphics.graphics.length);
 map.setExtent(extent, true);
 console.log("extent1",extent);
}


Hi all,

So I'm not sure that my code is right but this is what I did.
Query is good and I can see that it calls getLocRes()
Problem here is:
console.log("getLocRes",results);
this shows correct (including # of array)
geom is undefined (chrome console)

but nothing else show's up no alert no console.

can anyone give me some hint?

Thank you,
map loaded fine as well as other functions.

Outcomes