Google Earth API Samples - Entering a Photo Overlay

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

Relevant Resources:

Relevant Code Excerpt:

<!-- We'll need to walk the DOM looking for a KmlPhotoOverlay later -->
<script src="http://earth-api-samples.googlecode.com/svn/trunk/lib/kmldomwalk.js" type="text/javascript"></script>
var photoOverlay = null;
// create the photo overlay by fetching it out of a KML file
var href = window.location.href.substring(0, window.location.href.lastIndexOf('/')) + '/';
href += 'static/spaceneedle_photooverlay.kml';

google.earth.fetchKml(ge, href, function(kmlObject) {
  if (!kmlObject) {
    // wrap alerts in API callbacks and event handlers
    // in a setTimeout to prevent deadlock in some browsers
    setTimeout(function() {
      alert('Bad or null KML.');
    }, 0);
    return;
  }

  // Show the entire KML file in the plugin.
  ge.getFeatures().appendChild(kmlObject);

  // Walk the DOM looking for a KmlPhotoOverlay
  walkKmlDom(kmlObject, function() {
    if (this.getType() == 'KmlPhotoOverlay') {
      photoOverlay = this;
      return false; // stop the DOM walk here.
    }
  });
});
function enterPhotoOverlay() {
  if (!photoOverlay) {
    alert('No photo overlay found!');
    return;
  }

  ge.getPhotoOverlayViewer().setPhotoOverlay(photoOverlay);
}

function exitPhotoOverlay() {
  // just like setBalloon(null)
  ge.getPhotoOverlayViewer().setPhotoOverlay(null);
}