Search code examples
google-earth-plugin

How to launch Google Earth plugin within Chrome


I have the Google Earth plugin installed and it seems to work fine.

What I would like to do is open a KML file (exported from MyTracks on Android) in it.

But, I can find no option to open the KML file, or launch the GE plugin.

Is this possible ?


Solution

  • To launch the plugin take a look at the 'Using the Google Earth Api' section in the developer's guide.

    For loading KML files, take a look at the following documentation https://developers.google.com/earth/documentation/kml

    It give examples of how to fetchKml and parseKml as well as linking to a working example.

    var href = 'http://code.google.com/'
                   + 'apis/earth/documentation/samples/kml_example.kml';
    
    google.earth.fetchKml(ge, href, function(kmlObject) {
      if (kmlObject) {
        ge.getFeatures().appendChild(kmlObject);
      }
    });
    

    You can also use a KmlNetworkLink to load the data again the document links to a working example of this.

    var link = ge.createLink('');
    var href = 'http://code.google.com/'
               + 'apis/earth/documentation/samples/kml_example.kml'
    link.setHref(href);
    
    var networkLink = ge.createNetworkLink('');
    networkLink.set(link, true, true); // Sets the link, refreshVisibility, and flyToView
    
    ge.getFeatures().appendChild(networkLink);