google.load("earth", "1");

var ge = null;
var la = null;

function init() {
  google.earth.createInstance("map3d", initCallback, failureCallback);
}

function initCallback(object) {
 ge = object;
 ge.getWindow().setVisibility(true);
ge.getOptions().setFlyToSpeed(0.6);
var buildingsLayer = ge.getLayerRoot().getLayerById(ge.LAYER_BUILDINGS);
var inheritedVisibility = getInheritedVisibility(buildingsLayer);
ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, !inheritedVisibility);
loadkmz();
goStart();
ge.getOptions().setFlyToSpeed(0.2);

 
}
function loadkmz() {
		path='http://www.earthexposure.com/clients/oom/';
		file='files/oomorakelboom.kmz';
  	google.earth.fetchKml(ge,path+file,finished);  
}
function finished(object) {
  if (!object) {
	alert('bad or NULL kml');
	return;
  }
  ge.getFeatures().appendChild(object);
	 
}
function getInheritedVisibility(layer) {
  if (layer.getVisibility() == false) {return false;}else{
    var parent = layer.getParentNode();
    if (!parent) {return true;}
    return getInheritedVisibility(parent);
  }
}
function failureCallback(object) {
}
function changeLookAt(lat,lng, alt, heading,tilt,range){
	la = ge.createLookAt('');
	la.set(lat,lng,alt,ge.ALTITUDE_RELATIVE_TO_GROUND,heading,tilt,range); 
	ge.getView().setAbstractView(la); 
}


function goStart(){
changeLookAt(52.289881, 6.191053 ,68 , -54 , 81,  400);
ge.getView().setAbstractView(la);
 }



