Skip to main content
Inspiring
October 11, 2016
Answered

hide layers

  • October 11, 2016
  • 1 reply
  • 418 views

I need to hide a layer called draft but some times it's spelt Draft and other times its draft.

openDocs.layers.item("(?i)DRAFT").visible = false; // This was a failed attempt

I thought that maybe changing it toUpperCase might work but it didn't, maybe my code was wrong.

Can anyone provide some guidance?

This topic has been closed for replies.
Correct answer tpk1982

Am not sure we can use regular expression in condition like you did, but we can use like below

var input = ['Draft','draft']; 

i = input.length; 

  while(i--){

    if(openDocs.layers.itemByName(input).visible==true){ 

        openDocs.layers.itemByName(input).visible=false; 

}

     

      }

1 reply

tpk1982
tpk1982Correct answer
Legend
October 11, 2016

Am not sure we can use regular expression in condition like you did, but we can use like below

var input = ['Draft','draft']; 

i = input.length; 

  while(i--){

    if(openDocs.layers.itemByName(input).visible==true){ 

        openDocs.layers.itemByName(input).visible=false; 

}

     

      }

Inspiring
October 11, 2016

Thanks

Is there a way of testing it by converting the string to upper or lowercase?

tpk1982
Legend
October 11, 2016

We can use toLowercase or toUppercase, for example

var mylayer="Draft"

alert(mylayer.toLowerCase())