Kazu46Machi / earth-api-samples

Automatically exported from code.google.com/p/earth-api-samples
0 stars 0 forks source link

Local KML file can not be loaded through both fetchKml or KmlNetworkLink #174

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What should this feature enhancement do?

Error happened when a local KML file (e.g. c:\pentagon.kml) is fetched by 
using fetchKml and nothing appeared by using KmlNetworkLink.

Are there any known workarounds that produce the similar results?

1. Save the attached kml file to "C:\pentagon.kml":

2. In the web page, add the two javascript functions

    // Fetch kml from a file or url. Called by Web Browser.
    function fetchkml()
    {
      url = 'c:/pentagon.kml';
      google.earth.fetchKml(ge, url, fetchkml_finished);
    }

    // Callback function after a KML or KMZ file is fetched.
    function fetchkml_finished(object)
    {
      if (!object)
      {
        // 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;
      }

      // call external to inform the file is loaded.
      ge.getFeatures().appendChild(object);

      // Fly to the Pentagon
     var lookAt = ge.createLookAt('');
     lookAt.set(38.867, -77.0565, 500, ge.ALTITUDE_RELATIVE_TO_GROUND, 0,  
45, 900);
     ge.getView().setAbstractView(lookAt);    
   }

3. run fetchkml function. Error happens on the line: google.earth.fetchKml
(ge, url, fetchkml_finished);

Original issue reported on code.google.com by qlu...@yahoo.com on 2 Mar 2009 at 3:27

Attachments:

GoogleCodeExporter commented 8 years ago
This is expected behavior. The Google Earth Plugin cannot access local files for
security reasons.

Original comment by api.roman.public@gmail.com on 27 Mar 2009 at 10:42