multiple icon styles in one KML file

1,419 views
Skip to first unread message

samcampos

unread,
Feb 5, 2007, 4:22:35 PM2/5/07
to KML Discussions
Hello,

I am trying to write a KML file that will display two different icons. I can get the code to display one of the icons (the red icon), but not the blue one. Instead of the blue icon, it displays the default yellow pushpin icon. I have not been able to find any help on this yet. Any suggestions or links to a tutorial would be much appreciated! Below is the code that I am using.

<?xml version ="1.0"?>
<kml xmlns='http://earth.google.com/kml/2.1'>
<Folder><name>Test Project</name>
<LookAt>
<longitude>-119.3</longitude>
<latitude>35.5</latitude>
<range>170000</range>
<tilt>55</tilt>
</LookAt>
<Style id='blueicon'><IconStyle><Icon><href>http://maps.google.com/mapfiles/kml/paddle/blu-circle.png</href></Icon></IconStyle></Style>
<Style id='redicon'><IconStyle><Icon><href>http://maps.google.com/mapfiles/kml/paddle/red-circle.png</href></Icon></IconStyle></Style>

<Placemark>
<name>Name 1</name>
<description>Description 1</description>
<styleUrl>#blueicon</styleUrl>
<Point>
<coordinates>-118.953009907556,35.0159600819684</coordinates>
</Point>
</Placemark>

<Placemark>
<name>Name 2</name>
<description>Description 2</description>
<styleUrl>#redicon</styleUrl>
<Point>
<coordinates>-119.289768458283,36.3268987922839</coordinates>
</Point>
</Placemark>

</Folder>
</kml>


Thanks!

ManoM

unread,
Feb 5, 2007, 4:47:38 PM2/5/07
to KML Discussions
Hi samcampos,

Try wrapping it all in a <Document> element. Styles should live at the <Document> Level:

Code:

<?xml version ="1.0"?>
<kml xmlns="http://earth.google.com/kml/2.1">
  <Document><Style id="blueicon">
  </Document>
</kml>




ManoM

samcampos

unread,
Feb 6, 2007, 4:09:33 PM2/6/07
to KML Discussions
Thank you! That was it!

Grok_Lobster

unread,
Feb 6, 2007, 4:11:52 PM2/6/07
to KML Discussions
It might be a bug. I found something similar yesterday with polylines.

Try moving the style description for the red icon down past the point of using the blue icon. Instances after that should work if it is the same.
Reply all
Reply to author
Forward
0 new messages