Select to view content in your preferred language

get renderer from REST service

1351
2
Jump to solution
02-07-2018 04:52 PM
JimNoel
Occasional Contributor

I have a FeatureLayer, that I would like to render using the same scheme as an existing REST service sublayer.  I thought if I made a MapImageLayer based on the REST service, I could use the sublayer's renderer property.  However, this property seems to be designed only for overriding the REST service, not for getting the info from the service.  (The property shows up as null.)

Anyone know a way of getting this info?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Jim,

   You can do this if you use a esriRequest to get the drawingInfo from the sub layer and then use jsonUtils.fromJson ('esri/renderers/jsonUtils') method to create the renderer.

        esriRequest({
          url: YOUR_layerUrl,
          content: {
            f: 'json'
          },
          handleAs: 'json',
          callbackParamName: 'callback'
        }).then(lang.hitch(this, function (layerInfo) {
          var rend = jsonUtil.fromJson(layerInfo.drawingInfo.renderer);
        }));‍‍‍‍‍‍‍‍‍‍

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Jim,

   You can do this if you use a esriRequest to get the drawingInfo from the sub layer and then use jsonUtils.fromJson ('esri/renderers/jsonUtils') method to create the renderer.

        esriRequest({
          url: YOUR_layerUrl,
          content: {
            f: 'json'
          },
          handleAs: 'json',
          callbackParamName: 'callback'
        }).then(lang.hitch(this, function (layerInfo) {
          var rend = jsonUtil.fromJson(layerInfo.drawingInfo.renderer);
        }));‍‍‍‍‍‍‍‍‍‍
JimNoel
Occasional Contributor

Thanks, Robert!  I forgot to mention that I was using 4.6, but once I adjust for that version, it works fine.  Much appreciated!

0 Kudos