Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If any of my ESRI REST map services are down I want to be able to tell the user, at minimum with an alert or message.

I thought I could use onLayerAddResult(layer, error) but it doesn't seem to be getting called if the layer based on a stopped/down service is added to the map, only when a layer is successfully added.

I see some examples using esri.request but it doesn't seem like I should have to do an extra call to the service since in the Firebug console I see these calls like this to each service:

http: //myserver/ArcGIS/rest/services/Streets/Mask/MapServer?f=json&dpi=96&transparent=true&format=png8&layers=show%3A-1&

With a response of either:

*{"serviceDescription" : null,"mapName":"Layers","description":"","copyrightText":"","layers":[{"id":0,"name":"LMBCO_Mask","parentLayerId":-1,"defaultVisibility":true,"subLayerIds":null}],"tables":[],"spatialReference":{"wkid":2263},"singleFusedMapCache":false,"initialExtent":{"xmin":806353.163236593,"ymin":139639.306949227,"xmax":1165380.94101437,"ymax":327833.751393672,"spatialReference":{"wkid":2263}},"fullExtent":{"xmin":824755.941014371,"ymin":38597.6402825604,"xmax":1146978.16323659,"ymax":323319.862504783,"spatialReference":{"wkid":2263}},"units":"esriFeet","supportedImageFormatTypes":"PNG32,PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,BMP","documentInfo":{"Title":"","Author":"","Comments":"","Subject":"","Category":"","Keywords":"","AntialiasingMode":"Normal","TextAntialiasingMode":"Force"},"capabilities":"Map,Query,Data"});*

if the service is up and running, or:

*{"error":{"code":400,"message":"Unable to complete operation.","details":["Service 'NYCStreets/LMBCO_Mask' of type 'MapServer' does not exist or is inaccessible."]}});*

if the service is not available.

Is there a way to handle this reponse that is already coming back?

Thanks for your help!

Chad Wilcomb

share|improve this question

Try connecting it to a dojo handler, like this:

    dojo.connect(map, "onLayerAddResult", function(layer, error){
    if (error) {
        var content = "Layer could not load: " + + "<br />" + layer.url + "<br />";
        alert("Major Error loading Content", content);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.