oma Google Earth API Samples - Show/Hide Photorealistic Buildings

Google Earth API Samples - Show/Hide Photorealistic Buildings

Last Modified:
06/08/2009
Installed Plugin Version:
...



Relevant Resources:

Relevant Code Excerpt:

function showBuildings() {
  ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, true);

  // NOTE: you can use LAYER_BUILDINGS_LOW_RESOLUTION for gray buildings
  
  setTimeout(function() {
               var la = ge.createLookAt('');         
               la.set(37.79333, -122.40, 0, ge.ALTITUDE_RELATIVE_TO_GROUND, 
                      180, 50, 1000);
               ge.getView().setAbstractView(la);
             }, 10000);
}

function hideBuildings() {
  ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, false);
}

function alertBuildingsVisible() {
  alert(getInheritedVisibility(
    ge.getLayerRoot().getLayerById(ge.LAYER_BUILDINGS)) ?
      'Buildings are visible' : 'Buildings are NOT visible');
}

function getInheritedVisibility(layer) {
  if (layer.getVisibility() == false) {
    return false;
  } else {
    var parent = layer.getParentNode();
    if (!parent)
      return true;
    
    return getInheritedVisibility(parent);
  }
}