To display the result of a query on the map and in Attribute Table, I create a new FeatureLayer and populate it with the features from the result. The Attribute Table displays nicely, but when a feature is selected, the function"Zoom to selected features" won't work.
The code I use to initialize the feature layer is as follow. I appreciate it if anyone can help me point out what needs to be done to make the zoom function works.
The code I use to initialize the feature layer is as follow. I appreciate it if anyone can help me point out what needs to be done to make the zoom function works.
Code:
var layerDetails:LayerDetails = new LayerDetails();
layerDetails.spatialReference = map.spatialReference;
layerDetails.fields = <list of fields>;
var resultFeatures:Array = new Array();
for (i = 0; i < featureSet.features.length; i++) {
if (<some logic here> ) {
resultFeatures.push(featureSet.features[i]);
}
}
var resultLayer:FeatureLayer = new FeatureLayer();
resultLayer.name = "Search Result";
resultLayers.push(resultLayer);
resultLayer.featureCollection = new FeatureCollection(new FeatureSet(resultFeatures), layerDetails);
resultLayer.outFields = ["*"];
map.addLayer(resultLayer);