tjrourke

JSAPI map won't load layers until the page is refreshed.

Discussion created by tjrourke on Nov 12, 2012
Latest reply on Mar 16, 2018 by DelRayNolan
Client-side:
    ArcGIS JavaScript API version 2.5 - 2.7, local server installation
        jQuery
    Browsers: Internet Explorer (7, 8 and 9), Firefox and Chrome.


Server side:
    ASP.NET MVC 3 on Windows 2008 servers using IIS 7.5
Map services
    Operational layers (dynamic and feature layers) are on our ArcGIS Servers
    Basemap is the World Street Map layer from ArcGIS Online.


We have built some map applications to be consumed in pages built by other development teams.
When our map applications load the first time for a user (or after clearing the browser cache), one or more layers fails to load.


Our in-house map services depend on database connections that are severed by the firewall when they are maintained for too long. We have timed jobs to reset those map services, but when they're cut off it can take a couple of minutes for them to be available to users. That's not the issue I'm talking about here.


We added some JavaScript classes to check that the layers have loaded and retry if necessary, with a limit of five retries. After five failures to load, we pop up a message that tells the user one or more layers couldn't load and asks the user to refresh the page. After the refresh, the layers usually load, though not always.


The classes we added were modified from code found here at http://forums.esri.com/Thread.asp?c=158&f=2396&t=291261, but the other developers want the map to load first time, every time. I've been assuming this is a network issue - the code doesn't change, the map services don't change and the browser doesn't change - the only thing is a new call. Also, we changed to local installs of the JSAPI because we routinely get Dojo errors from the Esri CDN version not being found. Still, we need to get around this one.


A programmer on one of the other teams suggested the resources are not loading fast enough. Since the onLoad event is the only point I know of to determine when the API has loaded the layer, I've been checking it in debug. I even increased the number of retries and the timeout period. I found that if the layer didn't load the first time, it never will. But when I refresh the page, it loads the layers from the cache and it works. I clear the cache again, retry and it fails, then refresh and it works.


Has anyone else had a problem like this with their layers not loading?

Outcomes