Latest

random

Display KML on Google Maps


Kml File Example

KML is a file format used to display geographic data in an Earth browser such as Google Earth, Google Maps, and Google Maps for android. 
If you have a Kml file content and you need to view kml file in Google Map. This Google Map API v3 example demonstrates how to plot KML file in google map. Find the javascript code snippet below :-
// Function to plot a kml on google map
function OpenWimaxCovarageplot() {
            if (map) {               
                WimaxLayer = null;
                WimaxLayer = new google.maps.KmlLayer('http://11.111.11.111/Virtual_Directory/test.kml'); 

                if (WimaxLayer) {
                    WimaxLayer.setMap(map);
                }
            }
        }
view kml file in google maps,how to open kml files in google earth,view kml in google maps,google earth kmz,view kmz files,kml or kmz
view kmz file in google maps
// Function to remove opened kml from Google Map
 function RemoveWimaxCovarageplot() {
            if (WimaxLayer) {
                WimaxLayer.setMap(null);
                WimaxLayer = null;
            }
        }

Note: Your .KML file should be located on public IP

4 comments:

  1. Nice article Ravi. Could you please give some description of KML file to make this article more descriptive.

    ReplyDelete
  2. yeah sure! KML is a file format(extension) used to display geographic data on google maps and google earth.

    KML uses a tag-based structure with nested elements and attributes and is based on the XML standard.

    For example download the kml file from the below url and open it in notepad or google earth.

    https://developers.google.com/kml/documentation/KML_Samples.kml

    I hope you will find this information helpful for more please visit https://developers.google.com/kml/documentation/kml_tut

    ReplyDelete
    Replies
    1. Hi Ravi,

      Could you please help me to load .kml file on google map through virtual directory of Development server, i created an virtual directory from where i can download the file if i put URL on IE, but when i putting same url into google.map.KmlLayer('my virtual directory') the map is not displayed. Could you please guide me. Where i get stuck.

      Awaiting for your quick response

      Delete
    2. Hello Pankaj,

      you should upload your kml file on public IP/URL otherwise it will not display on google map.

      Delete

All Rights Reserved by Etechpulse © 2015 - 2016
Powered By Blogger

Contact Form

Name

Email *

Message *

Powered by Blogger.