title: List of links that "Look at" a KML placemark
body: <p>I am trying to add a column next to GE that has a list of all the Placemarks, as links or buttons, and when you click on those links it will exit the tour and jump to (or flyto) that placemark's location and pop-up the balloon.</p>
  
  <p>the KML has a list of FlyTo's and LookAt's inside of a tour as well as Placemarks inside a document :).</p>
  
  <p>Here is an Example of my KML placemark:</p>
  
  <pre><code>&lt;Placemark id="Mussorie"&gt;
   &lt;name&gt;Karen Snyder&lt;/name&gt;
    &lt;description&gt;
    Karen Snyder is an Arts Specialist learning language and culture through the arts in     Mussorie, India
      &lt;/description&gt;
      &lt;styleUrl&gt;#Icon&lt;/styleUrl&gt;
      &lt;Point&gt;
       &lt;coordinates&gt;79.134521,30.040566,0&lt;/coordinates&gt;
      &lt;/Point&gt;
     &lt;/Placemark&gt;
  </code></pre>
  
  <p>Here is my JavaScript and HTML:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
        &lt;title&gt;Shepherd Global Outreach Partners&lt;/title&gt;
        &lt;script src="https://www.google.com/jsapi"&gt; &lt;/script&gt;
        &lt;script src="http://earth-api-samples.googlecode.com/svn/trunk/lib/kmldomwalk.js" type="text/javascript"&gt; &lt;/script&gt;
        &lt;script type="text/javascript"&gt;
          var ge;
          var tour;
          var curr_pm;
          var obj_pm;
          var linksit='';
          var linksitcount=1;
          var links = [];
          google.load("earth", "1");
  
          function init() {
            var urlquery = location.href.split("?");
            if(urlquery[1]) {
              var urlterms = urlquery[1].split(",");
              curr_pm = urlterms[0];
            }
  
            google.earth.createInstance('map3d', initCB, failureCB);
          }
  
          function initCB(instance) {
            ge = instance;
            ge.getWindow().setVisibility(true);
            ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
  
            var href = 'http://www.shepnet.org/GO.kml?ID='+Math.floor((Math.random()*100000)+1) ;
            google.earth.fetchKml(ge, href, fetchCallback);
  
            function fetchCallback(fetchedKml) {
               // Alert if no KML was found at the specified URL.
               if (!fetchedKml) {
                  setTimeout(function() {
                      alert('Bad or null KML');
                   }, 0);
                   return;
               }
  
               // Add the fetched KML into this Earth instance.
               ge.getFeatures().appendChild(fetchedKml);
  
               // Walk through the KML to find the tour object; assign to variable 'tour.'
               walkKmlDom(fetchedKml, function() {
                  if (this.getType() == 'KmlTour') {
                     tour = this;
                     return false;
                   }
               });
  
              if (tour) {
                ge.getTourPlayer().setTour(tour);
                ge.getTourPlayer().play();
                ge.getTourPlayer().setLoop(true) 
              }
  
              if (!fetchedKml) {
                // 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.
              currentKmlObject = fetchedKml;
              ge.getFeatures().appendChild(currentKmlObject);
  
              //Walk the DOM looking for a KmlLineString - the Race Path
              var links = [];
              walkKmlDom(fetchedKml, function() {
              if (this.getType() == 'KmlPlacemark') {
                // create a link to the placemark
                links.push('&lt;a href="javascript:void(0);" onclick="flyto(\'' + this.getUrl() + '\')"&gt; ' + this.getName() + ' &lt;/a&gt;&lt;br&gt;');
              }});
  
              for (index = 0; index &lt; links.length; ++index) {
                console.log(links[index]);
              }
  
            }
          }
  
          var flyto = function(url) {
            // close any currently open balloon.
            ge.setBalloon(null); 
  
            // find the placemark from the url parameter
            var placemark = ge.getElementByUrl(url);
            if(placemark == null) {
              console.log("Placemark is null: " + url);
              return;
            }
  
            // create a lookat based on that feature's geometry 
            var lookAt = ge.createLookAt('');
            lookAt.setLatitude(placemark.getGeometry().getLatitude());
            lookAt.setLongitude(placemark.getGeometry().getLatitude())
  
            // Update the view in Google Earth using the lookat
            ge.getView().setAbstractView(lookAt);
  
            // open the feature's balloon
            ge.setBalloon(placemark.getBalloon());
          }
  
          function failureCB(errorCode) {
          }
  
          function UCLA() {
            ge.getTourPlayer().reset();
            var camera = ge.getView().copyAsCamera(ge.ALTITUDE_RELATIVE_TO_GROUND);
            camera.setLatitude(34.0688272174651);
            camera.setLongitude(-118.445067424559);
            camera.setAltitude(10000);
            ge.getView().setAbstractView(camera);   
          }
  
          function pauseTour() {
            window.open(href = 'http://www.shepnet.org/GO.kml#UCLA');  
          }
  
          function resetTour() {
            ge.getTourPlayer().reset();
          }
          function exitTour() {
            ge.getTourPlayer().setTour(null);
          }
  
          google.setOnLoadCallback(init);
  
        &lt;/script&gt;
      &lt;/head&gt;
        &lt;body&gt;
        &lt;div id="map3d" style="height: 768px; width: 1280px;"&gt;&lt;/div&gt;
        &lt;div id ="controls"&gt;
          &lt;input type="button" onClick="flyto('http://www.shepnet.org/GO.kml#UCLA')" value="UCLA"/&gt;
          &lt;input type="button" onClick="resetTour()" value="Stop/Reset Tour"/&gt;
          &lt;input type="button" onClick="exitTour()" value="Exit Tour"/&gt;
          &lt;a href="javascript:void(0);" onClick="flyto('http://www.shepnet.org/GO.kml#Mussorie')"&gt; 'Mussorie' &lt;/a&gt;
        &lt;/div&gt;
        &lt;/body&gt;
    &lt;/html&gt;
  </code></pre>