GOOGLE地球浏览器分析(五):KML文件基本格式
粟卫民http://www.gisdev.cn/ http://blog.youkuaiyun.com/suen/ 日期: 2007-7-5
保留所有版权。如需转载,请联系作者,并在醒目位置注明出处
第三节我们介绍了KML文件的定义及其在GOOGLE地图浏览器中的地位,并给出了一个简单的样例文件。下面我们详细介绍KML文件的格式。
1 基本格式
基本格式的KML文件是指可以直接由Google Earth创建的KML文件,它包括地点标记、叠层、路线和多边形。下面分别介绍。
1.1 地点标记(Placemarks)
上一节我们给出了一个地点标记(Placemarks)的示例。地点标记是Google Earth中最常用的地理特征,它使用一个黄色的图钉在地球表面标记一个位置。一个简单的地点标记的KML代码如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Placemark>
<name>Simple placemark</name>
<description>Attached to the ground. Intelligently places itself
at the height of the underlying terrain.
</description>
<Point>
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
</Point>
</Placemark>
</kml>
它包括以下几个部分:
(1)XML头:<?xml version="1.0" encoding="UTF-8"?>
(2)KML命名空间定义:<kml xmlns="http://earth.google.com/kml/2.1">
(3&