+ Reply to Thread
Results 1 to 2 of 2

Thread: Unable to add new features to feature layer if feature class has subtype

  1. #1
    Patric Trollope
    Join Date
    Dec 2011
    Posts
    7
    Points
    2
    Answers Provided
    0


    0

    Default Unable to add new features to feature layer if feature class has subtype

    Hi guys,

    Im new to most of these technologies, so please bear with me. That being said I hope somebody can help! I am going to be as clear as possible so please let me know if something doesn't make sense.

    I am testing the WP7 SDK, and have created a simple "pothole reporting" application, which will allow a user to view a map with an ArcGIS Online basemap, and a feature layer containing the pothole data. They are able to add, identify and delete from the feature layer.

    Problem Summary: If my feature class has a subtype, I am not able to add a new feature to my feature layer - regardless of what property I pass to the Editor's Add command.

    Problem Details:

    If I create a feature class with no subtype, I am able to add, identify and delete features successfully, but as soon as I create a feature class with a subtype I am unable to add new features.

    According to the Resource Centers Concept page "Using The Editor":

    "Features can be added by using the Editor's Add command. It takes a single property indicating the type of feature or graphic to add to the map, which depends on the type of layer you're editing. When adding features to a FeatureLayer, the required parameter is a specific template or type ID. To determine the value when working with a FeatureLayer, see the service's web page; the value is the ID from the Types section."

    Here is my services page for my feature layer:

    Services Directory: http://mymachine/ArcGIS/rest/service...eatureServer/0

    Code:
    Feature Layer: test2 (ID: 0)
    View In:   ArcGIS.com Map 
    Display Field: comment2
    Type: Feature Layer
    Geometry Type: esriGeometryPoint
    ...
    Type ID Field: status2
    
    Fields: 
      OBJECTID (Type: esriFieldTypeOID, Alias: OBJECTID, Editable: False)
      status2 (Type: esriFieldTypeSmallInteger, Alias: status2, Editable: True)
      size2 (Type: esriFieldTypeSmallInteger, Alias: size2, Editable: True)
      comment2 (Type: esriFieldTypeString, Alias: comment2, Length: 50, Editable: True)
      date2 (Type: esriFieldTypeDate, Alias: date2, Length: 36, Editable: True)
      photo2 (Type: esriFieldTypeRaster, Alias: photo2, Editable: True)
      GlobalID (Type: esriFieldTypeGlobalID, Alias: GlobalID, Length: 38, Editable: False)
    
    Types: 
      ID: 1
      Name: New
      Domains: 
      Templates: 
        Name: New
        Description: 
        Drawing Tool: esriFeatureEditToolPoint
        Prototype: 
          Attributes: 
            status2: 1
      ID: 2
      Name: WIP
      Domains: 
      Templates: 
        Name: WIP
        Description: 
        Drawing Tool: esriFeatureEditToolPoint
        Prototype: 
          Attributes: 
            status2: 2
      ID: 3
      Name: Fixed
      Domains: 
      Templates: 
        Name: Fixed
        Description: 
        Drawing Tool: esriFeatureEditToolPoint
        Prototype: 
          Attributes: 
            status2: 3

    This is my feature layer declaration in XAML:

    Code:
    <esri:FeatureLayer ID="Potholes" Url="http://mymachine/ArcGIS/rest/services/test2/FeatureServer/0" OutFields="*" />

    This is my editor declaration in XAML:

    Code:
    <esri:Editor x:Key="MyEditor" 
                    LayerIDs="Potholes"
                    ContinuousMode="True"
                    EditCompleted="Editor_EditCompleted"
    />

    In my code behind (C#), I initialize my editor and feature layer:

    Code:
    editor = LayoutRoot.Resources["MyEditor"] as Editor;
    editor.Map = MyMap;
    
    editLayer = MyMap.Layers["Potholes"] as FeatureLayer;

    I call the Editors Add command:

    Code:
    if (editor.Add.CanExecute(???))
      editor.Add.Execute(???);

    According to the documentation "the required parameter is a specific template or type ID". I have tried passing:

    Code:
    if (editor.Add.CanExecute(1))
    And

    Code:
    if (editor.Add.CanExecute("New"))

    Both variations return false, and I cannot add a feature.

    In the API documentation (http://help.arcgis.com/en/arcgismobi...tor~Add.html)I also found the following:

    "If you are editing a FeatureLayer, the CommandParameter should be the feature type to use if you have feature types, or the template name if you only have templates defined. If you have multiple templates defined for each feature type, you can use an array object[] { featureTypeId, featureTemplateName } as parameter. If no template and/or feature type is specified, the default will be used. If the FeatureLayer is read-only, Add will not be supported."

    So then I also tried this:

    Code:
    object[] myobj = new object[] { "1", "New" };
    if (editor.Add.CanExecute(myobj))

    This also returns false.

    I am at a loss here, any advice would be very much appreciated.

    Regards,
    Patric

  2. #2
    Jennifer Nery

    Join Date
    May 2010
    Posts
    2,449
    Points
    289
    Answers Provided
    51


    0

    Default Re: Unable to add new features to feature layer if feature class has subtype

    This related thread: http://forums.arcgis.com/threads/498...g-using-EDITOR.

    You're right that the code-behind equivalent is the following:
    Code:
    var cmdParameter = new object[] { featureTypeID, templateName }; //or simply, cmdParameter = featureType
    if (editor.Add.CanExecute(cmdParameter))
    {
    	editor.Add.Execute(cmdParameter);
    }
    Note that your Editor need to be acting on 1 layer only for Add.
    Jennifer Nery
    Software Developer
    ArcGIS API for SL/WPF/WP7

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts