AnsweredAssumed Answered

Hopeless at timing and still using Legacy code

Question asked by amarsden on Nov 26, 2017
Latest reply on Nov 27, 2017 by amarsden

OK - I've a site I wrote years back which did work, but now due to a data centre move I realise it onl;y worked becasue the requests were resolved quickly, on the "new" network my code needs attention for timing.

 

I have this

 

        dojo.connect(dynamicMapServiceLayer, "onLoad", function () {
            var content = "";
            var i = 0
            //return the layer descriptions and © text into arrays - we use this later for the info dialog to generate hyperlinks and © text
            dojo.forEach(dynamicMapServiceLayer.layerInfos, function (layer) {
                //console.debug(dynamicMapServiceLayer.layerInfos[layer.id])
                var requestHandle = esri.request({
                    url: mapserviceCustom + "/" + layer.id + "?f=json",
                    handleAs: "json",
                    load: function (data) {
                        LayerAttach[layer.id] = data.hasAttachments;                       
                        LayerDescriptions[layer.id] = data.description;
                        //LayerCopyright[layer.id] = data.copyrightText;
                        console.debug(dynamicMapServiceLayer)
                        dynamicMapServiceLayer.layerInfos[layer.id].copyrightText = data.copyrightText;
                       
                    },
                }, { useProxy: true });              
            });               
        }); 

 

That runs during the init of my site and gets more info from the REST of the service regarding each layer, I use this to dynamically control the copyright notice on the map, as this varies per layer.  I store this info in the layer description.

 

I've not looked at this for a long time, but I know I need to do something to stop the rest of the code working until all this has run, as a later part of my init code will use the results - but my hack skills are exhausted.  Most of the site is in legacy and most examples I have found are in AMD.  So any help gratefully received.

 

Cheers

 

ACM

Outcomes