I've been tackling this problem all day and help would surely be appreciated. I'm new to JS and I'm attempting to zoom to a graphic selected from a FindTask. The graphic shows up on the correct point but I can't for the life of me get it to zoom to a point feature. ThanksThis is slapped together from various samples and examples. JS 3.8. //create find parameters
findParams = new esri.tasks.FindParameters();
findParams.returnGeometry = true;
findParams.layerIds = [0];
findParams.searchFields = ["OBJECTID"];
var sr = new esri.SpatialReference({wkid:102100});
findParams.outSpatialReference = sr;
}
//set the search text to find parameters
function execute(searchText) {
findParams.searchText = searchText;
findTask.execute(findParams, showResults);
}
//symbology for graphics
function showResults(results) {
var markerSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10);
//find results return an array of findResult.
map.graphics.clear();
var dataForGrid = [];
//Build an array of attribute information and add each found graphic to the map
dojo.forEach(results, function(result) {
var graphic = result.feature;
if (graphic.geometry.x === 0 || graphic.geometry.y === 0) {
console.warn(graphic.geometry.toJson());
return;
}
switch (graphic.geometry.type) {
case "point":
graphic.setSymbol(markerSymbol);
break;
}
//add graphics to map
map.graphics.add(graphic);
map.setExtent(map.graphic[0].feature.geometry.getExtent());
//THIS IS WHERE EVERYTHING GOES WRONG.....
if (map.graphics.graphic.length > 1) {
var graExtent = esri.graphicsExtent(map.graphics.graphics);
map.setExtent(map.graphic[0].feature.geometry.getExtent());
}
else if (map.graphics.graphic.count == 1) {
map.setExtent(map.graphic[0].feature.geometry.getExtent());
}
});
}
dojo.addOnLoad(init);