Google Earth Lessons

An Educational Resource for Teachers

Step 6 - Following the Color Rules...

OK, you have created a placemark and made it brown. But what if you want it a different color, like green or lavendar? You can do it fairly easily, but not as easily as it could be.

In our XML code we had the color defined by the color tag:

<color>ff007db3</color>

It looks similar to HTML color coding:

<body bgcolor="#FDFFCE">

But in fact it is quite different. Notice a few things first of all. Notice that letters are (MUST BE) lower-case in the XML code but don't have to be in the HTML. HTML is more forgiving. XML is Case Sensitive.

The trick to adding the color you want into a <color> tag is to take the color code from HTML and run it through a blender. The reason is because Google Earth looks at colors in the opposite direction than HTML even though they both use what is called the 'hexidecimal value' of colors (0 = 00 to 255 =ff).

HTML colors are RGB (Red, Green, Blue) whereas KML needs colors in the order BGR (Blue, Green, Red).

Also, Google Earth KML allows you to specify how transparent the balloon color is. So, in the code above, the color information is ff007db3 and breaks down this way:

  • ff = fully opaque (00 would be 100% transparent, why you would want that, I don't know)
  • 00 = blue value
  • 7d = green value
  • b3 = red value

So, to add a color that you want using a color picker rather than a sophisticated graphics program that will show you the individual hexidecimal value of each RGB color (which you can still do if you want to, but I guess I am a little lazy that way) is to just find the color you want with an HTML color picker and then flip the first two characters with the last two characters.

Here is an example using the color picker at wellstyled.com:

colorpicker

If we wanted to use the top color as the color of the window without any transparency our final product would be:

<color>ffffff80</color>, the second one down would be <color>ff999900</color> and so on as we switch the first two characters with the last two characters and put the ff in front of it all so that the color shows up all the way.

And that's it!

Attached is an advanced placemark with two placemarks in a folder that share the <styleURL> so you can see some more advanced features such as sharing icon traits, etc. in the <Style> tag now that you know a little bit about nesting and tags and such.

Play around, experiment and be sure to drop us a line with some of the neat placemarks you created! You can toss them in the GELessons.com KMZ bucket and access them world-wide!