Hey Everyone,<br><br>I'm not sure if this is the best place to post this, so please let me know if there is a better place to send it. Anyways, we were able to cut our page load time in half for our geomoose instance, and I thought I'd post it on the mailing list in case it might help someone else out. Using firebug, we were able to determine that Geomoose's itereateThroughLayers function was taking a significant amount of time, so we looked for a way to improve it. We ended up coming up with a solution that is slightly more memory intensive, but cut the time spent on the function in half. To implement the change, just replace the old iterateThroughLayers function with the following code (in compiled.js):<br>
<br> var theLayer = new Array();<br> var pathsP = new Array();<br> function iterateThroughLayers(pathString, fn) {<br> if(pathsP[pathString] == null){<br> var services = MyCatalog.getElementsByTagName('map-source');<br>
var paths = new String(pathString).split(':');<br> for(var i = 0; i < services.length; i++) {<br> var root = services[i].getAttribute('name');<br> var layers = services[i].getElementsByTagName('layer');<br>
for(var l = 0; l < layers.length; l++) {<br> var layerName = layers[l].getAttribute('name')<br> for(var p = 0; p < paths.length; p++) {<br> if(root+'/'+layerName == paths[p]) {<br>
var mapLayer = Map.getLayersByName(root)[0];<br> theLayer[pathString] = mapLayer;<br> pathsP[pathString] = paths[p];<br> if(mapLayer) {<br>
fn(mapLayer, paths[p]);<br> }<br> }<br> }<br><br> }<br> }<br> }<br> else{<br> if(theLayer[pathString]){<br>
fn(theLayer[pathString], pathsP[pathString]);<br> }<br> }<br> <br> }<br><br>This works because the function is hit twice with the same pathString (just a different function), and unnecessarily has to run through the same series of identical loops twice. Instead, the information genorated from the first run through is stored in the two arrays theLayer and pathsP and recalled. <br>
<br>This may not significantly improve speeds if you are not using many layers, but if you are, you should see some gains. I hope this helps some people out!<br><br>-Jeff<br>