Select to view content in your preferred language

Single vs. multiple FeatureLayers

2998
13
03-10-2011 11:41 AM
DonFreeman
Emerging Contributor
Suppose you have a map service containing a point layer and a line layer. Each of these layers is defined with a single symbol in the service. (This seems to be a requirement to get the map tip to work.) On the map we want to present these 2 layers with symbol colors representing the YEAR attribute from the service layer. This would be done with a custom renderer and associated symbol. If we are presenting 5 years worth of data with each year being a different color, would it be best to create a FeatureLayer for each year, or can all 5 years be presented in a single FeatureLayer (1 for points and 1 for lines)? Assume the years do not need to be manipulated individually. Is there a sample around that shows how to render different symbols within a layer based on the attribute data?

Thanks
0 Kudos
13 Replies
DonFreeman
Emerging Contributor
Thanks Jenn. Its helpful to have that insight. I suppose I could change the field type at the source to text. Do you expect that would fix it?

Alternatively I did find a workaround by changing the renderer type to a ClassBreaksRenderer. This does work.
<esri2:SimpleMarkerSymbol x:Key="MySmallMarkerSymbol" Color="Green" Size="8" Style="Circle" />
   <esri2:SimpleMarkerSymbol x:Key="MyMediumMarkerSymbol" Color="Blue" Size="8" Style="Circle" />
   <esri2:SimpleMarkerSymbol x:Key="MyLargeMarkerSymbol" Color="Yellow" Size="8" Style="Circle" />
   <esri:ClassBreaksRenderer x:Key="MyClassBreaksRenderer" Attribute="CONSTYEAR" >
    <esri:ClassBreaksRenderer.Classes>
     <esri:ClassBreakInfo MinimumValue="2011" MaximumValue="2011" Symbol="{StaticResource MySmallMarkerSymbol}" />
     <esri:ClassBreakInfo MinimumValue="2012" MaximumValue="2012" Symbol="{StaticResource MyMediumMarkerSymbol}" />
     <esri:ClassBreakInfo MinimumValue="2013" MaximumValue="2013" Symbol="{StaticResource MyLargeMarkerSymbol}" />
    </esri:ClassBreaksRenderer.Classes>
   </esri:ClassBreaksRenderer>

Which option do you think is the better fix?
0 Kudos
JenniferNery
Esri Regular Contributor
ClassBreaksRenderer is usually used when you want to apply the same symbol to a range of values and UniqueValueRenderer is usually used when you want to apply one symbol for a particular attribute value. http://help.arcgis.com/en/webapi/silverlight/2.1/help/Working_symbols_renderers.htm

While ClassBreaksRenderer worked, I think that you mean to use UniqueValueRenderer but that is just my opinion. Changing the field type to esriFieldTypeString or esriFieldTypeInteger should work. I don't know why Silverlight XAML seem to have this limitation with Int16. If changing your service seem drastic, I think you can simply create your renderer in code-behind.
0 Kudos
DonFreeman
Emerging Contributor
Do you suppose this is a bug that we should report (not working with Int16)?
0 Kudos
JenniferNery
Esri Regular Contributor
Sure I can post this question to Microsoft.

The following reproduce the same XamlParseException:
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Grid x:Name="LayoutRoot" Background="White">  
 <ComboBox VerticalAlignment="Top" HorizontalAlignment="Center" SelectedIndex="0">
 <ComboBox.Items>
  <!--<sys:Int32>1</sys:Int32>-->
  <sys:Int16>1</sys:Int16>
 </ComboBox.Items>
</ComboBox>
</Grid>


I found this from Silverlight forum: http://forums.silverlight.net/forums/p/32280/100852.aspx#100852
0 Kudos