Select to view content in your preferred language

Adding Symbols Defined In the Application to the TemplatePicker

2634
7
06-02-2010 08:08 AM
ScottMcBride
Emerging Contributor
The documentation states that "The symbols visible in the Template Picker can come from either the editing templates defined in the feature service's source map, or they can be a set of symbols that defined in the application." 

I have many symbols, and for performance reasons want to use PictureMarkerSymbols in the application rather than symbols from the feature layer.  The feature layer is simply a point layer with a single symbol.  I am able to render the points as based on an attribute which references a static resource PictureMarkerSymbols.   I am also able to create PictureMarkerSymbols programatically in the code behind and add them to other controls. 

The question is....  how do I add the PictureMarkerSymbols that I have defined in my application to the Template Picker.  Any feedback would be greatly appreciated.

I am using ArcGIS API for Microsoft Silverlight???/WPF??? version 2.0 BETA, ArcGIS 10 Pre-Release, Silverlight 4 SDK.
0 Kudos
7 Replies
dotMorten_esri
Esri Notable Contributor
In the beta, TemplatePicker is solely driven by the symbols exposed by the FeatureService. You cannot override these.
In a future release, they will be driven by the layer's renderer, and you can replace the renderer with your own and ultimately override the picker's symbols that way.
However, it does sound like the TemplatePicker is not for you. You are probably better off with just a button that executes the Add command. You can simply set your image inside the Add button.

I'm curious why you think PictureMarkerSymbol is more performant. In all our tests, it's in fact the least performant symbol.
0 Kudos
ScottMcBride
Emerging Contributor
Thank you very much for your reply.  I will follow your advice.  

As to the performance question:  Use of the PictureMarkerSymbol as a symbol type is a constraint of the application.  It requires the use of a large collection of very specific symbols used by the industry.  The symbols are small (1 -2 k png files).  The performance gain that I was refering to is loading them as static resources rather than creating multiple copies of the same image when using the UniqueValueRenderer based on an attribute.  There is a cost loading the application on startup, but rendering performance is good.  However, if you have a better strategy, I am open to suggestions.
0 Kudos
dotMorten_esri
Esri Notable Contributor
"The performance gain that I was refering to is loading them as static resources rather than creating multiple copies of the same image when using the UniqueValueRenderer based on an attribute"
When you specify a symbol for each UniqueValueRenderer, it will not create new instances, but re-use the same instance you are defining for that unique value on all the graphics that unique value matches. So it is already re-used.

The problem with the PictureMarkerSymbol is that for each instance, the image is decoded over and over again, and this will happen even if you define it as a static resource. We found that the best way to work around this is to create a Rectangle, Grid or Border and set the fill or background to an ImageBrush, but make sure the brush is defined as a static resource. That way the image will only be decoded once, and if you have 100s of points using the same symbol, performance will be a lot better. I talk about this issue (and other tips on how to optimize symbols) in this session: http://proceedings.esri.com/library/userconf/devsummit10/tech/tech_68.html (general intro to symbols starting at 43:20, symbol performance from 58:10)
0 Kudos
ScottMcBride
Emerging Contributor
Since I am using a UniqueValueRenderer, the displayed symbol is based on an attribute (symbolcode).  The editor "add" command adds a new feature using the defaults since there is no feature template.  It is displayed using the default symbol.  The API Refrence on "Add Property" of the "Editor Class" says that a CommandParameter should be used when adding a FeatureLayer.   The CommandParameter makes refrence to "an array object[] { featureTypeId, featureTemplateName } as parameter".  This takes me back to how to create a feature template.  Is there another way to add an attribute (symbolcode) when using the editor "Add" command?
0 Kudos
dotMorten_esri
Esri Notable Contributor
You don't create a feature template. You reference the ones in FeatureLayer.LayerInfo.Templates/FeatureTypes. If your FeatureService has FeatureTypes but only one template for each type, you can just specify the FeatureType. If you only have Templates (no types), you can just reference the Template name. If you have FeatureTypes with multiple templates in each, you will have to use the array combination as you mention.
0 Kudos
ScottMcBride
Emerging Contributor
Thank you for you help so far.  Progress is being made.
Can you give me an example of "an array object[] { featureTypeId, featureTemplateName }"?  I have created three templates in a point feature class (TemplateA, TemplateB, and TemplateC).  I have verified that these templates are defined in the FeatureLayer rest services.  I have created three buttons, one for each template and have bound it to the editor.  These buttons sucessfully add a point feature.  However, I have been unable to bind them to the templates (they always default to the first one).  My guess is that the CommandParameters binding syntax is not in the correct format.  I am assuming the the featureTemplateName is a String name of the template.  However, I do not know what the featureTypeID is or what type it is.  I have tried "Point" as a String, 0 as an int (it only has one feature type point), 1 as an int (the integer form for the esriGeometryTypePoint).   

  object[] ArrayA = new object[2];
            ArrayA[0] = ??????????
            ArrayA[1] = "TemplateA";
0 Kudos
SrikanthNarra
Emerging Contributor
scott_mcbride
Hi You just use Type Id as Object Type,Point as Object,ZERO as an Object den your problem will be solved
0 Kudos