Search code examples
google-mapsiframegoogle-earthgoogle-earth-plugin

How to set the "Google Earth Plugin" view as default in a Google Maps iframe?


I am using this Example and I want to set Google EARTH as default view.


Solution

  • Use setMapType to set the desired mapType:

     map.setMapType(G_SATELLITE_3D_MAP);
    

    <edit>:

    The linked example uses the Maps-API V2, for V3 it's little bit different. Wait for the idle-event of the map and set the mapType to 'GoogleEarthAPI' .

    Go to line 116 of your document and modify it:

    if (isGEinstalled)
    {
    googleEarth = new GoogleEarth(map);
    //add the following line
    google.maps.event.addListenerOnce(map,'idle',function(){map.setMapTypeId('GoogleEarthAPI')});
    }
    else
    {
      alert("O plugin de Google Earth não está instalado");
    }