Select to view content in your preferred language

Using queryTask and zooming into a geometry

1011
3
Jump to solution
05-27-2013 10:25 PM
PrasannaRaghavendar
Occasional Contributor
I am trying to get the geometry of the polygon using UNIQPOLYID.
UNIQPOLYID is the display field.

function searchGeometry(polyId){    queryTask = new esri.tasks.QueryTask(URLGoesHere);    query = new esri.tasks.Query();    query.returnGeometry = true;    query.text = polyId;    queryTask.execute(query, queryResults); }  function queryResults(featureSet){    alert(featureSet.features); //undefined    //Should get the geometry of the feature and zoom into it. }


"featureSet.features" is undefined in my queryResults(featureSet). How should I get the the feature with the provided polyId so that I can zoom in to the geometry.
0 Kudos
1 Solution

Accepted Solutions
VinayBansal
Frequent Contributor
Check with rest url , if you are getting results.
http://<yourserver>/arcgis/rest/services/<Map_Service>/Mapserver/layerid

View solution in original post

0 Kudos
3 Replies
VinayBansal
Frequent Contributor
Check with rest url , if you are getting results.
http://<yourserver>/arcgis/rest/services/<Map_Service>/Mapserver/layerid
0 Kudos
PrasannaRaghavendar
Occasional Contributor
I got the geometry when I included layerId.
function queryResults(featureSet){ 
 var resultSet = featureSet.features;
 var shape = resultSet[0].geometry;     
            if(shape.type==='polygon'){
         var featureExtent=shape.getExtent();
         map.setExtent(featureExtent);
     }else{
         alert("Shape is not a polygon");
     }


Though I set feature Extent to map extent. The slider zooms to the fullest and I get to see only "Map Data Not Available". Why is that? I want the slider to just zoom on the polygon.
0 Kudos
VinayBansal
Frequent Contributor
If you got your answer, then do mark the post as answered.

And regarding your second query, this may happen in many scenarios....
like projection of geometry is different than that of map.
Map is zooming to location where base map is not available.
0 Kudos