How do you get renderer from a feature layer?

6974
13
Jump to solution
03-11-2015 03:35 PM
MorganEverett
New Contributor III

How do you get the renderer from a feature layer? 

I want to get the current rendered from a feature layer, and then set the RotationInfo on it so I can rotate my graphics that are in that feature service.

0 Kudos
13 Replies
deleted-user-wcpelUUf_XXx
New Contributor III

Robert,

the original service is not mine, its already up and working on the web with all the symbology present, there is nothing im trying to use that is not already working on the service as it is.

this is the service on a webapp with the symbology working perfectly, using this supported and already published service in the code to extract renderer still results in bad partial symbology when i try and replicate it.

how can i extract the already working renderer to my layer without losing the data?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Segev,

   Most likely the difference you are seeing there is that the layer is being rendered server side (using ArcObject) verses you attempting to render clientside using the JS API (i.e. a ArcGISDynamicMapServiceLayer vs. FeatureLayer). To see this add the url as ArcGISDynamicMapServiceLayer in your app and you will see all the symbology just fine.

deleted-user-wcpelUUf_XXx
New Contributor III

is this what you meant?

i also added the requirements but the console.info\renderer returns as undefined.

var serviceUrl = "https://ags.iplan.gov.il/arcgisiplan/rest/services/PlanningPublic/Xplan_2039/MapServer/1";
var layer = new ArcGISDynamicMapServiceLayer(serviceUrl);

if (featureLayer.graphics) { 
layer.on('load', function(evt){ 
console.info(evt.target.renderer);
featureLayer.setRenderer(evt.target.renderer)
});
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

No, not at all. What I am saying is that when you add a ArcGISDynamicMapServiceLayer to a map that the rendering is done on the server and an image (not clientside graphics) is returned to the JS API. Thus the server has no issue drawing these complex composite fills. A FeatureLayer is drawn clientside and use the JS API for all it's rendering and thus is limited in several ways that the server is not. You code above is still trying to apply the renderer to a FeatureLayer and you will continue to have the same issue as before.