I am trying to query a feature layer that is not shown on the map until the query is actually executed. I have a button that I am using to set off the query when it is clicked. Here is the code that I am trying to use:
on(dom.byId("mapshow"), "click", selectHistorical);
function selectHistorical(){
var queryTask = new QueryTask(window.historicalUrl);
var query = new Query();
query.returnGeometry=true;
query.outFields=window.historicalOutFields;
query.text = dom.byId("mydropdown").value;
query.outSpatialReference = {"wkid":2236};
dojo.connect(queryTask, "onComplete", function(featureSet){
map.graphics.clear();
dojo.forEach(featureSet.features, function(feature){
var graphic = feature;
map.graphics.add(graphic);
});
});
queryTask.execute(query);
}
Am I missing something? Is there a better way to go about doing this? Any help is greatly appreciated, thanks!Michelle