in the rest service ,there is renderer in "Drawing Info" but in JS api it is not found.
Solved! Go to Solution.
You can probably retrieve it by getting the layer information in JSON with a request (esri/request | API Reference | ArcGIS API for JavaScript )
var layersRequest = esri.request({ url: "http://<server>/arcgis/rest/services/<service>/MapServer/<layer index>", content: { f: "json" }, handleAs: "json", callbackParamName: "callback" }); layersRequest.then( function(response) { console.log("Success: ", response.drawingInfo); }, function(error) { console.log("Error: ", error.message); });
This will give you the same result as http://<server>/arcgis/rest/services/<service>/MapServer/<layer index>?f=pjson
You can probably retrieve it by getting the layer information in JSON with a request (esri/request | API Reference | ArcGIS API for JavaScript )
var layersRequest = esri.request({ url: "http://<server>/arcgis/rest/services/<service>/MapServer/<layer index>", content: { f: "json" }, handleAs: "json", callbackParamName: "callback" }); layersRequest.then( function(response) { console.log("Success: ", response.drawingInfo); }, function(error) { console.log("Error: ", error.message); });
This will give you the same result as http://<server>/arcgis/rest/services/<service>/MapServer/<layer index>?f=pjson
it seems there are things that should be simpler... and easier...
The 1st option of requesting using the rest api does not work if it was disabled which many people do.
The 2nd option may work. It is such a long winded workaround I'm suprised anyone ever thought of that... I'm going to give it a try.
But it really is strange you cannot just tweak a renderer, eg change 1 color. You have to build an entire new renderer, and disregard completly what the author of the map intended for the symbology of the layers. It's just awkward...
Yeah, you can request it as done in the previous comment, or you can create a FeatureLayer with the sublayer ID appended to the end of the URL and access the renderer that way.