I'm trying to set up an alert box to fire if my layers do not load to let the user know which ones did not load. I am not sure why when I convert from some sample code I found using dojo.connect, it no longer works.
This works:
var arrayErrors = []; dojo.connect(mapObj, "onLayerAddResult", function(error){ if (error) { var errMess = error.message; arrayErrors.push(errMess); alert("Added to array\n" + errMess); } });
Whereas this does not:
var arrayErrors = []; on(mapObj, "layer-add-result", function(error){ if (error) { var errMess = error.message; arrayErrors.push(errMess); alert("Added to array\n" + errMess); } });
Using dojo.connect in the first code block, the alert box pops up with the error message for each service that does not load. In the second code block the alert box does not pop up at all. However if I put an alert box before the "if" block, that one will pop up - so for some reason an error is not being logged? Does anyone see any problems in my code?
Solved! Go to Solution.
Perfect - thanks Robert. It doesn't need to be a meaningful error; it's just to alert the user that there is an error that needs to be reported to the GIS team. I plopped this in my map and it works!