songhu

change font on ArcGISDynamicMapServiceLayer

Discussion created by songhu on May 27, 2013
Hi,
I am displaying a map as a ArcGISDynamicMapServiceLayer. The map comes with some labels and I want to change its font at the client side. I tried to use layerDrawingOption and SimpleRenderer but no success. I have attached my code below, could anyone point out what I missed?
Many thanks in advance!

    <script>
      dojo.require("esri.map");
      dojo.require("esri.renderer");

      var map;

      function init() {
        map = new esri.Map("mapDiv", { 
          sliderOrientation: "horizontal"
        });

        var imageParameters = new esri.layers.ImageParameters();
        imageParameters.format = "png"; 

        //Takes a URL to map service.
        var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("myMapServericeURL", {
          "opacity":0.5, 
          "imageParameters":imageParameters
        });
        
        //symbol
        var textSymbol =  new esri.symbol.TextSymbol("Change Font")
        .setColor(new dojo.Color([128,0,0]))
        .setAlign(esri.symbol.Font.ALIGN_START)
        .setAngle(45)
        .setFont(new esri.symbol.Font("10pt")
        .setWeight(esri.symbol.Font.WEIGHT_BOLD));

        //render
        var render = new esri.renderer.SimpleRenderer(textSymbol);
          
        var layerDrawingOptions = [];
        var layerDrawingOption = new esri.layers.LayerDrawingOptions();
        layerDrawingOption.scaleSymbols = true;
        layerDrawingOption.showLabels = true;
        layerDrawingOption.transparency = 5;
        layerDrawingOption.renderer = new esri.renderer.SimpleRenderer(render);
        layerDrawingOptions[0] = layerDrawingOption;
        dynamicMapServiceLayer.setLayerDrawingOptions(layerDrawingOptions);
        
        map.addLayer(dynamicMapServiceLayer);
      }

      dojo.ready(init);
    </script>

Outcomes