Select to view content in your preferred language

Legend doesn't work with secure map services

2628
11
Jump to solution
09-01-2011 05:47 AM
JimmyBrink
Deactivated User
We have secured map services with AGS. I have the proxy.config, proxy.ashx, and web.config in my application. My map layers display OK using the proxy. When I try and display my legend using the proxy map layers they will not display with out a login that comes up. If I enter my user and password the legend displays. I also plugged in my rest services from a unsecured AGS server and the legend displays. I looked up the dijit legend api reference and it doesn't have a parameter for the proxy.
Is there a parameter for the Legend digit that will allow you to use the proxy?
Should the legend use the proxy for the rest service?

var legend = new esri.dijit.Legend({
                    map: map,
                   layerInfos: legendLayers
                }, "legendDiv");
                legend.startup();

How anyone experienced this?

Thanks

Jimmy Brink
0 Kudos
1 Solution

Accepted Solutions
AntonioSergio
Esri Contributor
In the TOC.js file find this function _getLegendIconUrl: function (legend) and replace the url :

// resolve relative url
src = this.rootLayer.url + '/' + this.serviceLayer.id + '/images/' + src;


..

// resolve relative url
src = 'http://servername/proxy.ashx?' + this.rootLayer.url + '/' + this.serviceLayer.id + '/images/' + src;


Regards,

António Sérgio
Senior Technical Consultant
ESRI Portugal

View solution in original post

0 Kudos
11 Replies
SimonFisher
Frequent Contributor
I know this thread is a bit old, but I am experiencing a similar issue.  Legend images show up fine when accessing on the internal LAN and have access to the ArcGIS Server.  They do not show up when running everything through the esri proxy (esriConfig.defaults.io.alwaysUseProxy = true;).  Using fiddler I can see that all calls go through the proxy, except for the actual legend image requests.  The images are trying to be accessed directly through the ArcGIS Server Rest url, not the proxy, so this is the reason they do not show up.  I think that this may be a bug in the ESRI ArcGIS JavaScript API/Legend Widget, they are forgetting to check alwaysUseProxy and not sending the request through the proxy, unless there is something else I am missing.  Did you ever find a fix or workaround to your issue?

Thanks
Simon
0 Kudos
by Anonymous User
Not applicable
I am seeing this behavior also. I need to force the legend to go through the proxy but not sure how.

ESRI? Your thoughts?
0 Kudos
SimonFisher
Frequent Contributor
Has anyone been successful in getting the legend to work when using the proxy?  Or has this been fixed in the latest version of the API? 2.7?
0 Kudos
BenSayers
Emerging Contributor
Has anyone been successful in getting the legend to work when using the proxy?  Or has this been fixed in the latest version of the API? 2.7?


I'm using API v2.8 and I'm still getting this problem.

Has anyone managed to fix it?
0 Kudos
SimonFisher
Frequent Contributor
I have an open support ticket with ESRI regarding this issue.  I will update this thread when I have the issue resolved.
0 Kudos
aiminfan
Deactivated User
I am using 3.4 and still experience same issue!
Any update?
Aimin
0 Kudos
KevinMacLeod1
Frequent Contributor
I am also experiencing the same issue! We are on API 3.3.  We just secured a service with a token and put it in the proxy page. We used the token generator page to get the token. Now the secured service works fine.

But the legend symbology images come up as "x"'s in AGS JS TOC.

The legend itself loads fine, I sent the legend object to its own Accordion pane. But the legend symbology icons are X's in the AGS JS TOC widget. Which is more important. (Still not sure why they don't just include AGS JS TOC in API?)

--update--
I called ESRI and it is apparently a bug related to IE only. Something regarding "base 64 rasters" or something equally specific, and which all browsers support but IE. He said it's NIM065326: Legend widget does not honor proxy when requesting swatches. http://support.esri.com/en/bugs/nimbus/TklNMDY1MzI2

And to use this workaround: put this into the code:

dojo.connect(map, 'onExtentChange', onZoomEnd);

function onZoomEnd() {
        if (navigator.appName == 'Microsoft Internet Explorer') {
                timer = setTimeout(function () {
                                var imgs = dojo.query('.esrilegendLayer > tbody > tr > td > img');
                                for (var i = 0; i < imgs.length; i++) {
                                        imgs.src = "http://server/proxy.ashx?" + imgs.src;
                                }
                        }, 100);
        }
}




However the symbols DO load fine in my Legend dijit, just not AGS JS TOC, in IE (only in IE).

Nianwei Liu  or anyone familiar with the inner workings of the AGS JS TOC do you know?

Anyone else have any luck?
0 Kudos
KC
by
Regular Contributor

I used that workaround code, but had to change the ".esrilegendLayer" to ".esriLegendLayer" and then the swatches showed up for me.  Also used instead:

map.on("extent-change", onZoomEnd);

0 Kudos
AntonioSergio
Esri Contributor
In the TOC.js file find this function _getLegendIconUrl: function (legend) and replace the url :

// resolve relative url
src = this.rootLayer.url + '/' + this.serviceLayer.id + '/images/' + src;


..

// resolve relative url
src = 'http://servername/proxy.ashx?' + this.rootLayer.url + '/' + this.serviceLayer.id + '/images/' + src;


Regards,

António Sérgio
Senior Technical Consultant
ESRI Portugal
0 Kudos