Search code examples
cssxmlkmlgoogle-earth

KML styling without styleUrl


Is there a way to color eg. a placemark without using styleUrl's? What i want to do is to style a placemark directly inside the placemark, instead of having to declare a style-id and referring to that id in the placemark.

I imagined something like:

<Folder>
  <name>Paths</name>
  <Placemark>
    <name>Extruded</name>
    <visibility>1</visibility>
    <LineString color="7f00ffff" width="2">
      <extrude>1</extrude>
      <tessellate>0</tessellate>
      <altitudeMode>absolute</altitudeMode>
      <coordinates>
        -112.2656634181359,36.09445214722695,2630
        -112.2652238941097,36.09520916122063,2630
        -112.2645079986395,36.09580763864907,2830
        </coordinates>
    </LineString>
  </Placemark>
</Folder>

Solution

  • I figured it out myself. You simply have to add the style-tags inside the placemark but outside the object. I made the mistake prior to asking the question to, place the style-tage inside the linestring.

    The code that satisfied my needs:

    <Folder>
        <name>Paths</name>
        <Placemark>
            <Style>
                <LineStyle>
                    <color>7f00ffff</color>
                    <width>2</width>
                </LineStyle>
            </Style>
            <name>Extruded</name>
            <visibility>1</visibility>
            <LineString>
                <extrude>1</extrude>
                <tessellate>0</tessellate>
                <altitudeMode>absolute</altitudeMode>
                <coordinates>
                    -112.2656634181359,36.09445214722695,2630
                    -112.2652238941097,36.09520916122063,2630
                    -112.2645079986395,36.09580763864907,2830
                </coordinates>
            </LineString>
        </Placemark>
    </Folder>