4

I've been able to create a KML file that shows a circle on my (Google Earth) map. Now I would like to have a translucent fill on the circle. I'm new to KML, so I'm learning by trial-and-error with examples from the web.

My code looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Placemark>
      <Name>EWR</Name>
      <Description>EWR</Description>
      <Style>
       <IconStyle>
         <Icon/>
       </IconStyle>
       <LineStyle>
         <color>ff0000ff</color>
         <width>2</width>
       </LineStyle>
     </Style>
    <LineString>
      <tessellate>1</tessellate>
      <coordinates>
       -74.0733123604,40.6924798
       -74.0753862256,40.7075157245
      [...]
      </coordinates>
    </LineString>
 </Placemark>
 </Document>
 </kml>

CLARIFICATION: I've gotten a few answers saying "adjust the value for the 'color' tag". That's enlightening, but doing that changes the opacity of the outline. What I want to do is fill the circle. I'm guessing that I need some additional tag(s) to do that.

2
  • You are unable to partially change a point symbology. You can, however, create two symbols--a semi transparent circle and a solid circle outline. Though I wouldn't recommend for larger datasets. If you are working with a polygon, there is a way to change the fill of the polygon to be solid while the fill is not. I'll update my answer with that code.
    – MaryBeth
    Commented Dec 15, 2015 at 14:00
  • I have multiple zones that I wish to add color to each zone. Zone 1 blue, Zone 2 Red, Zone 3 Purple, Zone 4 Orange, Zone 5 Yellow. Can some one please add this to the following KML file; <kml xmlns="opengis.net/kml/2.2"> <Document> <name>New Map</name> <visibility>1</visibility> <open>1</open> <Folder> <name>New Map</name> <visibility>1</visibility> <open>1</open> <Placemark> <name>Zone 1</name> <description>Port Zone 1</description> <visibility>1</visibility> <LineString> <coordinates>152.804911,-31.727295 152.690033,-31.734230 152.660155,-31.734181 152.710415,-31.678095 152.688466
    – Damien
    Commented Apr 22, 2019 at 6:56

2 Answers 2

3

For a point feature:

You'll basically need to define with a transparency prefix (see below). In your color tag referenced in your code above (ff0000ff ) the prefix ff represents 100% opaque or 0% transparent. To get to a 50% transparency, you'd need to use the hex representation of 7F as your prefix (7F0000ff) Hex Transparency Guide in Answers

From Google Earth Developers Forum:

Elements Specific to ColorStyle

Color and opacity (alpha) values are expressed in hexadecimal notation. The range of values for any one color is 0 to 255 (00 to ff). For alpha, 00 is fully transparent and ff is fully opaque. The order of expression is aabbggrr, where aa=alpha (00 to ff); bb=blue (00 to ff); gg=green (00 to ff); rr=red (00 to ff). For example, if you want to apply a blue color with 50 percent opacity to an overlay, you would specify the following: 7fff0000, where alpha=0x7f, blue=0xff, green=0x00, and red=0x00

An alternate work-around for creating a point with a transparent outline could be to create the image in GIMP or other photo-editing software where the .GIF has a transparent fill and opaque outline.

For a polygon feature:

You will need to create a style in order to use mixed transparencies. You need to use the PolyStyle tag to edit how the polygon is displayed. In the example below, fill and outline tags being set to "1" ensure visibility. ("0" would be false). The LineStyle tag is the outline, using the "FF" prefix, as above, you will see the line as solid. The Color Tag nested inside PolyStyle shows a 50% transparency, as expected with the 7F prefix.

Example taken from here.

enter image description here enter image description here

1
  • thanks! that was the right path to go down. I was not getting translucent polygons in Google Earth, but if I upload to Google maps, I get it. Commented Dec 16, 2015 at 14:03
2

With the <color> tag, as follows:

<color>ff0000ff</color>

The first two hex characters define the alpha band, or opacity.

  • ff = completely solid
  • 00 = completely translucent

More info here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.