domenica 9 novembre 2014

8. preparazione del file che usa la API di google earth

Copiare e incollare questo file in un file di test con estensione html  e sostituire il link in rosso con quello del file copiato al punto 7:

<html>
  <head>
    <script src="https://www.google.com/jsapi?key=YOURAPIKEY"></script>
    <script>
      google.load('earth','1', {'other_params':'sensor=false'});

      var ge = null;

      function init() {
        google.earth.createInstance('map3d', initCallback, failureCallback);
      }

      function initCallback(pluginInstance) {
        ge = pluginInstance;
        ge.getWindow().setVisibility(true);
 // Earth is ready, we can add features to it
  addKmlFromUrl('http://digilander.libero.it/pincopallino/pluto/Mura%20Venete%20di%20Crema.kml');
      }

function addKmlFromUrl(kmlUrl) {
  var link = ge.createLink('');
  link.setHref(kmlUrl);

  var networkLink = ge.createNetworkLink('');
  networkLink.setLink(link);
  networkLink.setFlyToView(true);

  ge.getFeatures().appendChild(networkLink);
}

      function failureCallback() {
        // we can do something here if there's an error
      }
    </script>

  </head>
  <body onload="init()" id="body">
    <div id="map3d" style="width: 500px; height: 500px;"></div>
  </body>
</html>

Nessun commento:

Posta un commento