GetLegendInfosAsync() does not return legends in case of ArcGISTiledLayer

792
3
Jump to solution
06-01-2021 06:58 AM
RomanBoros
New Contributor III

Hi

Could you please assist with how we can fetch legends from the Map Tiles service?

Below is the sample code, we have consumed the tile by URL which is rendered successfully to the map view. 

ArcGISTiledLayer layer = new ArcGISTiledLayer(new Uri(LayerUrl)) ;
await baseLayer.LoadAsync();
var legends = layer.GetLegendInfosAsync();

However, GetLegendInfosAsync()  does not return the legend associated with the tile service. 

RomanBoros_0-1622555375421.png

Thanks :)  in advance 

0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor

'await' is missing in your code, the task is not executed yet at your debug point.
var legend = await sublayer.GetLegendInfosAsync();

View solution in original post

3 Replies
DominiqueBroux
Esri Frequent Contributor

The legend is provided by sublayers so you have to get the SubLayers, loop on the sublayers, and call GetLegendInfosAsync on each sublayer (even if frequently a tiled layer has only one sublayer)

0 Kudos
RomanBoros
New Contributor III

Thanks for your response. After trying GetLegendInfosAsync () on the sublayer it returned null as a result and Status as Waiting for Activation. Anything we need to configure on on the Tile Service? see below snapshot

RomanBoros_0-1622561498971.png

 

0 Kudos
DominiqueBroux
Esri Frequent Contributor

'await' is missing in your code, the task is not executed yet at your debug point.
var legend = await sublayer.GetLegendInfosAsync();