Issues with ArcGISTiledMapServiceLayer in IE8 and IE7

Discussion created by aconnolly on Mar 20, 2013
Latest reply on Apr 2, 2013 by aconnolly

At version 3.3 there could be an issue with the ArcGISTiledMapServiceLayer. When my app loads I set show/hide one of 4 layers that represents my base map layer. Throughout the use of the app the user can switch between those different layers (think: "streets", "hybrid", "topo", etc...). When they choose any of those options I toggle between the layer's visbility.

This works without fail in all browsers that we've tested, except for IE8 and IE7. Occasionally I will find that one of my ArcGISTiledMapServiceLayer objects is NULL when I try to hide/show it.

When the page loads it hides/shows those layers based on some setting for "streets", etc..."

This lead me back to the docs for the layer object and I wondered if my layers were not loaded properly because I didn't see any errors from the "onError" call back I had hooked up.

As a general question, why would my layer object be NULL (in IE8 and IE7) if my code between versions 2.8 and 3.3 never changed? Remember when the page loads up I wait to add the layers to the map until the map is ready, etc...

Another question is, what's with the documentation on ArcGISTiledMapServiceLayer? It seems to contradict itself with the code sample:

onLoad(layer) reads:

"Fires after layer properties for the layer are successfully populated. This event must be successful before the layer can be added to the map."

Then under code snippets:

"In Internet Explorer, due to resource caching, the onLoad event is fired as soon as the layer is constructed. Consequently you should check whether the layer's loaded property is true before registering a listener for the onLoad event:"

The code reads:

function init() {
  //setting initial extent in constructor
  var map = new esri.Map("mapDiv", { extent: new esri.geometry.Extent(...) });

  //or use set extent method
  var map = new esri.Map("mapDiv");
  map.setExtent(new esri.geometry.Extent(...));

  //add first layer

This code doesn't check for "loaded == true" and neither does it hook up the onLoad event. What gives? Can we get a legit sample for how to hook up one of these layers with an onError and onLoad event? The samples for using a "basemap" now tell you to use the new "basemap" property of the map object. I don't want to do that because I want to control which layers are used for "streets", "hybrid", etc...

Can someone post a little code that shows how to properly create, hook events to and add an ArcGISTiledMapServiceLayer to a map and also explain whether or not it's wise to use the hide/show property of that layer object to control its visibility.

Frustrated ...

- Aaron