Google AJAX API loaderでGoogle earth APIをロードすると、ロード完了時に、google.setOnLoadCallbackで設定した関数が呼ばれます。
ところが、この時点ではまだGoogle earth API全体はロードが完了しておらず、例えばgoogle.earth.fetchKmlの内部で使われている関数がundefinedで失敗します。
KMLが正常に読み込まれるまで繰り返すことで対応しました。以下、コード例です。
google.setOnLoadCallback(function() { ... fetchKml = function() { try { google.earth.fetchKml(ge, 'http://www.example.com/example.kml', kmlFinishedLoading); } catch(error) { console.log('fetchKml error'); setTimeout(fetchKml, 100); } setTimeout(fetchKml, 100); });