how to setup google earth tour auto run after applying KML in google earth

437 views Asked by At

I have generated a kml for google earth tour,

Every time i need to click "start tour" to run the tour.

I would expect after loading the kml file the tour should be run without user intervention and it should be repeated automatically.

Could any one help? Any one Please

Thanks & Regards, Pica

1

There are 1 answers

0
Santhakumar On

Here i enclosed one simple tour application. It start automatically without any human intervention. If you want know more about google earth api tour ,see this link. https://developers.google.com/earth/documentation/touring

<html>
   <head>
      <title>Sample tour in the Google Earth Plugin</title>
      <script src="https://www.google.com/jsapi"> </script> 
      <script src="http://earth-api-samples.googlecode.com/svn/trunk/lib/kmldomwalk.js" type="text/javascript"> </script>
      <script type="text/javascript">

         var ge;
         var tour;
         google.load("earth", "1");

         function init() {
            google.earth.createInstance('map3d', initCB, failureCB);
         }

         function initCB(instance) {
            ge = instance;
            ge.getWindow().setVisibility(true);
            ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);

            var href = 'http://developers.google.com/kml/documentation/kmlfiles/complete_tour_example.kml';
            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;
        ge.getTourPlayer().setTour(tour);

         ge.getTourPlayer().play();
          return false;
                  }
               });
            }
         }

         function failureCB(errorCode) {
         }

         google.setOnLoadCallback(init);

      </script>
   </head>
   <body>

      <div id="map3d" style="height: 400px; width: 600px;"></div>


   </body>
</html>