fauphi

Select features on feature layer

Discussion created by fauphi on Dec 2, 2012
Latest reply on Jan 29, 2015 by HrishiPol
Hi there,

I'm trying to select features on a AGSFeatureLayer, but that doesn't work.
Here's my code, maybe someone finds something that isn't right.

code in "viewDidLoad". This adds the 18 AGSFeatureLayers to my mapView:
for(int i = 0; i < 19; i++) {
        NSString *urlString = [@"http://www.geoportal.passau.de/ArcGIS/rest/services/APPDATEN/MapServer/" stringByAppendingFormat:@"%i", i];
        NSString *layerNameString = [@"feature" stringByAppendingFormat:@"%i", i];
        NSURL* url = [NSURL URLWithString: urlString];
        AGSFeatureLayer* featureLayer = [AGSFeatureLayer featureServiceLayerWithURL: url mode: AGSFeatureLayerModeSelection];
        self.lyrView = [self.mapView addMapLayer:featureLayer withName:layerNameString];
        featureLayer.queryDelegate = self;
        [self.featureLayerArray addObject:featureLayer];
    }


code in "mapView: didLoadLayerForLayerView:". Here I'm trying to select a feature on the FeatureLayer number 1:
AGSFeatureLayer *newLayer = (AGSFeatureLayer*)[self.featureLayerArray objectAtIndex:1];
    
    AGSQuery* query = [AGSQuery query];
    query.where = @"ID <> 0";
    //query.spatialRelationship = AGSSpatialRelationshipWithin;
    //query.geometry = californiaGeometry;
    [newLayer selectFeaturesWithQuery:query selectionMethod:AGSFeatureLayerSelectionMethodAdd];


The class is defined as AGSFeatureLayerQueryDelegate, but none of these delegate methods is called:
featureLayer: operation: didFailQueryFeaturesWithError:
featureLayer: operation: didFailSelectFeaturesWithError:
featureLayer: operation: didSelectFeaturesWithFeatureSet:
featureLayer: operation: didQueryFeaturesWithFeatureSet:

What am I doing wrong here?
Is there an example for that? I only found one with the editing of the FeatureLayer.

Thanks for any advice!!

Philipp

Outcomes