AnsweredAssumed Answered

JSAPI 4.3 vs 4.6 Legend Widget "visible" property

Question asked by p_griffith on Jan 16, 2018
Latest reply on Jan 16, 2018 by p_griffith

I originally wrote some code using the 4.3 Javascript API to make the Legend widget visible only at certain scales of the map view:


var legend = new Legend({
    view: mapView,
    layerInfos: [{
      layer: myLayer,
      title: "My Title"
    visible: false
});"scale", function(scale) {
   if (scale > 1500000) {
    legend.visible = false;
   } else {
    legend.visible = true;


When using version 4.3 of the Javascript API, this code works: the Legend changes its visibility at the appropriate scale.

When using version 4.6 of the Javascript API, this code breaks: the Legend always remains visible, but switches between displaying the layer properties and displaying "No legend," rather than disappearing as it did before.


How can I mimic the functionality of 4.3 in version 4.6?


Thanks for the help!