Select to view content in your preferred language

heip me

4264
3
Jump to solution
08-26-2014 09:30 PM
lasinh
by
Occasional Contributor

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(???, ????);

         

 

 

 

              }

0 Kudos
1 Solution

Accepted Solutions
RainerSpitzer1
Deactivated User

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

-

View solution in original post

3 Replies
RainerSpitzer1
Deactivated User

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

                  }

        

              }

lasinh
by
Occasional Contributor

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

0 Kudos
RainerSpitzer1
Deactivated User

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

-