GOOGLE地球浏览器分析(五):KML文件基本格式
粟卫民http://www.gisdev.cn/ http://blog.csdn.net/suen/ 日期:<chsdate year="2007" month="7" day="5" islunardate="False" isrocdate="False" w:st="on"><span lang="EN-US">2007-7-5</span></chsdate>
保留所有版权。如需转载,请联系作者,并在醒目位置注明出处
第三节我们介绍了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"></kml>
<placemark><span style=""> </span></placemark>
<name>Simple placemark</name>
<description>Attached to the ground. Intelligently places itself </description>
at the height of the underlying terrain.
<point><span style=""> </span></point>
<coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
它包括以下几个部分:
(1)XML头:<?xml version="1.0" encoding="UTF-8"?>
(2)KML命名空间定义:<kml xmlns="http://earth.google.com/kml/2.1"></kml>
(3)地点标记对象,包括:
名称(name):用于对地点标记进行注记;
描述(description):对地点标记进行描述,“气球(ballon)”中的显示内容;
点(Point):指定地点标记的位置。
1.2 使用HTML描述地点标记
有两种方式来使用HTML描述地点标记,一种是直接在<description></description>,<snippet></snippet>和<balloonstyle></balloonstyle>中的标记中写入标准HTTP超链接地址,如www.google.com,这样Google Earth 4.0及更高版本将利用Auto-Markup技术自动把它显示为超链接。另一种是使用CDATA元素在<description></description>标记中写入自己的HTML标记语言,如下所示:
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"></kml>
<document></document>
<placemark></placemark>
<name>CDATA example</name>
<description></description>
CDATA Tags are useful!
Text is more readable and
easier to write when you can avoid using entity
references.
]]>
<point></point>
<coordinates>102.595626,14.996729</coordinates>
当然,还有一种使用转义字符来表示特殊符号的方式,这就不需要CDATA元素,如下所示:
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"></kml>
<document></document>
<placemark></placemark>
<name>Entity references example</name>
<description></description>
<h1>Entity references are hard to type!</h1>
<p><font color="green">Text is
<i>more readable</i>
and <b>easier to write</b>
when you can avoid using entity references.</font></p>
<point></point>
<coordinates>102.594411,14.998518</coordinates>
1.3叠层
叠层是覆盖在地球表面的图像。一个简单的叠层KML代码如下所示:
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"></kml>
<folder><span style=""> </span></folder>
<name>Ground Overlays</name>
<description>Examples of ground overlays</description>
<groundoverlay><span style=""> </span></groundoverlay>
<name>Large-scale overlay on terrain</name>
<description>Overlay shows <place w:st="on">Mount Etna</place> erupting on July 13th, 2001.</description>
<icon><span style=""> </span></icon>
<href>http://code.google.com/apis/kml/documentation/etna.jpg</href>
<latlonbox><span style=""> </span></latlonbox>
<north>37.91904192681665</north>
<south>37.46543388598137</south>
<east>15.35832653742206</east>
<west>14.60128369746704</west>
<rotation>-0.1556640799496235</rotation>
在<groundoverlay></groundoverlay>中,它包含两个较新的标记:
<icon></icon>:指定图片的URL;
<latlonbox></latlonbox>:指定图片的位置和范围。
Google Earth支持JPEG,BMP, GIF, TIFF, TGA和PNG等格式的图像。
1.4 路线
在KML里面,路线由<linestring></linestring>元素来创建。如下所示:
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"></kml>
<document><span style=""> </span></document>
<name>Paths</name>
<description>Examples of paths. Note that the tessellate tag is by default<span style=""> </span>set to 0. If you want to create tessellated lines, they must be authored<span style=""> </span>(or edited) directly in KML.</description>
<style id="yellowLineGreenPoly"><span style=""> </span></span></p><p class="MsoNormal"><span lang="EN-US"><LineStyle><span style=""> </span></span></p><p class="MsoNormal"><span lang="EN-US"><color>7f00ffff</color><span style=""> </span></span></p><p class="MsoNormal"><span lang="EN-US"><width>4</width><span style=""> </span></span></p><p class="MsoNormal"><span lang="EN-US"></LineStyle><span style=""> </span></span></p><p class="MsoNormal"><span lang="EN-US"><PolyStyle><span style=""> </span></span></p><p class="MsoNormal"><span lang="EN-US"><color>7f00ff00</color><span style=""> </span></span></p><p class="MsoNormal"><span lang="EN-US"></PolyStyle><span style=""> </span></span></p><p class="MsoNormal"><span lang="EN-US"></style>
<placemark></placemark>
<name>Absolute Extruded</name>
<description>Transparent green wall with yellow outlines</description> <styleurl>#yellowLineGreenPoly</styleurl>
<linestring><span style=""> </span></linestring>
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudemode>absolute</altitudemode>
<coordinates></coordinates>
-112.2550785337791,36.07954952145647,2357 -112.2549277039738,36.08117083492122,2357 -112.2552505069063,36.08260761307279,2357 -112.2564540158376,36.08395660588506,2357 -112.2580238976449,36.08511401044813,2357 -112.2595218489022,36.08584355239394,2357 -112.2608216347552,36.08612634548589,2357 -112.262073428656,36.08626019085147,2357 -112.2633204928495,36.08621519860091,2357 -112.2644963846444,36.08627897945274,2357 -112.2656969554589,36.08649599090644,2357
1.5 多边形
多边形由定义,包括<outerboundaryis></outerboundaryis>和<innerboundaryis></innerboundaryis>,如下所示:
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"></kml>
<placemark><span style=""> </span></placemark>
<name>The Pentagon</name>
<extrude>1</extrude>
<altitudemode>relativeToGround</altitudemode>
<outerboundaryis><span style=""> </span></outerboundaryis>
<linearring><span style=""> </span></linearring>
<coordinates><span style=""> </span></coordinates>
-77.05788457660967,38.87253259892824,100 -77.05465973756702,38.87291016281703,100 -77.05315536854791,38.87053267794386,100 -77.05552622493516,38.868757801256,100 -77.05844056290393,38.86996206506943,100 -77.05788457660967,38.87253259892824,100
<innerboundaryis><span style=""></span></innerboundaryis>
<linearring><span style=""> </span></linearring>
<coordinates><span style=""> </span></coordinates>
-77.05668055019126,38.87154239798456,100 -77.05542625960818,38.87167890344077,100 -77.05485125901024,38.87076535397792,100 -77.05577677433152,38.87008686581446,100 -77.05691162017543,38.87054446963351,100 -77.05668055019126,38.87154239798456,100
注:本文大部分内容是由GOOGLE KML文档KML Samples翻译而来,如果GOOGLE公司觉得有什么不妥,请联系我修改或删除。
<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog.html" frameborder="0" width="728" scrolling="no" height="90"></iframe>
相关推荐
Google地球数据KML文件,全国铁路、国道文件。
资源难找,5分出售
全国铁路和国道谷歌地球KML文件,很全面很精确
Google Earth KML文件生成工具可以协助我们将cad数据直接匹配到google earth
KML 2.0介绍 KML全称是Keyhole Markup Language KML,是一个基于XML语法和文件格式的文件,用来描述和保存地理信息如点、线、图片、折线并在Google Earth客户端之中显示
Arcgis全国水系图文件,可直接使用,算是比较全的图了。
G5量值图层是一款制作谷歌地球是必不可少的KML文件,通过该软件进行栅格、扇形图层在Google Earth中直观显示量值,支持帮助用客户对小区流量、基站流量、各类指标类量值业务等进行区域多点快速联动分析,本站提供的...
可导入谷歌地球图层展示,全球夜晚灯光亮点。
谷歌地球图层制作软件。
适用于GoogleEarth的KML标记语言语法规则,了解它后,可以自己方便的编写KML呈现程序,使用自己定制化的显示界面直观显示对比分析数据。 适用于卫星导航、定位、位置服务等领域
KML文件格式详细介绍,学习googleearth的好东西
中国各省边界kml文件
全国高铁谷歌地球kml文件
川藏线路线图kml可以直接导入谷歌地球 非常详细 可以直接使用 川藏线的每个重要的地点都有涉及 告诉你川藏线怎么玩
KML 2.0介绍 KML全称是Keyhole Markup Language KML,是一个基于XML语法和文件格式的文件,用来描述和保存地理信息如点、线、图片、折线并在Google Earth客户端之中显示
KML文件转换工具,适合在谷歌地球上面做布点的工具,非常方便
数据资源收集与github开源网站,经过去重加工后,形成kml文件。该文件格式为kml,下载后需要配合桌面地图工具加载,然后显示。
在日常优化中大家肯定会使用GE(Google Earth),那么GE可以识别的文件KML及KMZ大家肯定也不会陌生,大家肯定也有各种工具可以将具有经纬度点坐标转换成KML,但是对于已经生成的KML文件,相信大家基本都不会反向转换...
Google Earth KML文件生成器,根据经纬度或网格坐标生成Google Earth KML文件,可自选点格式、线格式,面格式,地标图形,线框颜色等