Advertisement
Guest User

fetchkml

a guest
Mar 4th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!--
  2. You are free to copy and use this sample in accordance with the terms of the
  3. Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
  4. -->
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7.   <head>
  8.     <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  9.     <title>Google Earth API Sample</title>
  10.     <script src="http://www.google.com/jsapi?key=ABQIAAAAuPsJpk3MBtDpJ4G8cqBnjRRaGTYH6UMl8mADNa0YKuWNNa8VNxQCzVBXTx2DYyXGsTOxpWhvIG7Djw" type="text/javascript"></script>
  11.     <script type="text/javascript">
  12.       function addSampleButton(caption, clickHandler) {
  13.         var btn = document.createElement('input');
  14.         btn.type = 'button';
  15.         btn.value = caption;
  16.        
  17.         if (btn.attachEvent)
  18.           btn.attachEvent('onclick', clickHandler);
  19.         else
  20.           btn.addEventListener('click', clickHandler, false);
  21.  
  22.         // add the button to the Sample UI
  23.         document.getElementById('sample-ui').appendChild(btn);
  24.       }
  25.      
  26.       function addSampleUIHtml(html) {
  27.         document.getElementById('sample-ui').innerHTML += html;
  28.       }
  29.     </script>
  30.     <script type="text/javascript">
  31.     var ge;
  32.    
  33.     google.load("earth", "1");
  34.     google.load("maps", "2");
  35.    
  36.     function init() {
  37.       google.earth.createInstance('map3d', initCallback, failureCallback);
  38.         addSampleUIHtml(
  39.         '<input id="location" type="text" value="kosice, matuskova 12"/>'
  40.       );
  41.    
  42.       addSampleButton('Fly Here!', buttonClick)
  43.     }
  44.    
  45.     function initCallback(instance) {
  46.       ge = instance;
  47.       ge.getWindow().setVisibility(true);
  48.    
  49.       // add a navigation control
  50.       ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
  51.    
  52.       // add some layers
  53.       ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
  54.       ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
  55.    
  56.       // in this sample we will attempt
  57.       // to fetch a  KML file and show it
  58.    
  59.       function finished(object) {
  60.         if (!object) {
  61.           // wrap alerts in API callbacks and event handlers
  62.           // in a setTimeout to prevent deadlock in some browsers
  63.           setTimeout(function() {
  64.             alert('Bad or null KML.');
  65.           }, 0);
  66.           return;
  67.         }
  68.         ge.getFeatures().appendChild(object);
  69.        // var la = ge.createLookAt('');
  70.        // la.set(48.724944, 21.246872, 25, ge.ALTITUDE_RELATIVE_TO_GROUND,
  71.        //        180, 60, 500);
  72.       //  ge.getView().setAbstractView(la);
  73.       }
  74.    
  75.       // fetch the KML
  76.       var url = 'http://3dmodel.fei.tuke.sk/Dominikanske_namestie_49.kmz';
  77.       google.earth.fetchKml(ge, url, finished);
  78.    
  79.       google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/Dom_umenia.kmz', finished);
  80.  
  81.  google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_40.kmz', finished);
  82.  google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_42.kmz', finished);
  83.  google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_46_50.kmz', finished);
  84.  google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_52_56.kmz', finished);
  85.  google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_58az60.kmz', finished);
  86.  google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_59.kmz', finished);
  87.  google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_62az72.kmz', finished);
  88.  google.earth.fetchKml(ge, 'http://3dmodel.fei.tuke.sk/masiarska_72_74.kmz', finished);
  89.  
  90.      
  91.      
  92.       document.getElementById('installed-plugin-version').innerHTML =
  93.         ge.getPluginVersion().toString();
  94.     }
  95.    
  96.     function failureCallback(errorCode) {
  97.     }
  98.    
  99.     function buttonClick() {
  100.       var geocodeLocation = document.getElementById('location').value;
  101.    
  102.       var geocoder = new google.maps.ClientGeocoder();
  103.       geocoder.getLatLng(geocodeLocation, function(point) {
  104.         if (point) {
  105.           var lookAt = ge.createLookAt('');
  106.           lookAt.set(point.y, point.x, 10, ge.ALTITUDE_RELATIVE_TO_GROUND,
  107.                      0, 90, 100);
  108.           ge.getView().setAbstractView(lookAt);
  109.         }
  110.       });
  111.     }
  112.    
  113.     </script>
  114.   </head>
  115.   <body onload="init()" style="font-family: arial, sans-serif; font-size: 13px; border: 0;">
  116.     <div id="sample-ui"></div>
  117.     <div id="map3d" style="width: 1024px; height: 768px;"></div>
  118.     <br>
  119.     <div>Installed Plugin Version: <span id="installed-plugin-version" style="font-weight: bold;">Loading...</span></div>
  120.   </body>
  121. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement