Bleroux

Zoom to Feature

Discussion created by Bleroux on Oct 12, 2012
Latest reply on Nov 29, 2012 by abrown31
I am new to javascript and am looking for a little guidance as to zooming to a single point in a feature layer.

I am adding a layer to my map that will only have 1 record based on an input field. I would like to center and zoom to that point when the app initializes and then when someone changes the value and clicks submit. For the life of me I can figure out how to zoom to the point that is in that layer. Here is my code to add the layer. Any suggestions? I've tried many things including querying the layer and zooming to the extent of the results with no luck. Please help.

HOPolicies = new esri.layers.FeatureLayer("http://webmapping/ArcGIS/rest/services/Policies/PoliciesSDE/MapServer/0", { 
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
outFields: ["*"] 
 }); 
temp = input.value
HOPolicies.setDefinitionExpression("POLICY_NO = '" + temp +"'");
map.addLayers([HOPolicies]);

Outcomes