I am trying to use someone else's map service in my web map, but their symbology is atrocious so I need to render new colors through JavaScript API.

I try the following (amongst many other efforts spanning 2 days):

       parcels = new ArcGISDynamicMapServiceLayer(config.mapServices.parcels, {id:"Parcels"});
       parcels.on("load", function(){

           var layerDrawingOptions = [];
           var layerDrawingOption = new LayerDrawingOptions();

            // set symbology overrides
            layerDrawingOption.renderer = new SimpleRenderer(symbols.polygon);

            // the following index represents the layers in the service to apply the renderer to
            layerDrawingOptions[8] = layerDrawingOption;

            parcels.setVisibleLayers([8]); //schools,streets,parks,parcels,boundaries,shields

       })   ;       


I am following this currently: https://developers.arcgis.com/javascript/jsapi/layerdrawingoptions-amd.html#renderer

The few examples at the API deal with renderers for class-breaks, etc, I need to resymbolize all parcels, which should be a similar concept. Any ideas on how I can symbolize a dynamic layer at the client rather than the server using JS API?

1 Answer 1


the two most common gotchas for Dynamic Layers are:

  1. the service itself doesn't support requests to alter symbology. (make sure Supports Dynamic Layers is true in the service metadata)

  2. the index position in the layer drawing options array doesn't match the index position of the layer.

    var sfs = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
      new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
      new esri.Color([0,255,0]), 2),new esri.Color([0,0,255,1])
    app.renderer = new esri.renderer.SimpleRenderer(sfs);
    var optionsArray = [];
    var drawingOptions = new esri.layers.LayerDrawingOptions();
    drawingOptions.renderer = app.renderer;
    //since we're attempting to alter the drawing rule for layer 3, we insert into the same position
    optionsArray[3] = drawingOptions;

i published a working sample here

  • Thanks for the clarrification, John. He had "supports dynamic layers" set to false... Do you suppose that was the catch?
    – CCantey
    Apr 3, 2015 at 17:54
  • absolutely. youre never going to be able to modify the symbology of a dynamic map service that doesn't have the capability 'turned on' Apr 4, 2015 at 19:22

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.