Search code examples
kmlgoogle-earth

How to make png image Google Earth <color> compliant?


When I use the standard Google Earth placemark icons, I can set a ARGB colour. However, when I use my own png image, the <color></color> tag has no impact, the colour remains unchanged.

What do I need to apply to my image in order to make it compliant with the color tag? I have tried to use SVG, but this does not show at all.

<IconStyle>
  <scale>0.75</scale>
  <color>ffffffff</color>  <= works with the GM icons, but not with mine
  <Icon>
    <href>http://...myimage.png</href>
  </Icon>
</IconStyle>

Solution

  • The white color ffffffff is the default - meaning no blending of colors. The color tag is of the form aabbggrr not ARGB. Specify a non-white color to get blended (or mixed-in) with RGB color values of the image.

    Works best where icon has transparent background unless you want to blend the background color also. Some tricks include having a 3-color icon: 0=transparent background, 1=black outline and 2=solid white fill color. This blends well in Google Earth. For example take a look at the arrow icon in Google Earth http://maps.google.com/mapfiles/kml/shapes/arrow.png.

    Here's an example with a white on orange RSS feed icon blended with green showing an icon blended to green.

    <?xml version="1.0" encoding="UTF-8"?>
    <kml xmlns="http://www.opengis.net/kml/2.2">
        <Placemark>
            <name>Placemark</name>
            <description><![CDATA[icon: <br/>
             <img src="http://www.feedicons.com/images/feed-icon-28x28.png">]]>
            </description>
            <Style>     
                <IconStyle>
                    <color>ff00ff00</color>
                    <Icon>
                        <href>http://www.feedicons.com/images/feed-icon-28x28.png</href>
                    </Icon>                    
                </IconStyle>
            </Style>
            <Point>
                <coordinates>48.11427038011192,29.00801197928001</coordinates>
            </Point>
        </Placemark>
    </kml>