2

When creating a new FeatureLayer in the ArcGIS Maps SDK for JavaScript, it's possible to specify a renderer, to tell the layer how draw on the map.

If you don't specify a renderer, the symbology properties from the layer's REST endpoint are used.

For example, in this sample States layer the renderer is shown as below, and this is used to symbolise the layer in the absence of the renderer property being used in the FeatureLayer constructor:

drawingInfo": {
  "renderer": {
    "type": "simple",
    "symbol": {
      "type": "esriSFS",
      "style": "esriSFSSolid",
      "color": ...

But when a FeatureLayer is made from this States layer, the FeatureLayer.renderer property is undefined, as shown in the demo at https://codepen.io/slead/pen/NWLOGWN

const featureLayer = new FeatureLayer({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2"
});
console.log("renderer", featureLayer.renderer)

How can I obtain the details of the layer's default renderer, being that set by its REST endpoint?

1 Answer 1

4

You have to wait for featureLayer to be created to get renderer.

Relevant code could then look something like this:

featureLayer.on("layerview-create", function(event){
  console.log("renderer", featureLayer.renderer);
});

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.