I'm using Google Maps Javascript API v3 to load some KML files onto a map. However, I variously get TIMED_OUT, FETCH_ERROR, and OK returned for certain layers. I've taken the URL for each and put it into maps.google.com where the layers invariably load just fine. Has anyone else had issues with inconsistent layer loading? More to the point, is there anything that can be done so that Google Maps will consistently load the layers when asked?
I've included the code that I use for loading the layer although I'm fairly certain that it is not at fault because the layers do actually load sometimes.
function addMapLayer(url) {
console.log('Attempting to add layer at: ' + url);
var layer = new google.maps.KmlLayer(url, {
preserveViewport: true,
map: maps.BirdMap.map
});
google.maps.event.addListener(layer, 'status_changed', function () {
console.log('KML load: ' + layer.getStatus());
if (layer.getStatus() != 'OK') {
$('#maps-error').text('[' + layer.getStatus() + '] Google Maps could not load the layer. Please try again later.');
$('#maps-error').dialog('open');
} else {
layers.push(layer);
}
});
}