AnsweredAssumed Answered

Change legend  title, name and label of a layer 

Question asked by Mehretab on Sep 24, 2018
Latest reply on Apr 3, 2019 by rscheitlin

I am adding an  ArcGISDynamicMapServiceLayer layer on run time in to a Web appbuilder application. So far I am able to manipulate/change the title and name of the layer on the legend widget but  not the labels (marked in black)

 

If you log the layerInfoParam.layer you can clearly see that the label is part of the legendResponse object (line 151), but trying to access this object results in to "undefined". Any idea why?

The alternative to use esriRequest and fetch the legend object in json looks not  a lightweight task so not an good option.

 

console.log(layerInfoParam.layer)
{}

__coords_dx: 0

__coords_dy: 0

_active: <div style="position: absolute; width: 1136px; height: 333px; overflow: visible; transition: transform 500ms ease 0s;">

_addImage: function hitch()

_attrs: Object { "data-suspended": "", "data-hidden": "" }

_cleanUpRemovedImages: function hitch()

_ct: null

_defaultVisibleLayers: Array(15) [ 0, 1, 2,]

_displayLevels: undefined

_div: <div id="map_Topografie und Bodenbedeckung" style="position: absolute; width: 1136px; height: 333px; overflow: visible; transform: translate3d(0px, 0px, 0px); display: none;" data-suspended="" data-hidden="">

_errorHandler: function hitch()

_exclusionsPerZoom: null

_fireOnUpdate: false

_fireOnUpdateEvent: function hitch()

_hasMax: true

_hasMin: true

_hideDefaultSymbol: false

_infoTemplates: null

_inherited: Object { c: (), p: 3 }

_initLayer: function hitch()

_isRefLayer: false

_load: function hitch()

_loadCallback: undefined

_loadingList: null

_lowestLevel: 0

_lyrZEHandle: Object { remove: remove(), id: 11, receiveArguments: true,}

_map: Object { _plugins: {}, _internalLayerIds: (1) [], _layerSize: 6,}

_multiple: 1

_noDom: 0

_onExtentChangeHandler_connect: null

_onPanHandler_connect: null

_onPanStartHandler_connect: null

_Handler_connect: Object { remove: remove(), id: 8, receiveArguments: true,}

_onScaleHandler_connect: null

_onZoomHandler_connect: null

_onZoomStartHandler_connect: null

_opacityChangeHandler_connect: Object { remove: remove(), id: 0, receiveArguments: true,}

_params: Object { }

_passives: Array []

_patchIE: false

_popTile: function hitch()

_removeList: null

_resamplingTolerance: undefined

_resumedOnce: true

_rrIndex: 0

_standby: null

_tileBounds: null

_tileErrorHandler: function hitch()

_tileH: 256

_tileIds: null

_tileLoadHandler: function hitch()

_tileMapCallback: function hitch()

_tileW: 256

_tiles: null

_titleForLegend: "Topografie und Bodenbedeckung"

_transitionEnd: function hitch()

_url: Object { path: "https://geoportal.bafg.de/arcgis3/rest/services/IKSR_WRRL_2015/k1_2000_de/MapServer", query: null }

_wakeTimer: null

_wrap: true

attributionDataUrl: ""

capabilities: "Map,Query,Data"

className: undefined

copyright: ""

credential: undefined

description: ""

exclusionAreas: undefined

fullExtent: Object { type: "extent", xmin: 389280.3733725788, ymin: 5822598.578892125,}

hasAttributionData: false

id: "Topografie und Bodenbedeckung"

infoTemplates: null

initialExtent: Object { type: "extent", xmin: 389280.37337257876, ymin: 6256939.447573861,}

isPNG32: false

isResampling: false

layerInfos: Array(15) [ {}, {}, {},]

legendResponse: Object { layers: (13) [], _ssl: undefined }

loaded: true

maxImageHeight: 4096

maxImageWidth: 4096

maxRecordCount: 1000

maxScale: 1128.497176

minScale: 591657527.591555

normalization: true

onFeatureReducti: function c()

onFeatureReductionRendererChange: function c()

"token punctuation">:
function c()

onOpacityChange: function c()

onScaleRangeChange: function c()

onVisibilityChange: function c()

"onvisible-layers-change": function c()

refresh: function hitch()

refreshInterval: 0

resampling: false

resourceInfo: "{\"currentVersion\":10.51,\"serviceDescription\":\"\",\"mapName\":\"Layers\",\"description\":\"\",\"copyrightText\":\"\",\"supportsDynamicLayers\":true,\"layers\":[{\"id\":0,\"name\":\"rwseg_2000_anno_karte\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":[],\"minScale\":0,\"maxScale\":0},{\"id\":1,\"name\":\"cities_2000_anno\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":[],\"minScale\":0,\"maxScale\":0},{\"id\":2,\"name\":\"Rwseg_DATEN\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":3,\"name\":\"Grenze der 1-Meilenzone\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":4,\"name\":\"Isselmeer_Deich\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":5,\"name\":\"See_CHXX\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":6,\"name\":\"Flussgebietseinheit Rhein\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":7,\"name\":\"Uebergangsgewaesser_K1\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":8,\"name\":\"rwseg_Legende\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":9,\"name\":\"rwseg_chxx\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":10,\"name\":\"Kanal m Wesel Datteln Kanal\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":11,\"name\":\"Kanal\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":12,\"name\":\"Canal_NL\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":13,\"name\":\"Corine Land Cover 2006\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0},{\"id\":14,\"name\":\"gtopo30_hil\",\"parentLayerId\":-1,\"defaultVisibility\":true,\"subLayerIds\":null,\"minScale\":0,\"maxScale\":0}],\"tables\":[],\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857},\"singleFusedMapCache\":true,\"tileInfo\":{\"rows\":256,\"cols\":256,\"dpi\":96,\"format\":\"PNG\",\"compressionQuality\":0,\"origin\":{\"x\":-20037508.342787,\"y\":20037508.342787},\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857},\"lods\":[{\"level\":0,\"resolution\":156543.03392800014,\"scale\":591657527.591555},{\"level\":1,\"resolution\":78271.51696399994,\"scale\":295828763.795777},{\"level\":2,\"resolution\":39135.75848200009,\"scale\":147914381.897889},{\"level\":3,\"resolution\":19567.87924099992,\"scale\":73957190.948944},{\"level\":4,\"resolution\":9783.93962049996,\"scale\":36978595.474472},{\"level\":5,\"resolution\":4891.96981024998,\"scale\":18489297.737236},{\"level\":6,\"resolution\":2445.98490512499,\"scale\":9244648.868618},{\"level\":7,\"resolution\":1222.992452562495,\"scale\":4622324.434309},{\"level\":8,\"resolution\":611.4962262813797,\"scale\":2311162.217155},{\"level\":9,\"resolution\":305.74811314055756,\"scale\":1155581.108577},{\"level\":10,\"resolution\":152.87405657041106,\"scale\":577790.554289},{\"level\":11,\"resolution\":76.43702828507324,\"scale\":288895.277144},{\"level\":12,\"resolution\":38.21851414253662,\"scale\":144447.638572},{\"level\":13,\"resolution\":19.10925707126831,\"scale\":72223.819286},{\"level\":14,\"resolution\":9.554628535634155,\"scale\":36111.909643},{\"level\":15,\"resolution\":4.77731426794937,\"scale\":18055.954822},{\"level\":16,\"resolution\":2.388657133974685,\"scale\":9027.977411},{\"level\":17,\"resolution\":1.1943285668550503,\"scale\":4513.988705},{\"level\":18,\"resolution\":0.5971642835598172,\"scale\":2256.994353},{\"level\":19,\"resolution\":0.29858214164761665,\"scale\":1128.497176}]},\"initialExtent\":{\"xmin\":389280.37337257876,\"ymin\":6256939.447573861,\"xmax\":1330828.506468845,\"ymax\":7122763.679222325,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}},\"fullExtent\":{\"xmin\":389280.3733725788,\"ymin\":5822598.578892125,\"xmax\":1330828.5064688448,\"ymax\":7122763.679222326,\"spatialReference\":{\"wkid\":102100,\"latestWkid\":3857}},\"minScale\":591657527.591555,\"maxScale\":1128.497176,\"units\":\"esriMeters\",\"supportedImageFormatTypes\":\"PNG32,PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,BMP\",\"documentInfo\":{\"Title\":\"compath_2000_de.mxd\",\"Author\":\"\",\"Comments\":\"\",\"Subject\":\"\",\"Category\":\"\",\"AntialiasingMode\":\"None\",\"TextAntialiasingMode\":\"Force\",\"Keywords\":\"\"},\"capabilities\":\"Map,Query,Data\",\"supportedQueryFormats\":\"JSON, AMF, geoJSON\",\"exportTilesAllowed\":false,\"supportsDatumTransformation\":true,\"maxRecordCount\":1000,\"maxImageHeight\":4096,\"maxImageWidth\":4096,\"supportedExtensions\":\"WMSServer\"}"

scales: Array(20) [ 591657527.591555, 295828763.795777, 147914381.897889,]

setDefinitionExpression: function c()

setInfoTemplates: function c()

setLayerDefinitions: function c()

setRenderer: function c()

spatialReference: Object { wkid: 102100, latestWkid: 3857 }

supportsDynamicLayers: true

suspended: true

tileInfo: Object { rows: 256, cols: 256, dpi: 96,}

units: "esriMeters"

updating: false

url: "https://xxxx/xxx/rest/services/xxx/xxx/MapServer"

version: 10.51

visible: false

visibleAtMapScale: true

visibleLayers: Array(15) [ 0, 1, 2,]

<prototype>: Object { declaredClass: "esri.layers.ArcGISTiledMapServiceLayer", _agolAttrs: (14) [], _isReference: false,}

 

Any hint would be appreciated !!

 

Mehretab 

Outcomes