So I've been using a few of the samples to put an application together, I'm not a JavaScript coding expert, so this should be easy for those who are.I want the app to Geocode, then do a spatial query on that geocoded point, highlight the feature and show an infoWindow. I also would like to be able to query by clicking. Bottom line: all of that works EXCEPT showing the infoWindow after the geocde spatial query, the info window DOES show when I click on the map. I think it has to do with this line:(evt) ? map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint)) : null;
Below is the relevant code, please help! (some code has been removed because I know it works and is not relevant to te problem)
//Click Query Functions
function clickQuery(evt) {
esri.show(dojo.byId('loadingImg'));
map.infoWindow.hide();
map.graphics.clear();
featureSet = null;
//onClick event returns the evt point where the user clicked on the map.
//This contains the mapPoint (esri.geometry.point) and the screenPoint (pixel xy where the user clicked).
//set query geometry = to evt.mapPoint Geometry
geom = evt.mapPoint;
query.geometry = geom;
query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
//Execute task and call showResults on completion
queryTask.execute(query, function(fset) {
if (fset.features.length === 1) {
showFeature(fset.features[0],evt);}
else {esri.hide(dojo.byId('loadingImg'));
}
});
}
//Geocode query function
function geoQuery(loc) {
var geom = new esri.geometry.Point(loc.x,loc.y, map.spatialReference);
query.geometry = geom;
query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;
queryTask.execute(query, function(fset) {
if (fset.features.length === 0) {
showError();
}
else if (fset.features.length === 1) {
showFeature(fset.features[0],evt);
}
else {
esri.hide(dojo.byId('loadingImg'));
}
});
}
// Query Show Feature
function showFeature(feature,evt) {
//set symbol
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([102,204,0]),3), new dojo.Color([102,204,0,0.6]));
feature.setSymbol(symbol);
//construct infowindow title and content
var attr = feature.attributes;
map.infoWindow.setTitle("My Title");
map.infoWindow.setContent("My infoWindow Content");
map.graphics.add(feature);
(evt) ? map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint)) : null;
map.setExtent(feature.geometry.getExtent(),true);
}