All, here are some details of how subtypes are supported in the definition of the layer.
Summary:
The renderer is required to match the list of subtypes exactly as this is how values assigned at the subtype level are stored in the definition of the service.
Details:
The service definition for a layer has a parameter “typeIdField”, Once would think this is for the subtype of a layer, but it is not. It defines the field the unique value render is based on:
Here is a simple example where the typeIdField is based on a string field, this clearly shows that this parameter is not for subtypes as a subtype can never be based on a text field:
- "typeIdField" : "Render",
If you review the types of the json:
"types" : [
{
"id" : "Blue",
"name" : "Blue",
"domains" :
{
"Render" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "Blue",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"Render" : "Blue"
}
}
}
]
},
You can see domains based on the renderer types. Since this is not a subtype layer in the example above, the domain is inherited from the field
Now compare this to a layer with subtypes and renderered by the subtype:
- "typeIdField" : "subtypetest",
Now review the types, you can see that the one subtype(1) has the domain that is set at the subtype layer, where the first one(0) is using the value specified at the field(inherited)
"types" : [
{
"id" : 0,
"name" : "New Subtype",
"domains" :
{
"Render" : {"type" : "inherited"}
},
"templates" : [
{
"name" : "New Subtype",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"Render" : null,
"subtypetest" : 0
}
}
}
]
},
{
"id" : 1,
"name" : "other",
"domains" :
{
"Render" :
{
"type" : "codedValue",
"name" : "testother",
"codedValues" : [
{
"name" : "blah",
"code" : "blahcode"
},
{
"name" : "foo",
"code" : "boo"
}
]
}
},
"templates" : [
{
"name" : "other",
"description" : "",
"drawingTool" : "esriFeatureEditToolPoint",
"prototype" : {
"attributes" : {
"Render" : null,
"subtypetest" : 1
}
}
}
]
}
],