0

因此,我一直在筛选 GE 的文档,并找到了如何使用 LineStyle 和 LineString 来设置和显示线条的样式,但实际上我无法让它发挥作用。这是我的 KML:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"><Document><Style id="thisStyle">
<LineStyle>
<color>500078F0</color>
<colorMode>Normal</colorMode>
<width>5</width>
</LineStyle>
</Style>
<Placemark>
<name>502-2012-11-19 05:27:03</name>
<description>Speed:0</description>
<Point>
<coordinates>-76.0513,42.0894,247</coordinates>
</Point>
</Placemark>
<Placemark>
<name>502-2012-11-19 05:26:46</name>
<description>Speed:0</description>
<Point>
<coordinates>-76.0517,42.0886,287</coordinates>
</Point>
</Placemark>
....
<Placemark>
<name>525-2012-11-19 04:38:25</name>
<description>Speed:0</description>
<Point>
<coordinates>-76.0512,42.0894,178</coordinates>
</Point>
</Placemark>
<styleUrl>#thisStyle</styleUrl>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>
-76.0513,42.0894,247 
-76.0517,42.0886,287 
....
-76.0512,42.0894,178 
</coordinates></LineString></Document></kml>

注意:上面出现“...”的地方还有大约 50 个坐标集,为了简洁起见,我删除了它们,但由于所有坐标都是由脚本生成的,如果一个作品我知道它们都会生成。任何人都可以将我推向正确的方向,为什么我的地标都出现了,但没有线条?

4

2 回答 2

1

您必须在地标中内联样式或使用styleUrl元素引用地标中的样式。

您的示例中的最后一个 Placemark 需要像这样重写:

<Placemark>
    <name>525-2012-11-19 04:38:25</name>
    <description>Speed:0</description>
    <styleUrl>#thisStyle</styleUrl>
    <LineString>
        <tessellate>1</tessellate>
        <altitudeMode>clampToGround</altitudeMode>
        <coordinates>
            -76.0513,42.0894,247 
            -76.0517,42.0886,287
             ...
            -76.0512,42.0894,178 
        </coordinates>
    </LineString>
</Placemark>

如果您的 KML 无法正确查看,那么验证 KML 通常会有所帮助。您可以使用KML 验证器

于 2012-11-20T01:53:30.180 回答
1

LineString元素仅在 Placemark(或 Placemark 内的 MultiGeometry)内有效:

<Placemark>
  <LineString>
    <tessellate>1</tessellate>
    <altitudeMode>clampToGround</altitudeMode>
    <coordinates>
      -76.0513,42.0894,247 
      -76.0517,42.0886,287 
      -76.0512,42.0894,178 
    </coordinates>
  </LineString>
</Placemark>
于 2012-11-20T01:50:23.423 回答