Knowing the polygon id and getting the extent

434
3
05-26-2013 10:13 PM
PrasannaRaghavendar
New Contributor III
I have a text box where I have the polygon Id like,
"id_of_the_polygon_12345"
. Is it possible to get its extent on the map and zoom into it? I have figured out how to do it upon clicking on the map. But could not figure how to do the same knowing my poly Id.
0 Kudos
3 Replies
VinayBansal
Occasional Contributor II
Could you elaborate more on your functionality, what actually you want to do?.
0 Kudos
PrasannaRaghavendar
New Contributor III
I know that I can zoom to a polygon when it is clicked by doing this

identifyParams.geometry = evt.mapPoint;
identifyParams.mapExtent = map.extent;
identifyTask.execute(identifyParams, function(result) { 
     var i;
     var polyId= new Array();
     for(i=0; i<result.length;i++){              
       polyId=result.feature.attributes["UNIQPOLYID"];
     }


But I do not want to do it upon clicking on the map. When the user enters the polygon id in a text box, I want to zoom and show that polygon on the screen.
0 Kudos
VinayBansal
Occasional Contributor II
Means you need to query based on the polygon Id.

For that you need to use query task

You can take input from this sample on how to call query task on layer you want to query

http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/query_nomap.html


Once you got the results, get the geomtry and zoom to its extents on map.
0 Kudos