deleted-user-yA_w_FC9FKe5

Disable button based on zoom

Discussion created by deleted-user-yA_w_FC9FKe5 on Apr 18, 2014
Latest reply on Apr 21, 2014 by BSnider-esristaff
I have a button that is summarizing data but I want the toggle button to only be enabled when at a certain zoom and then disabled when above it.  How can I do this?

        new ToggleButton({
          showLabel: true,
          onChange: function(val){           
            if(val == true){
     document.getElementById("messages").style.display = 'block'
     buffer = map.on("click", function(evt){
                circle = new Circle({
                center: evt.mapPoint,
                geodesic: true,
                radius: 1,
                radiusUnit: "esriMiles"
              });
              //Being used
     map.graphics.clear();
              map.infoWindow.hide();
              var graphic = new Graphic(circle, circleSymb);
              map.graphics.add(graphic);

              var query = new Query();
              query.geometry = circle.getExtent();
              //use a fast bounding box query. will only go to the server if bounding box is outside of the visible map
              featureLayer.queryFeatures(query, selectInBuffer);
            });
            this.set('label', 'Close Buffer Report Tool');
           }
           else{
   map.graphics.clear();
            featureLayer.clearSelection();
            buffer.remove();            
            document.getElementById("messages").style.display = 'none'
   this.set('label', 'Open Buffer Report Tool');
  
   dom.byId("messages").innerHTML = "Click on the map <br> to select 5 mile buffer.";
           }
          },
          label: "Open Buffer Report Tool"
        }, "btnBufferTool");

Outcomes