AnsweredAssumed Answered

problem with " dynamiclayer.setlayerDrawingOptions"

Question asked by yanasdf789 on Sep 18, 2016
Latest reply on Sep 21, 2016 by fcbassongis

I try to ClassbreaksRenderer with dynamiclayer, But I get the problem "dynamiclayers is not enabled on  this  MapService", My Code is

#

 map = new esri.Map("map", { extent: extentNingbo32651, center: [605326.8575680437, 106118.09019766698]});

var zwmap = new esri.layers.ArcGISTiledMapServiceLayer("http://"+location.hostname+":6080/arcgis/rest/services/xxxx/MapServer", {
id: "zw",
opacity: 1

});

map.addLayer(zwmap);

var DyLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://192.168.1.1:6080/arcgis/rest/services/xxxx/MapServer", { id: "zhen", opacity: 0.8 });
DyLayer.setVisibleLayers([0]);
var layerDefs = [];
layerDefs[0] = "FNAME='AA'";
DyLayer.setLayerDefinitions(layerDefs);
var Dyrenderer = new esri.renderer.ClassBreaksRenderer(null, "OBJECTID");
var Dyoutline = new esri.symbol.SimpleLineSymbol("solid", new esri.Color([205, 192, 197]), 1);
var Dycolors = [
new esri.Color([255, 51, 51, 0.8]),
new esri.Color([255, 51, 51, 0.8]),
new esri.Color([255, 51, 51, 0.8]),
new esri.Color([255, 51, 51, 0.8]),
new esri.Color([255, 51, 51, 0.8])
];
Dyrenderer.addBreak(0, 1, esri.symbol.SimpleFillSymbol("solid", Dyoutline, Dycolors[0]));
Dyrenderer.addBreak(1, 3, esri.symbol.SimpleFillSymbol("solid", Dyoutline, Dycolors[1]));
Dyrenderer.addBreak(3, 5, esri.symbol.SimpleFillSymbol("solid", Dyoutline, Dycolors[2]));
Dyrenderer.addBreak(5, 20, esri.symbol.SimpleFillSymbol("solid", Dyoutline, Dycolors[3]));
Dyrenderer.addBreak(20, 200, esri.symbol.SimpleFillSymbol("solid",Dyoutline,Dycolors[4]));

 

var drawingOptions = new esri.layers.LayerDrawingOptions();
drawingOptions.renderer = Dyrenderer;
var optionArray = [];
optionArray[0] = drawingOptions;
var drawingOptions = new esri.layers.LayerDrawingOptions();
drawingOptions.renderer = Dyrenderer;
var optionArray = [];
optionArray[0] = drawingOptions;
DyLayer.setLayerDrawingOptions(optionArray);
map.addLayer(DyLayer);

#

 

I debug with firefox,when run the "DyLayer.setLayerDrawingOptions(optionArray);",I get the error"dynamicLayers is not enabled on this MapService"

Outcomes