在KML中引用地标 [英] Referring to a Placemark in KML

查看:108
本文介绍了在KML中引用地标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种引用地标的方法(可能通过使用地标ID"属性)?

Is there a way to refer to a placemark (probably by using the Placemark ID attribute) ?

用例:

假设您有一个城市的公交车站列表.一些公交车站将停靠一些公交站点.如果可以引用地标,则可能会有所有停靠点的主列表,并且每行(在单独的文件夹中设置)都可以引用上述地标之一.选择多个文件夹会显示这些行的其他地标,但是已经显示的地标不会显示多次.

Suppose you have a list of bus stops in a city. Some stops will be common to many bus lines. If Placemark referencing was possible, there could be a master list of all stops and each line (set in a separate Folder) could just refer to one of the above Placemarks. Selecting more than one Folder would display the other Placemarks for those lines, but the Placemarks already displayed would not show multiple times.

这将减少混乱,尤其是名称仅显示一次时.

That would produce a lot less clutter, especially with the names displayed only once.

推荐答案

不幸的是,并非如此,因为Kml Schema不支持一对多关系或符号链接(除了样式,但这对您实际上没有任何用处) )

Unfortunately not as the Kml Schema does not support One-to-Many Relationships or symbolic links (apart from styles, but that is not really of any use to you.)

但是,您可以通过使用文件夹描述中的链接来模拟这种情况.

However, one way you could emulate this is by using links in folder descriptions.

以您的示例为例,假设您有一个文件,其中定义了公交车站"地标的主列表.然后,您可以在文件夹中定义所有路线,并带有指向相关站点的描述链接.

To use your example, say you have a single file that has your master list of 'bus stop' place-marks defined in it. You could then define all your routes in folders with description links to the relevant stops.

显然,所有地标都会始终显示,但是每个路线文件夹"至少允许您在该路线的车站之间移动,而不必复制车站数据.

Obviously all the place-marks are always shown, but each 'route folder' would at least allow you to move between the stops for that route without having to duplicate the stop data.

例如

<kml>
  <Folder id="stops">
    <Placemark id="p1">
      <name>stop 1</name>
    </Placemark>
    <Placemark id="p2">
      <name>stop 2</name>
    </Placemark>
    <Placemark id="p3">
      <name>stop 3</name>
    </Placemark>
    <Placemark id="p4">
      <name>stop 4</name>
    </Placemark>
    </Folder>
    <Folder id="r1">
      <name>route 1</name>
      <description>
        <![CDATA[
        <a href="#p1;balloonFlyto">stop 1</a>
        <a href="#p3;balloonFlyto">stop 3</a>
        ]]>
      </description>
    </Folder>
    <Folder id="r2">
      <name>route 2</name>
      <description>
        <![CDATA[
        <a href="#p1;balloonFlyto">stop 1</a>
        <a href="#p2;balloonFlyto">stop 2</a>
        <a href="#p4;balloonFlyto">stop 4</a>
        ]]>
      </description>
    </Folder>
</kml>

编辑

您还可以简单地将数据保存在不支持一对多的数据中,例如mysql数据库.然后,您可以查询它,但是您希望根据请求根据需要生成KML.查看此使用PHP&带有Earth API的MySQL 讲述了如何设置数据库来保存数据,如何查询数据以及如何从中输出KML.

You could also simply keep your data in something that does support one-to-many, like a mysql database. You could then query it however you liked to produce the KML as required based on the request made. Take a look at this Database Driven Earth App Using PHP & MySQL with the Earth API it goes through how you might set up a database to hold your data, how to query it and output KML from it.

这篇关于在KML中引用地标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆