eric_spittle
eric_spittle

Reputation: 124

Getting lines to work on Google Earth

So I've been sifting through GE's documentation, and found how to do LineStyle and LineString to style and display a line, but in practice I cannot actually make it work. Here's my 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>

Note: The above places where "..." appears there are about 50 more coordinate sets, I removed them for the sake of brevity, but since all coordinates are produced by a script if one works I know they all will. Can anyone nudge me in the right direction as to why my placemarks all show up, but no lines?

Upvotes: 0

Views: 5270

Answers (2)

CodeMonkey
CodeMonkey

Reputation: 23738

You must either inline Style in the Placemark or reference the style in the Placemark using styleUrl element.

The last Placemark in your example needs to be rewritten like this:

<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>

If your KML doesn't view correctly then it usually helps to validate the KML. You can use the KML Validator.

Upvotes: 1

geocodezip
geocodezip

Reputation: 161334

A LineString element is only valid inside a Placemark (or a MultiGeometry inside a Placemark):

<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>

Upvotes: 1

Related Questions