I am working on a web map using ArcGIS JavaScript API. The map should be able to query a layer and show the result. Since this is my first time using query task of the API, I got some issue. Below is the syntax of the query part. When I clicked the button in webpage, It always give the error:
init.js:182 Error(…)y
@ init.js:182(anonymous function)
@ init.js:181c
@ init.js:66d
@ init.js:66resolve.callback
@ init.js:67c
@ init.js:66d
@ init.js:66resolve.callback
@ init.js:67c
@ init.js:66d
@ init.js:66resolve.callback
@ init.js:67c
@ init.js:66d
@ init.js:66resolve.callback
@ init.js:67(anonymous function)
@ init.js:185k
@ init.js:189q
@ init.js:189resolve
@ init.js:191a
@ init.js:190k
@ init.js:190q
@ init.js:189resolve
@ init.js:191a
@ init.js:190k
@ init.js:190q
@ init.js:189resolve
@ init.js:191a
@ init.js:190k
@ init.js:190q
@ init.js:189resolve
@ init.js:191n
@ init.js:150f
@ init.js:154
As you can see, I put some console in the syntax and here is the result:
executequery started
where statement completed in executequery function
myquerytask completed in executequery function
It looks like the queryTask has already been excuted but the showResults, which is the callback function, doesn't. Could anybody help me with the entry level problem?
var whereExpression = "";
myQueryTask = new QueryTask("http://arcgis-cabhpgis-2026970499.us-west-1.elb.amazonaws.com/arcgis/rest/services/HCIC/160524_interactive_map_jzz_v02/MapServer/0");
myQuery = new Query();
myQuery.returnGeomery = true;
myQuery.outFields=["*"];
myQuery.where = whereExpression;
function executeQuery(){
console.log("executequery started");
whereExpression = "";
for(i=0;i<serviceList.length;i++){
if(i==0) {
whereExpression += ("ServiceProvided LIKE '%" + serviceList[i] + "%'");
}
else{
whereExpression += (" AND ServiceProvided LIKE '%" + serviceList[i] + "%'");
}
}
console.log("where statement completed in executequery function");
myQueryTask.execute(myQuery,showResults);
console.log("myquerytask completed in executequery function");
}
function showResults (results) {
console.log("showresults started");
document.getElementById("info").innerHTML = results.features.length;
}
on(dom.byId("applyServiceSelection"),"click",executeQuery);