Select to view content in your preferred language

Legend Widget with ArcGISTiledMapServiceLayer

852
3
Jump to solution
10-24-2018 10:07 AM
markpenton1
Emerging Contributor

In regards to displaying a ArcGISTiledMapServiceLayer in a legend widget with the JavaScript 3.26 API (see code and layer below). The legend is displaying the layer's symbology, but it is simultaneously displaying a set of symbology, one for each scale cached into the service layer. The results of which is that I see (the same) symbology in the legend for all scales. I am only interested in the legend displaying the correct symbols based on the map's current display scale. Any way to javascript code my way around this? BTW- I am not the owner of this layer.

basemaplayerStreet = new esri.layers.ArcGISTiledMapServiceLayer("http://maps.cityofmobile.org/ArcGIS/rest/services/Base_Cache/MapServer",
{id: 'City Base'});

 map.on("layers-add-result", function (results)
 {

  var legendDijit = new Legend
  ({map: map,}, "legendDiv");  


  legendDijit.startup(); 
     
  }); /*end layers-add-result*/

  map.addLayer(basemaplayerStreet);

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Mark,

   Because ArcGISTiledMapServiceLayer just returns cached tiles from the server you have no control over what layer are displayed. You would have to switch to a ArcGISDynamicMapServiceLayer and it will only show the layers based on their visible scale.

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Mark,

   Because ArcGISTiledMapServiceLayer just returns cached tiles from the server you have no control over what layer are displayed. You would have to switch to a ArcGISDynamicMapServiceLayer and it will only show the layers based on their visible scale.

0 Kudos
markpenton1
Emerging Contributor

Robert,

Thanks and that was what I was thinking. Guess the alternative is a fixed image representing a legend inside of a dojo ‘contentpane’.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Mark,

   Yep that is a good option.  Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.

0 Kudos