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(???, ????);
}
Solved! Go to Solution.
You are welcome. If you want you can mark my reply as correct answer to your question.
-
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);
}
}
Thanks Rainer!!! I tested and it worked great!!! thank you!!
You are welcome. If you want you can mark my reply as correct answer to your question.
-