AnsweredAssumed Answered

Can I make a button a toggle for multiple feature layers?

Question asked by NMWRRI on Mar 24, 2016
Latest reply on Mar 24, 2016 by NMWRRI

Hi all! Thanks for taking the time to look into this.


I have two buttons that I added manually into my webmap. One of them is a hover dropdown that shows my layers.

I have six feature layers in total, however 3 of the layers are in inches and 3 are in millimeters. The other button is my unit button (buttona).When I click my unit button (buttona)  the inner.HTML flip flops between Inches and Millimeters (see code below), is there a way to program buttona so that this button looks for the current layer that is currently showing and after its clicked it would display its counter part?


For example: If I have a county layer displaying in inches, when I click "buttona", it would hide the inches layer and display the county millimeters layer? Any help would be greatly appreciated!


Kindest Regards,


Francisco Ochoa


var flipflop = false;

var buttona = document.getElementById("buttona");

buttona.onclick = function change() {

       if (!flipflop) {

            buttona.innerHTML = "Inches";

       } else {

            buttona.innerHTML = "Millimeters" }

  flipflop = !flipflop;



  function showcounties() {

  if ( buttona.innerHTML == "Millimeters" ) {



  else {





  function showHUC8() {

  if ( buttona.innerHTML == "Millimeters" )


  else { showHUC8in();}};



  function showWPR() {

  if ( buttona.innerHTML == "Millimeters" )


  else {showwprin();}};


  function showcountymm()  {; HUC8.hide(); WPR.hide(); CNTYin.hide(); HUC8in.hide(); WPRin.hide();}


  function showhuc8mm() {

  featureLayer.hide();; WPR.hide(); CNTYin.hide(); HUC8in.hide(); WPRin.hide();}


  function showwprmm() {

  featureLayer.hide(); HUC8.hide();; CNTYin.hide(); HUC8in.hide(); WPRin.hide();}


  function showcountyin(){

  featureLayer.hide(); HUC8.hide(); WPR.hide();; HUC8in.hide(); WPRin.hide();}


  function showHUC8in(){

  featureLayer.hide(); HUC8.hide(); WPR.hide(); CNTYin.hide();; WPRin.hide();}


  function showwprin(){

  featureLayer.hide(); HUC8.hide(); WPR.hide(); CNTYin.hide(); HUC8in.hide();;}