how can i get graphics from featurelayer

772
1
11-09-2011 04:11 PM
XiaoJing
New Contributor
here is my code:

AGSFeatureLayer* featureLayer = [AGSFeatureLayer featureServiceLayerWithURL:[NSURL URLWithString:featureURL] mode:AGSFeatureLayerModeOnDemand];
[self.mapView addMapLayer:featureLayer withName:@"feature"];

- (void) mapView:(AGSMapView *)mapView didLoadLayerForLayerView:(UIView< AGSLayerView > *) layerView{
             if ([@"feature" isEqualToString:layerView.name]) {
  AGSFeatureLayer *featureLayer = (AGSFeatureLayer *)layerView.agsLayer;
  NSArray* ff = featureLayer.graphics;
  NSLog(@"%i", [ff count]);
}
}

the graphics array count always 0.Is there something I did is wrong?
0 Kudos
1 Reply
NimeshJarecha
Esri Regular Contributor
You are trying to get the graphics too soon. The graphics are not loaded in AGSFeatureLayer.graphics when layer is created. When layer is created and added to map, layer send a query to server to fetch the features. And after that you should try to get the graphics from feature layer.

Hope this helps!

Regards,
Nimesh
0 Kudos