LayerList with token protected layer

6643
13
05-20-2016 07:59 AM
MarcoRosa
New Contributor

Hi to all,

im going to set up Layer List in this way:

var llWidget = new LayerList({
                    map: map,
                    showLegend: true,
                    showOpacitySlider: true,
                    layers: [{
                        layer: mylayer,
                        id: "mylayerID",
                        subLayers: true
                    }]
                }, "layerList");
                llWidget.startup();

Note that mylayer becomes from a request for a token protected lite this:

var mylayer= new ArcGISDynamicMapServiceLayer(url_mylayer + "?token=" + token, {})

Doesn't work .... error is invalid tokens when request to legends it's made. How can i set layer to layer list in thic case ?

Where's the mistake?

Thank's in advanced to all

GP

0 Kudos
13 Replies
MarcoRosa
New Contributor

Hi Joel,

done that …. Added require "esri/dijit/Legend", and modified code following istructions. Protected are correctly added to map , no more errors were generated but legend doesnt work correctly.

I can view just first layer without detailed options (layer styles / opacity)

Now in trying to download and install local api …. We’ll see

Da: Joel Bennett

Inviato: lunedì 23 maggio 2016 14:58

A: Porta Giorgio

Oggetto: Re: - LayerList with token protected layer

GeoNet <https://community.esri.com/?et=watches.email.thread>

LayerList with token protected layer

reply from Joel Bennett<https://community.esri.com/people/bennetjo?et=watches.email.thread> in ArcGIS API for JavaScript - View the full discussion<https://community.esri.com/message/610200?et=watches.email.thread#comment-610200>

0 Kudos
JoelBennett
MVP Regular Contributor

Could you post the relevant portions of your code with the modifications included?  In the case that it is correct, there may also be some additional requires I didn't think of initially.

0 Kudos
JoelBennett
MVP Regular Contributor

Yes, looking at it more closely, you're better off setting up the API locally and tweaking the one file.  Trying the inline fix actually gets pretty nasty...those two functions are full of required modules...for example, in _legendRequestServer, I can see that:

c = dojo/_base/lang

l = dojo/json

d = dojo/_base/array

w = esri/request

There's more in the _buildRow_Tools function as well.  It's possible to work with this, but very ugly, so I wouldn't recommend it.  I apologize for sending you down that trail without fully thinking it through.

0 Kudos
MarcoRosa
New Contributor

Hello Joel,

downloaded, installed local API and made workaround inside Legend.js as your suggestion, it works all fine.

Thanks a lot, hear from you soon,

Giorgio

Da: Joel Bennett

Inviato: lunedì 23 maggio 2016 18:47

A: Porta Giorgio

Oggetto: Re: - LayerList with token protected layer

GeoNet <https://community.esri.com/?et=watches.email.thread>

LayerList with token protected layer

reply from Joel Bennett<https://community.esri.com/people/bennetjo?et=watches.email.thread> in ArcGIS API for JavaScript - View the full discussion<https://community.esri.com/message/610333?et=watches.email.thread#comment-610333>

0 Kudos