Could I also do this inside an identify task? Right now I'm clicking on the state to get statistics in the popup.
var identifyTask, identifyParams;
function mapReady () {
map.on("click",executeIdentifyTask);
identifyTask = new IdentifyTask(roadsURL);
identifyParams = new IdentifyParameters();
identifyParams.tolerance = 7;
identifyParams.returnGeometry = true;
identifyParams.width = map.width;
identifyParams.height = map.height;
};
function executeIdentifyTask (event) {
map.infoWindow.clearFeatures();
identifyParams.geometry = event.mapPoint;
identifyParams.mapExtent = map.extent;
identifyParams.layerIds = roadsLayer.visibleLayers;
var deferred = identifyTask
.execute(identifyParams);
deferred.addCallback(function (response) {
return arrayUtils.map(response, function (result) {
var feature = result.feature;
var layerName = result.layerName;
var iTemplate;
if(result.layerName === "Forecast 18 Hours"
|| result.layerName === "Past 6 Hours"
|| result.layerName === "Past 24 Hours"
|| result.layerName === "Past 48 Hours"
|| result.layerName === "Past 72 Hours"){
iTemplate = new InfoTemplate(layerName,"State: ${name}<br>No Snow: ${No_Snow}<br>Trace: ${Trace}<br>0.1 to 1 Inch: ${One_Inch}<br>1 to 2 Inches: ${Two_Inch}<br>2 to 6 Inches: ${Six_Inch}<br>6 to 12 Inches: ${Twelve_In}<br>12 to 18 Inches: ${Eightn}<br>Above 18 Inches: ${Above_18}"
);
feature.setInfoTemplate(iTemplate);
}
return feature;
});
});
map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(event.mapPoint);
map.infoWindow.resize(225,200)
}