Select to view content in your preferred language

Problem with editing AGSFeatureLayer created in offline mode

1126
4
09-27-2012 11:54 PM
c_f_ong
Deactivated User
Hello

I'm experimenting with online-offline editing of a feature layer.

In online mode, the feature layer is created from a feature service hosted on ArcGIS Online. And I can click on the accessory button to edit the feature attributes.

In offline mode, I save layer defintion from [aFeatureLayer encodeToJSON] into a file and then recreate a new feature layer from the saved layer defintion as follows:

[self initWithLayerDefinitionJSON:featureLayerDefinition featureSetJSON:featureSetDictionary];

After that, the AGSPopupsContainerViewController doesn't allow me to edit the feature attributes. I've tried to fix the problem as follows but it doesn't seem to work.

    AGSPopupInfo *info = [AGSPopupInfo popupInfoForGraphic:graphic];
    AGSPopup *popup = [AGSPopup popupWithGraphic:graphic popupInfo:info];
    popup.allowEdit = YES;
    popup.allowDelete = YES;
    popup.allowEditGeometry = YES;
    self.popupVC = [[AGSPopupsContainerViewController alloc] initWithPopups:[NSArray arrayWithObjects:popup, nil]];

Is above the expected behaviour of a feature layer? Is there anyway to configure AGSPopupsContainerViewController for editing in the offline mode?

Thanks.

Rgds
Ong CF
0 Kudos
4 Replies
c_f_ong
Deactivated User
Hello

I've dug further as follows:

- (void)didLoadLayer:(AGSLayer *)layer
{
    if ([layer isKindOfClass:[AGSFeatureLayer class]])
    {
        AGSFeatureLayer *aFeatureLayer = (AGSFeatureLayer *)layer; // feature service layer loaded in by web map
        NSLog(@"1: canCreate %@", aFeatureLayer.canCreate ? @"YES" : @"NO");

        AGSFeatureLayer *fL = [[AGSFeatureLayer alloc] initWithLayerDefinitionJSON:[aFeatureLayer encodeToJSON] featureSetJSON:nil];
        NSLog(@"2: canCreate %@", fL.canCreate ? @"YES" : @"NO");
    }
}

And the output is as follows:

1: canCreate YES
2: canCreate NO

Any idea as why the difference in the above output? And for the second case, is there a way to configure the feature layer to output canCreate YES instead?

Thanks.

Rgds
Ong CF
0 Kudos
c_f_ong
Deactivated User
Hello

Did more digging...

AGSFeatureLayer *aFeatureLayer = (AGSFeatureLayer *)layer; // feature service layer loaded in by web map
NSLog(@"aFeatureLayer JSON %@", [aFeatureLayer encodeToJSON]);
NSLog(@"1: canCreate %@", aFeatureLayer.canCreate ? @"YES" : @"NO");

AGSFeatureLayer *fL = [[AGSFeatureLayer alloc] initWithLayerDefinitionJSON:[aFeatureLayer encodeToJSON] featureSetJSON:nil];
NSLog(@"fL JSON %@", [fL encodeToJSON]);
NSLog(@"2: canCreate %@", fL.canCreate ? @"YES" : @"NO");

Comparing the 2 JSON outputs and the difference seems to be as follows:

aFeatureLayer: editable = true;
fL: editable = false;

Is this reason for "1: canCreate YES" vs "2: canCreate NO"? Why? Anyway to make fL editable?

Thanks.

Rgds
Ong CF
0 Kudos
deleted-user-4bdbdJY7UQ_i
Deactivated User
Same issues here.

I am replying to bump this question back to the top.  I am having the same issues with not being able to edit feature layers created with the:

-(id)initWithLayerDefinitionJSON:(NSDictionary*)layerDefinitionJSON featureSetJSON:(NSDictionary*)featureSetJSON;

I noticed the same JSON output results as the original poster.  My AGSPopupsContainerViewController is configured to allow edits but this does not seem to work on feature layers created with the JSON parse.

Has anyone had any success editing features that were created this way?

Mark
0 Kudos
deleted-user-4bdbdJY7UQ_i
Deactivated User
One more try at getting a response from ESRI on this issue.  I still have not found a solution to this problem.

Mark
0 Kudos