WL

感受CODE中一点一滴的快乐
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Google Earth的KML语法

Posted on 2006-08-01 08:23  WL  阅读(3581)  评论(0编辑  收藏  举报

KMLGoogle Earth的地标文件格式,全称是Keyhole Markup Language KML,基于XML语法结构,用来描述GE地标信息如点、线、图片、折线、颜色、图标、视角等。以下系本人在实际开发应用过程中经常用到的一些语法说明,主要围绕NetworkLink对象展开。
非常感谢Step1.cn的K_Reverter对我的无私指点,他的网站上有比较完整的中文说明!
有些内容我是从KML的官方说明中提取的,并没有翻译过来。
目前的语法解释针对的是KML2.0,GE4出来后,KML也增加了新的内容,升级为2.1版,具体内容以后会贴出来!
 

<NetworkLink>

复合标签,用来定义一个引用的本地或远程的KML文件。我主要用它来读取远程数据库中的地标信息。

<NetworkLink>

  <name>NE US Radar</name>

  <flyToView>1</flyToView>

  <Url>

    <href>http://www.example.com/NetworkLink.aspx</href>

    <refreshMode>onInterval</refreshMode>

    <refreshInterval>30</refreshInterval>

    <viewRefreshMode>onStop</viewRefreshMode>

    <viewRefreshTime>7</viewRefreshTime>

<ViewFormat>

BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth],

[lookatLon],[lookatLat],[lookatRange],[lookatTilt],[lookatHeading]

</viewFormat>

  </Url>

<refreshVisibility>1</refreshVisibility>

</NetworkLink>

以上内容是一个NetworkLink对象的完整代码,其中的关键字可参考下面的语法解释!
 

<RefreshMode>

Sets the type of refresh that is done to a network link or ground overlay, either refreshing upon a designated interval or only once upon loading in Google Earth (default).

<refreshMode>onInterval</refreshMode>

 

Values

Use onInterval to indicate a time-based refresh of the KML or the ground overlay. Use once or leave the tag out to indicate refresh only upon loading of the network link or overlay into Google Earth.

 

<RefreshVisibility>

单一标签,是<NetworkLink>的子元素.指定网络KML文件被重新加载刷新的时候是否忽略KML文档之中各标注的默认可见性。

:

默认值是0,即忽略KML文档中的默认可见性设置而使所有标注的可见性不变。更改为1既可以在每次网络KML文件被刷新之后重新根据KML文件内容设置标注的可见性。 例如,假设有一项在KML文件之中可见性设置为0,而且refreshVisibility设置为1,当文件第一次加载到Google Earth之中的时候,该项是不显示的如果用户通过点击该项的复选框而已经使该项显示出来,这种情况下该网络KML文件被刷新之后,该项又会重新变成不显示。

 

<RefreshInterval>

单一标签。用来指定刷新一个网络KML文件或图片标注的时间秒数。

<refreshInterval>121</refreshInterval>

:

以秒为单位。如果该值大于0,则该项每n秒刷新一次,如果该值小于0,则该项根本不会被加载,如果该值等于0,则该项会被加载一次而不会再被刷新。

 

<ViewRefreshMode>

单一标签,是<NetworkLink>的子元素,指定在什么情况下向<href>网络服务器发送当前视角坐标。

:

onStop 代表视图窗口停顿n秒后, n<viewRefreshTime>标签之中指定。

never - Default mode. If <viewRefreshMode> is undefined, data is not refreshed when the camera view changes in Google Earth.

onStop - Returns the coordinates n seconds after movement in the viewing window has stopped, where n is defined in <viewRefreshTime>

onRequest - turns the coordinates only when the user chooses to refresh the overlay or network link

<viewRefreshTime>

单一标签,是<NetworkLink>的子元素,指定向网络服务器发送当前视角坐标的频率。

:  

一个代表秒的整数。

 

<ViewFormat>

This element selects what information Google Earth sends to the server in a query and allows you to specify how Google Earth formats the query.

<ViewFormat> is a child of the Network Link's <Url> element that allows more complete control over the view information returned to the server. Without specifying this tag, the information returned is the WMS-style east, south, west, north bounding-box coordinates, but you can now return any of these parameters in whichever order you like, and also a number of parameters in the <LookAt> element. The following example returns all possible information in a comma-delimited string:

<ViewFormat>

BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth],[lookatLon],[lookatLat],[lookatRange],[lookatTilt],[lookatHeading]

</viewFormat>

 

Values
A user defined variable. Available parameters are as follows:

·         [bboxWest]

·         [bboxSouth]

·         [bboxEast]

·         [bboxNorth]

·         [lookatLon]

·         [lookatLat]

·         [lookatRange]

·         [lookatTilt]

·         [lookatHeading] 

 

<Range>

单一标签,是<LookAt>的子元素.描述当前视点的海拔,以米为单位。

<range>909.907</range>

值:

由视点的位置决定。

 

<Heading>

单一标签
<LookAt>的子元素,当前视角在水平面上的投影和正北的夹角,下面的例子表现了一个向西的视角。

<heading>-90<heading>

:

由观测者(视点)方向决定,以度为单位。

 

<Latitude>

单一标签,是<LookAt>的子元素。 指定从-9090的纬度值。

<latitude>33.3205<latitude>

:

由视点坐标决定,单位是度。

 

<Longitude>

单一标签,是<LookAt>的子元素. 指定从-180180的经度值.

<longitude>-111.965<longitude>

:

由视点坐标决定,单位是度.

 

<LookAt>

复合标签。为标注或目录定义观测者坐标(视点)

<LookAt>

<heading>-0.00895499<heading>

<tilt>39.4365<tilt>

<range>214.17<range>

<latitude>37.3895<latitude>

<longitude>-122.086<longitude>

<LookAt>

 

<Tilt>

单一标签,<LookAt>的子标签. 代表视点到指定点的角度(视角),值为0代表没有倾斜,即在Google earth中的视角是垂直向下的.值为90代表最大倾斜度,即在Google earth中视角是水平的。

<tilt>0.000000<tilt>

:

代表视角倾斜度的数值,单位可以是十进制的度数,也可以是其他标准GIS数值。

 

<viewBoundScale>

 

Used for overlays—in either network links or placemark overlays—to indicate the percentage of  screen space to fill with data. If you are creating a ground overlay to deliver dynamic data via a network link, you can set the view-bound scale to 1.0 so that the dynamic date entirely fills the screen.  This would be a typical setting to use when the user will not need to adjust the size of the overlay.

Values

View bound scale is set to 1.0 as default for network links and 0.75 for overlays if not specified. Otherwise, you can set the value to a fractional portion of the screen size, including values greater than 1.0.  

Keep in mind that when using this tag for ground overlays where the user might want to modify the position, you should keep the value to a smaller fraction of the screen size to provide for easier editing.  Otherwise, set the bound to reflect the area of data relative to the viewing boundaries of the client screen that you want to display.