Hi,
I have an application where the query result should be displayed on a table as well as highlight points that meet the query on the map. I am having a challenge as to why the points are not highlighted. Kindly assist. Here is a snippet of the query section of the code.
ArcGIS API for JavaScript queryitems grahpics
query.where = queryString; lyrAcademies.selectFeatures(query, FeatureLayer.SELECTION_NEW, function(results){ showResults(results); }) } } //Show the results as highlighted boxes on the map function showResults(results) { mapMain.graphics.clear(); var selectSymbol = new SimpleMarkerSymbol( SimpleMarkerSymbol.STYLE_SQUARE, 15, new SimpleLineSymbol( SimpleLineSymbol.STYLE_SOLID, new Color([255,0,0]), 1), new Color([0,255,0,0.25]) );
Solved! Go to Solution.
Laura,
So the issue was you were not setting the query outSpatialReference:
Added line 16.
function executeIndQry() {
var queryString = '';
var i = 0;
// define more than one selection to query from the sector
for(option in dom.byId("industrySelectDD").options) {
if(dom.byId("industrySelectDD").options[option].selected) {
if(i == 0) {
queryString += "Industry ='" + dom.byId("industrySelectDD").options[option].value + "'";
i += 1;
} else {
queryString += " or Industry ='" + dom.byId("industrySelectDD").options[option].value + "'";
}
}
}
query.where = queryString;
query.outSpatialReference = mapMain.spatialReference;
lyrAcademies.selectFeatures(query, FeatureLayer.SELECTION_NEW, function(results) {
showResults(results);
})
}
Laura,
In your showResults function make this change:
//creating an array of attributes from the results queried
var GridItems = arrayUtils.map(results, function (result) {
var geo = result.geometry;
mapMain.graphics.add(new Graphic(geo, selectSymbol));
return result.attributes;
});
// for (result in results){
// var geo= results[result].geometry;
// mapMain.graphics.add(new Graphic(geo, selectSymbol))
// }
Thanks, rscheitlin I have tried that but there's still nothing on display
Laura,
Are there any errors in the web console? Are you getting results in the grid?
Yes, I am getting results in the grid, but nothing that displays the highlighted graphic/symbol on the map. I don't see any errors. Unless there's something, in particular, i should check for in the console.
Laura,
So the issue was you were not setting the query outSpatialReference:
Added line 16.
function executeIndQry() {
var queryString = '';
var i = 0;
// define more than one selection to query from the sector
for(option in dom.byId("industrySelectDD").options) {
if(dom.byId("industrySelectDD").options[option].selected) {
if(i == 0) {
queryString += "Industry ='" + dom.byId("industrySelectDD").options[option].value + "'";
i += 1;
} else {
queryString += " or Industry ='" + dom.byId("industrySelectDD").options[option].value + "'";
}
}
}
query.where = queryString;
query.outSpatialReference = mapMain.spatialReference;
lyrAcademies.selectFeatures(query, FeatureLayer.SELECTION_NEW, function(results) {
showResults(results);
})
}
Thank you!
It worked
Laura,
OK, I got it. I will take a look.
Laura,
Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.