heip me

3478
3
Jump to solution
08-26-2014 09:30 PM
by
New Contributor III

functions  queryTask1.execute(query1, showResults) return of type point(only one point), how are getting  this point and pass to functions centerAndZoom(point, lever).

this is my code

 

queryTask1.execute(query1, showResults);

           

 

 

              function showResults(featureSet) {

 

 

                  //remove all graphics on the maps graphics layer

                  myMap.graphics.clear();

 

 

                  //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;

                      graphic.setSymbol(symbol1);

 

 

                      //Set the infoTemplate.

                      graphic.setInfoTemplate(infoTemplate);

 

 

                      //Add graphic to the map graphics layer.

                      myMap.graphics.add(graphic);

                  }

 

 

map.centerAndZoom(???, ????);

         

 

 

 

              }

Reply
0 Kudos
1 Solution

Accepted Solutions
New Contributor III

You are welcome. If you want you can mark my reply as correct answer to your question.

-

View solution in original post

3 Replies
New Contributor III

Hi,

you can try the following. It is not tested, but should work. It zooms to the first found feature.

queryTask1.execute(query1, showResults);

          

              function showResults(featureSet) {

                  //remove all graphics on the maps graphics layer

                  myMap.graphics.clear();

                  //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;

                      graphic.setSymbol(symbol1);

                      //Set the infoTemplate.

                      graphic.setInfoTemplate(infoTemplate);

                      //Add graphic to the map graphics layer.

                      myMap.graphics.add(graphic);

                  }

                  if (resultFeatures[1] !== undefined) {

                       myMap.centerAndZoom(resultFeatures[1].geometry, 12);

                  }

        

              }

by
New Contributor III

Thanks Rainer!!! I tested and it worked great!!! thank you!!

Reply
0 Kudos
New Contributor III

You are welcome. If you want you can mark my reply as correct answer to your question.

-

View solution in original post