FeatureLayer and the RendererTakesPrecedence property

2516
3
Jump to solution
04-29-2014 04:13 AM
Labels (1)
MiriRevivo
Occasional Contributor
Hello,

I'm trying to use the RendererTakesPrecedence property on a FeatureLayer in order to change the symbols applied to the features by the renderer applied to the layer in the map service it is loaded from.
When in AcceleratedDisplay mode, this property is ignored, and the feature layer gets the renderer applied to it by the service (not the expected behavior).
When using the regular WPF rendering engine - it is respected.

I found this similar issue that was also present in the Silverlight API (but obviously with no relation to the AcceleratedDisplay):
http://forums.arcgis.com/threads/99127-FeatureLayer-doesn-t-honor-RendererTakesPrecedence

Is this a bug? Known limit in the Accelerated mode?

Thanks,
Miri.
0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor
Hi Miri,

What version of the API are you using? I just tested 10.2, 10.2.2 and the imminent 10.2.3 and it behaves as expected - when FeatureLayer.RendererTakesPrecedence is false, the individual symbols I explicitly defined on each Graphic are used. However, when RendererTakesPrecedence is true (the default), all Graphics are symbolized as per the service-defined renderer.

public MainWindow() {  InitializeComponent();   ESRI.ArcGIS.Client.LayerCollection.LayersInitializedHandler layerInitializedHandler = null;   BitmapImage bi0 = new BitmapImage(new Uri("pack://application:,,,/Aqua_Ball_Green_32.png"));   PictureMarkerSymbol pms = new PictureMarkerSymbol()  {   Source = bi0,  };   layerInitializedHandler += (s, e) =>   {   MyMap.Layers.LayersInitialized -= layerInitializedHandler;    FeatureLayer featureLayer = new FeatureLayer()   {    ID = "Fire Incidents",    Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0",    RendererTakesPrecedence = false,   };    EventHandler updateCompleted = null;    updateCompleted += (x, y) =>    {    featureLayer.UpdateCompleted -= updateCompleted;          foreach (var graphic in featureLayer.Graphics)    {     if (graphic.Geometry is MapPoint)     {      graphic.Symbol = pms;     }    }   };    featureLayer.UpdateCompleted += updateCompleted;    MyMap.Layers.Add(featureLayer);  };   MyMap.Layers.LayersInitialized += layerInitializedHandler; }  <Grid>  <esri:Map x:Name="MyMap" UseAcceleratedDisplay="True">         <esri:ArcGISTiledMapServiceLayer ID="World Topo Map"                      Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>     </esri:Map> </Grid>


Cheers

Mike

View solution in original post

0 Kudos
3 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi Miri,

What version of the API are you using? I just tested 10.2, 10.2.2 and the imminent 10.2.3 and it behaves as expected - when FeatureLayer.RendererTakesPrecedence is false, the individual symbols I explicitly defined on each Graphic are used. However, when RendererTakesPrecedence is true (the default), all Graphics are symbolized as per the service-defined renderer.

public MainWindow() {  InitializeComponent();   ESRI.ArcGIS.Client.LayerCollection.LayersInitializedHandler layerInitializedHandler = null;   BitmapImage bi0 = new BitmapImage(new Uri("pack://application:,,,/Aqua_Ball_Green_32.png"));   PictureMarkerSymbol pms = new PictureMarkerSymbol()  {   Source = bi0,  };   layerInitializedHandler += (s, e) =>   {   MyMap.Layers.LayersInitialized -= layerInitializedHandler;    FeatureLayer featureLayer = new FeatureLayer()   {    ID = "Fire Incidents",    Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0",    RendererTakesPrecedence = false,   };    EventHandler updateCompleted = null;    updateCompleted += (x, y) =>    {    featureLayer.UpdateCompleted -= updateCompleted;          foreach (var graphic in featureLayer.Graphics)    {     if (graphic.Geometry is MapPoint)     {      graphic.Symbol = pms;     }    }   };    featureLayer.UpdateCompleted += updateCompleted;    MyMap.Layers.Add(featureLayer);  };   MyMap.Layers.LayersInitialized += layerInitializedHandler; }  <Grid>  <esri:Map x:Name="MyMap" UseAcceleratedDisplay="True">         <esri:ArcGISTiledMapServiceLayer ID="World Topo Map"                      Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>     </esri:Map> </Grid>


Cheers

Mike
0 Kudos
MiriRevivo
Occasional Contributor
Hi Mike,

Thanks for the quick response! I missed it until now for some reason, it's a good think that Antti referred me to it 🙂
We're working with 10.2.2. I will check the difference between what you posted and what we are doing and let you know.

Thanks!
Miri.
0 Kudos
MiriRevivo
Occasional Contributor
Mike,

A quick update - your code sample helped, and solved our client's problem.
They were updating the feature's symbol too early in the event cycle, which made it seem that it has no impact.
Now everything works fine.

Thanks for your help!
Miri.
0 Kudos