Solved! Go to Solution.
resultsLayer = new esri.layers.ArcGISDynamicMapServiceLayer(serviceURL, {id: "resultsLayer"});
map.addLayer(resultsLayer);
layer = resultsLayer.dynamicLayerInfos
zoomLayer = new esri.layers.FeatureLayer(serviceURL+layernum);
var query = new esri.tasks.Query();
query.where = "0=1";
zoomLayer .selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW,zoomSel);
}
.........
function zoomSel(){
map.setExtent(zoomLayer.fullExtent);
}
var getLayerExtent = dojo.xhrGet({
url: 'http://MY_URL/ArcGIS/rest/services/MY_MAP_SERVICE/MapServer/0?f=json',
handleAs: 'json',
load: function(r) {
var extent = r.extent;
//zoom to it
}
);
dojo.io.script.get({
url: queryURL+layernum+'?f=json',
content: {q: "#dojo"},
callbackParamName: "callback"
}).then(function(data){
var newExtent = new esri.geometry.Extent
newExtent.xmax = data.extent.xmax;
newExtent.xmin = data.extent.xmin;
newExtent.ymax = data.extent.ymax;
newExtent.ymin = data.extent.ymin;
map.setExtent(newExtent);
});
}