AnsweredAssumed Answered

Zoom to single point

Question asked by gschwitz on Oct 10, 2013
Latest reply on Oct 11, 2013 by gschwitz

I currently have a query that will return 1 or multiple points.  The problem I am having is getting the query to zoom to a single point.  Here is my code, there is a valid feature set being returned:
                function showResults(featureSet) {                     //remove all graphics on the maps graphics layer           ;                     //Performance enhancer - assign featureSet array to a single variable.                     var resultFeatures = featureSet.features;                     //Loop through each feature returned                     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);                         //Set the infoTemplate.                         graphic.setInfoTemplate(infoTemplate);                         //Add graphic to the map graphics layer.                         nameGraphic =;                         //set map extent to selected features                                                 //This works if more than one point//                         //var myFeatureExtent = esri.graphicsExtent(resultFeatures);                         //map.setExtent(myFeatureExtent);                          onQueryComplete(resultFeatures); //Want to use this function to determine zoom                     }                              }

I also have a function that can be used to zoom to the appropriate area:
                function onQueryComplete(returnedPointFeatureSet) {                     var featureSet = returnedPointFeatureSet || {};                     var features = featureSet.features || [];                      var extent = esri.graphicsExtent(features);                     if (!extent && features.length == 1) {                         var point = features[0];                         map.centerAndZoom(point, 3);                     }                     else {                         map.setExtent(extent);                     }                 }

I'm having an issue with getting the onQueryComplete function to work properly.  I don't see why it will not work.  Any assistance is appreciated.