Search code examples
kmlgoogle-earth

KML file not formatting a drawn line


I am using the following code to generate a line in Google Earth, however the formatting of the line is not changing.

<Placemark>
<LineString>
<Style id="bendigo_line">
    <LineStyle>
        <width>3</width>
        <color>64F0FF14</color>
    </LineStyle>
</Style>
<coordinates>
-15,52,0
-20,53,0
-30,53,0
-40,53,0
-50,52,0
-53.233333,51.166667


</coordinates>
</LineString>
</Placemark>

I'm unsure of what I am doing wrong as this method has worked in the past and now doesn't change the line from the default thickness and colour.

Thanks


Solution

  • The <Style> element must appear outside the <LineString> element. KML requires elements in a particular order.

    For the syntax of the Placemark refer to the KML Reference.

    Try changing your KML to this order of elements:

    <Placemark>
      <Style>
        <LineStyle>
            <width>3</width>
            <color>64F0FF14</color>
        </LineStyle>
      </Style>
      <LineString>
        <coordinates>
         ...
        </coordinates>
      </LineString>
    </Placemark>
    

    When there are problems with KML try first to validate it using the KML Validator.