madgame

FeatureLayer dataChanged fails.

Discussion created by madgame on May 24, 2011
Latest reply on Sep 19, 2011 by pml
So far I've tried to refresh the FeatureLayer after I apply edits to it by calling dataChanged.  The point gets added at Lat/Lon of 0/0, instead of at the correct location.  If I remove/add the layer to the mapView, it shows up in the correct location. 

                AGSFeatureLayer *flayer = (AGSFeatureLayer*)theLayer;
                NSArray *types = flayer.types;
                AGSFeatureType *theType = [types objectAtIndex:0];
                NSArray *templates = theType.templates;
                AGSFeatureTemplate *theTemplate = [templates objectAtIndex:0];
                AGSGraphic *theFeature = [flayer createFeatureWithTemplate:theTemplate];
                
                [theFeature.attributes setValue:message forKey:@"Description"];
                [theFeature setGeometry:[AGSPoint pointWithX:longitude y:latitude spatialReference:[AGSSpatialReference wgs84SpatialReference]]];
                NSOperation *result = [flayer addFeatures:[NSArray arrayWithObject:theFeature]];
                [flayer dataChanged];


Also, I tried in the class where I implemented AGSFeatureLayerEditingDelegate...  Still no joy.

- (void)featureLayer:(AGSFeatureLayer *)featureLayer operation:(NSOperation *)op didFeatureEditsWithResults:(AGSFeatureLayerEditResults *)editResults {
    NSArray *addResults = editResults.addResults;
    AGSEditResult *addResult = [editResults.addResults objectAtIndex:0];
    
    if(addResult.success) {
        [featureLayer dataChanged];
        mICATViewController *ref = [mICATViewController sharedManager];
        if (ref.image != nil) {
            NSString *filename = [ref.imagePickerDelegate saveImageToTempFile:ref.image];
            [featureLayer addAttachment:addResult.objectId filepath:filename];
            [ref setImage:nil];
        }
    } else {
        NSLog(@"UGH. NOW WHAT");
    }
}


Any ideas????

Outcomes