KML Layer Example

         Until now, we have covered various examples involving markers, polylines, polygons, i.e. creating overlays. We have also seen other examples to remove overlays! We will now move on to some other concepts. Today we will have a look at what KML is and how to create a KML layer!

         Let us first understand what KML is and why is it necessary. KML stands for Keyhole Markup Language which is an XML schema for expressing geographic annotation and visualisation within 2D maps and 3D Earth browsers. The KML file specifies a set of features (place marks, images, polygons, 3D models, textual descriptions, etc.) for display in Google Earth, Maps and Mobile, or any other 3D Earth browser (geobrowser) implementing the KML encoding. Each place always has a latitude and a longitude. Other data can make the view more specific, such as tilt, heading, altitude, which together define a "camera view".

         So what we understand from this is that we can create geographic information in a tag structured file and then place its geographic contents on the base google map which helps us display the required information more effectively and attractively.

         Let us have a look at the following example now. In the example, I have used a KML file which shows the wild life sanctuaries in India. I haven't created that file and have used one which was directly available on the web! The KML file always needs to be hosted on your web server. Discrepancies in the data of the KML file if any, is not my fault. Copy the following code in a text file and save it with .html extension. Click on this file and it will open up in your default internet browser and you will see your KML layered map in action!

         The output of the above code will look as seen in the results section of the above live code. The above code is pretty simple and would be easily understood! If you have any queries or doubts regarding the above code, please leave them as comments. Till then, happy mapping!

Popular posts from this blog

Where does Google get it's live traffic data from?

jQuery Mobile's Next Big Step

Geodesic Polyline