I'm trying to return a string when I click on a country in a map. The string is the country name, which will then be passed to a geoprocessing tool. I've definied "country" as a global variable. I'm trying to define it inside the click function and it's not working. console.log() doesn't print anything.
Here is the code snippet:
var country = {};
map.on("click", function(evt) {
var selectQuery = new Query();
selectQuery.returnGeometry = true;
selectQuery.geometry = geometry;
featureLayer.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function(results) {
country = results[0].attributes["NAME"];
console.log(country);
});
map.infoWindow.setContent(content);
});