GE - Open KML File on Google Earth


GE - Open KML File on Google Earth

Viewing data from Google Earth - Google Maps

In the previous articles I explained about What is KML (Keyhole Markup Language)?, Google Fusion Table - An Introduction, How to open KML file on Google Maps API, Google Fusion Tables Layer | An Overview, What is GE? and How to use Google Earth?.

In this article I will explain how to display a KML file on Google Earth, Viewing Google Earth files, how to open a KML, Opening a KML File in Google Maps in web application. 

Google Maps can read KML or KMZ, the file formats Google Earth uses for the exchange of geographic information. This means that you can view data you create and share with Google Earth on Google Maps. You can use this feature to plot multiple points of interest, draw lines, and mark regions on Maps.Find the source code below:

Displaying a KML file on Google Earth

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head id="Head1" runat="server">
    <title>Displaying a KML file on Google Earth</title>
    <script src="" type="text/javascript"></script>
    <script type="text/javascript">
        var ge;

        google.load("earth", "1");

        function init() {
  'map3d', initCallback, failureCallback);

        function initCallback(instance) {
            ge = instance;

            // add a navigation control

            // add some layers
            ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
            ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);

            // in this sample we will attempt
            // to fetch a  KML file and show it

            function 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);

                var la = ge.createLookAt('');
                la.set(19.068482, 72.833884, 15, ge.ALTITUDE_RELATIVE_TO_GROUND, 180, 60, 500);

            // fetch the KML
            var url = 'your_kml_name.kml';
  , url, finished);

            document.getElementById('installed-plugin-version').innerHTML = ge.getPluginVersion().toString();

        function failureCallback(errorCode) {
<body onload="init()" style="font-family: arial, sans-serif; font-size: 13px; border: 0;">
    <form id="form1" runat="server">
    <h3>Displaying a KML file on Google Earth</h3>
        Installed Plugin Version: <span id="installed-plugin-version" style="font-weight: bold;">
    <br />
    <div id="map3d" style="width: auto; height: 500px;">

Note: The KML file should be on public IP.
Please leave your comments, suggestions and queries about this post in the comment sections in order for me to improve my writing skills and to showcase more useful posts. Thanks for reading!

GE - Open KML File on Google Earth Reviewed by Ravi Kumar on 4:47 PM Rating: 5

No comments:

All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form


Email *

Message *

Powered by Blogger.