@pacofaWithout seeing the results returned from your query it is hard to help. But you may have to check the geometry being returned, check to see if more than one, and if so loop through and create your extent based off those results.@mcplngMy want to start your own tread if not having the same issue the author has. That way the help provided is not being bounced back and forth. But to answer your question I use this to zoom to features. You have to use a different set of functions to zoom to a point.
symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([0, 255, 255]), 5),
new Color([255, 255, 0, 0.25])
);
psymbol = new SimpleMarkerSymbol(
SimpleMarkerSymbol.STYLE_CIRCLE, 8,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([0, 255, 255]), 8),
new Color([255, 255, 0, 0.25])
);
function featureZoom(feature)
{
map.graphics.clear();
ftype = feature.geometry.type;
//console.log(feature);
if(ftype == "point")
{
var pt = feature.geometry;
var factor = 1; //some factor for converting point to extent
var extent = new esri.geometry.Extent(pt.x - factor, pt.y - factor, pt.x + factor, pt.y + factor, pt.spatialReference);
map.setExtent(extent.expand(60)); // change this control the zoom
showFeature(feature);
} else {
var fExtent = feature.geometry.getExtent().expand(3);
map.setExtent(fExtent);
showFeature(feature);
}
}
function showFeature (feature)
{
map.graphics.clear();
ftype = feature.geometry.type;
if(ftype == "point")
{
feature.setSymbol(psymbol)
setTimeout(function(){map.graphics.clear()}, 3000);
} else {
feature.setSymbol(symbol);
setTimeout(function(){map.graphics.clear()}, 3000);
}
map.graphics.add(feature);
}
The showfeature function just highlights the feature for 3 seconds. The colors can be set by changing the symbol and psymbol variables.Ray