Legend Dijit Problem in Internet Explorer (IE)

1202
8
10-31-2011 11:44 AM
PatrickWilke-Brown
New Contributor
Is anyone else having a problem with the Legend dijit in JSAPI v2.1+ and IE? The legend dijit seems to work fine using services from ArcGIS Server version 9.3,9.3.1 and 10 in Firefox and other browsers but fails to load/generate legends from 9.3.1 versions in IE 7 and 8.

In the Legend.xd.js the following line exists which is used to construct a request to generate legend symbols for the dijit. However this URL is returning a 302 - Temporarily redirected status. IE doesn't seem to follow the redirect within the javascript code. Manually entering the address with the soapURL parameter does get redirected correctly.

Legend.xd.js
_legendUrl:"http://www.arcgis.com/sharing/tools/legend

Does anyone now of a way to override this to set it to the current legend service at http://utility.arcgis.com/sharing/tools/legend or other legend service?
0 Kudos
8 Replies
AndrewBrown1
Occasional Contributor II
Are you using the secured service?

We are with a proxy, and we're having the same issue. We're using the TOC Control listed below, and the icons show up on Firefox and Chrome, but not in IE 7/8. We're currently trying to figure it out, and we think that the GET command for the legend symbols isn't utilizing the proxy, thus returning nothing. It is odd why it works on other browsers though...


http://www.arcgis.com/home/item.html?id=9c43bdf76a23452ba1d95684f7cd76d8
0 Kudos
AndrewBrown1
Occasional Contributor II
Well, we just figured out why it wasn't working in IE.

Since we're using the previously mentioned TOC widget, there are a couple lines in the TOC.js file that we needed to modify:

if(!dojo.isIE && a.imageData && a.imageData.length > 0) {
    b = "data:image/png;base64," + a.imageData
  }else {
    if(b.indexOf("http") !== 0) {
      b = "https://www.website.com/gis/proxy/proxy.ashx?" + this.service.url + "/" + this.layer.id + "/images/" + b
    }
  }


All we simply did was add our website proxy URL in front of this.service.url and it works perfectly. Just by reading the above code, it seems that IE handles the images differently than other browsers. Boo Microsoft.
0 Kudos
PatrickWilke-Brown
New Contributor
I am not using a proxy.

Originally I had been using something similar to the TOC legend you are using but kept running into problems so I started testing for the problem using one of the ESRI Legend Dijit samples. Ran into the same problem. FF,Chrome,Safari all render the legend from both a 10.0 and 9.3.1 service, the 10.0 using the REST api and the 9.3.1 service using ESRI's utility.arcgis.com legend service.

I downloaded the 2.5 JSAPI so that I could host it locally. This also allowed me to change the URL to the ESRI legend service. It is currently hardcoded to www.arcgis.com/... but gets redirected to http://utility.arcgis.com. I changed the URL in Legend.xd.js to utility.arcgis.com to bypass the redirect. After doing this I can use the IE8 developer tools to inspect the response after the legend.startup. It looks like the legend images from the 9.3.1 legend are being generated by the ESRI legend service request but not being handled correctly within the JSAPI. Probably something similar to the problem described in the previous message. Your response give me hint to where to start looking.
0 Kudos
PatrickWilke-Brown
New Contributor
Follow up to problem. I mistakenly identified this as an issue with 9.3.1 services. The problem in our case was in the Legend.xd.js and how the generated legend image resource location is checked. We have all of our services as https:// resources, some of logic in Legend.xd.js was checking to see if http:// existed and if it didn't then append the original service URL + /image/ to the legend patch location. This doesn't exist in 9.3.1 services. Using a local copy of v. 2.5 of the JSAPI i changed the following lines so that it would work with our services.

Legend.xs.js (unminified)

~line 412 
         
OLD //if((_43.url && _43.url.indexOf("http://") > -1) || (_43.imageData && _43.imageData.length > 0)) {
NEW if((_43.url && _43.url.indexOf("http://") > -1) || (_43.url && _43.url.indexOf("https://") > -1) || (_43.imageData && _43.imageData.length > 0)) {

~line 456, this probably should be handled differently since if if http:// wasn't present /image/ was appended.
OLD //if( (_44.url.indexOf("http://") == -1)) {
NEW if( (_44.url.indexOf("http://") == -1) && _44.url.indexOf("https://") == -1) {

0 Kudos
KellyHutchins
Esri Frequent Contributor
Patrick,

Thanks for reporting this issue. We are working to fix this for the next release of the ArcGIS API for JavaScript.
0 Kudos
BenSayers
New Contributor II
Patrick,

Thanks for reporting this issue. We are working to fix this for the next release of the ArcGIS API for JavaScript.


I am still having this problem, running AGS 10.04 and using API v2.8.
Is there an easy fix or known work around?
0 Kudos
DavideLimosani
Occasional Contributor II
I have found the same issue with API 3.0 and arcgis server 10.

in IE the legend works in a different way and the images are loaded via http and they dont pass through the proxy.

I have found this workaround, hope it helps:

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 = "yourproxy" + imgs.src;
        }
        }, 100);
    }
}
0 Kudos
__Rich_
Occasional Contributor III
Just got round to reviewing my 'workarounds' for this issue (same cause for legend images and feature layer images) and I'm unpleasantly surprised that it still exists in v3.0.  All other operations (export, query, identify, find etc. etc.) use the proxy correctly, any idea when this problem will be addressed?
0 Kudos