Select to view content in your preferred language

Credential request only when Layer activated.

1799
1
01-14-2016 07:14 AM
ChristopherSchreiber
Frequent Contributor

Hello, Is there anyway to delay the JavaScript credential prompt to display when the layer that requires a login is activated?

I have a js map and I have multiple layers on it. Only 2 out of the 6 total layers are secured (they are stored on our organization's AGOL account). Like normal, when the map opens, it asks for credentials for AGOL. Is there a way to only have the credential request box display only when the AGOL layers are selected in the Layer list widget?

I am still pretty new to js, so I apologize.

Thank you!

0 Kudos
1 Reply
JordanBaumgardner
Frequent Contributor

I might try creating a different TOC. If you populated your TOC apart from the map you could then control when the layer was added to the map, only prompting the login when a secure service was added. Level of effort would depend on how much you were using the Digit/toc Functionality. If your just toggling visibility on 6 layers, I might roll my own and have it add the layers if not currently present.

There is probably a cleaver way to get the digit/toc to do that as well. I wonder if you faked out its LayerInfo array, perhaps give it a url that is not secure, then flip it first time pressed to the actual url.  ... Some random duck tape thoughts ...

[0] unsecureUrl

[1] unsecureUrl(fake) but switched to proper secureUrl when first pressed

[2] unsecureUrl

....

0 Kudos