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"
Yan,
That error does mean there is anything wrong with your code it means that you map service is not enabled for dynamic layer use. To fix this open the map service in ArcGIS server and enable it.
I find there is no wrong wtith map service,how to fix ?
when I comment the code "DyLayer.setLayerDrawingOptions(optionArray);", the dynamic layer show ,so it mean my service is ok。
is there anythong wrong?
should I config the proxy ?
Yan,
When you go to your REST service directory for that map service does it say "Supports Dynamic Layers: true"? As I mentioned before the map service has to support dynamic layers, that is what your error is saying.
thank you for your reply, I find "support Dynamic Layers:false",When you go to your REST service directory for that map service.how to fix the service to support Dynamic Layers?
Yan,
I have already mentioned how to fix that. You go to the map service in ArcGIS Manager and enable
Dynamic Workspaces
Allow per request modification of layer order and symbology
Yan,
Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.
As Robert Scheitlin, GISP said, go to the service Capabilities -> Mapping, click the Allow per request modification option on, click the manage button and select the workspace for the layer.