var layerURL = "http://172.20.25.165:6080/arcgis/rest/services/Crime2018/FeatureServer/"; //querys the crimes layer for all burglaries
var burgresultsLayer = new GraphicsLayer();
var burgQsym = { //creates the symbol for burglaries query
type: "simple-marker",
color: "green",
style: "triangle",
size: 8
};
/*alert(layerURL);*/
var qTask = new QueryTask({url : layerURL});
var burgQuery = new Query();
burgQuery.returnGeometry = true;
var fieldBoys = burgQuery.outFields = ["Offense", "Location"];
/*alert(fieldBoys);*/
burgQuery.where = "Offense = Burglary";
qTask.execute(burgQuery).then(function(results) {
console.log(results.features);
});
qTask.executeForCount(burgQuery).then(function(results) {
console.log(results);
});
Solved! Go to Solution.
John,
That is definitely your issue.
require([
"esri/Map",
"esri/views/MapView",
"esri/widgets/Home",
"esri/widgets/Search",
"esri/widgets/BasemapGallery",
"esri/widgets/Expand",
"esri/layers/FeatureLayer",
"esri/layers/ImageryLayer",
"esri/widgets/LayerList",
"esri/tasks/QueryTask",
"esri/tasks/support/Query",
"esri/layers/GraphicsLayer",
"dojo/dom",
"dojo/on",
"dojo/domReady!"
],function(
Map, MapView, Home, Search, BasemapGallery, Expand, FeatureLayer, ImageryLayer,
LayerList, QueryTask, Query, GraphicsLayer, dom, on) {
Here is your order fixed
John,
Your where clause is wrong:
burgQuery.where = "Offense = 'Burglary'";
Thank you ... I edited that code and still no go!
Getting this in console:
John,
OK I did not notice before that your url does not contain a specific layer id at the end of it which is required.
Thank you Robert ... I had noticed that after I posted this code ...
It now reads :
var layerURL = "http://172.20.25.165:6080/arcgis/rest/services/Crime2018/FeatureServer/0";
John,
If it works now. Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.
Not working yet ... thanks for your help!
I will most definitely mark as correct when time comes.
Thanks again.
So what is the error you are getting now then?
Same one
dojo.js:19 Uncaught TypeError: qTask.execute is not a function
at Map.js:141
at K (dojo.js:18)
at dojo.js:19
at E (dojo.js:19)
at da (dojo.js:19)
at e (dojo.js:21)
at HTMLScriptElement.<anonymous> (dojo.js:23)
John,
Sounds like your requires are not in sync with their vars then. Can I see more of your code?