I have to create a Polygon on Google Earth which is embedded in my website as it is made in the Google Earth application. I managed to create a polygon already but i can only create it with the javascript file but i need it to function like in the application.

Can anybody help me?

I searched a few hours for a solution but i couldnt figure out how to do this.

2 Answers 2


I have had some success with bringing KML layers from ArcGIS into Google Earth. It is not very well documented, especially since Google Earth is depreciated, but you can still do it. You must have access to a server that can host the KML layers, and it must be shared to a public level so your API will be able to access it. Below is the code for embedding a KML into Google Earth API.

google.load("earth", "1", {"other_params":"sensor=true_or_false"});

function init() {
    google.earth.createInstance('map3d', initCB);

function initCB(instance) {
    ge = instance;
    ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
    ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
    ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS_LOW_RESOLUTION, true);
    ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, true);
    ge.getLayerRoot().enableLayerById(ge.LAYER_TREES, true);

    var lookAt = ge.createLookAt('');

     addKmlFromUrl('http:// insert KML 00 URL here');  /* KML 00 */
     addKmlFromUrl('http:// insert KML 01 URL here');  /* KML 01 */
     addKmlFromUrl('http:// insert KML 02 URL here');  /* KML 02 */ 
     addKmlFromUrl('http:// insert KML 03 URL here');  /* KML 03 */
     addKmlFromUrl('http:// insert KML 04 URL here');  /* KML 04 */
     addKmlFromUrl('http:// insert KML 05 URL here');  /* KML 05 */ 
     addKmlFromUrl('http:// insert KML 06 URL here');  /* KML 06 */
     addKmlFromUrl('http:// insert KML 07 URL here');  /* KML 07 */

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

    var networkLink = ge.createNetworkLink('');



This should allow you to bring the KML layers into the Google Earth API just fine. The tool I used in ArcGIS for Desktop was "Layer to KML". I saved this to my computer. Since my layers had 3D properties I opened it up in Google Earth and edited the properties to display how I wanted them to, then I uploaded them to the ArcGIS Online Server and called them into Google Earth API within the JavaScript code as shown above.


Google Maps Api v3 supports rendering a vector KML that is stored on either a remote server or on the same server... Just use QGIS to create/convert any vector format to KML. Your question wasn't specific to the need maybe you can expand if this isn't helpful or obvious

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.