How do I change the extent on the map in function of a query?
in legend I have no problem using the function showResults (featureSet) {... but, can not get any display in AMD. Here I put a piece of script that I want to switch from legend to AMD:
function showResults(featureSet) {
//remove all graphics on the maps graphics layer
map.graphics.clear();
//QueryTask returns a featureSet. Loop through features in the featureSet and add them to the map.
//Performance enhancer - assign featureSet array to a single variable.
var resultFeatures = featureSet.features;
var extent;
for (var i = 0, il = resultFeatures.length; i < il; i++) {
//Get the current feature from the featureSet.
//Feature is a graphic
var graphic = resultFeatures[i];
graphic.setSymbol(symbol);
geometry = graphic.geometry;
ext = geometry.getExtent();
if (extent) {
extent = extent.union(ext);
} else {
extent = new esri.geometry.Extent(ext);
}
//Set the infoTemplate.
graphic.setInfoTemplate(infoTemplate);
//Add graphic to the map graphics layer.
//map.addLayer(stateLayer);
map.graphics.add(graphic);
}
map.setExtent(extent, true);
}