Select to view content in your preferred language

"Error getting service" - maybe error on TOC generation

2546
5
06-13-2014 04:12 AM
AdrianMarsden
Honored Contributor
Hi (apologies if this is considered a AGS issue - mods feel free to move)

My users are reporting occasions when the TOC (Nianwei Liu's) doesn't populate.

I rarely see it myself, but I just did, and by luck (as it is in IE) I had the F12 console up.  No errors or messages at all.

Digging into the Server logs and I can see some

"WARNING Error getting service."  With REST as the source

No more details, but from my knowledge, failure to get any service details would indeed break the TOC, so this may be the cause of the TOC breaking, but has anyone any ideas why the service isn't being sent back?

Cheers

ACM
0 Kudos
5 Replies
KenBuja
MVP Esteemed Contributor
Can you show the code where you're setting up the TOC? Which event do you have it placed in....the map's load, layer-add-result, layers-add-results, or somewhere else?
0 Kudos
AdrianMarsden
Honored Contributor
The code is in my init event, but I don't think it is the code as 97% of the time (rough guess ) it works fine

Here's the code anyway


    dojo.connect(dynamicMapServiceLayer, "onLoad", function (results) {
        var toc = new agsjs.dijit.TOC({
            map: map,
            layerInfos: [{
                layer: dynamicMapServiceLayer,
                slider: true,
                style: "inline",
                title: "EDDC Layers",
                isopen: true,
                collapsed: true
            }, {
                layer: background,
                slider: true,
                title: "Basemaps",
                noLegend: true,
                isopen: false,
                collapsed: true
            }, {
                layer: aerials,
                slider: true,
                title: "Aerials",
                isopen: true,
                collapsed: true
            }, {
                layer: altmaps,
                slider: true,
                title: "OS Basemaps",
                isopen: false,
                collapsed: true
            }]
        }, 'tocDiv');
        toc.startup();
    });


Thanks for taking a look

ACM
0 Kudos
KenBuja
MVP Esteemed Contributor
Since you're creating the TOC when the dynamicMapServiceLayer is loaded, I'm guessing you're getting the error when one of the other layers aren't yet available. Have you tried using the map's "layers-add-result" event instead so the TOC is created and started after all layers are available?
0 Kudos
AdrianMarsden
Honored Contributor
Nope - so far I've not focused on the TOC code, thinking it may be a AGS issue.

Thanks for the suggestion - I may play around with moving the code next week, the problem is testing it, as it is so infrequent.
0 Kudos
AdrianMarsden
Honored Contributor
Finished my other tasks early, so made this change now.  I'll see what happens.  Obviously your suggestion is good practice whatever, so I'll leave it there for good.

MAny thanks
0 Kudos