kml

Colored polygon outlines displayed as just all white opaque polygons


Someone shared a kml with me that was created in Google Earth Web along with a screenshot of it.

When I opened it up in Google Earth Pro, the colored polygons displayed as solid white.

For a test, I created a test polygon in Google Earth Web and exported it as KML.

  1. Projects > New project > Create KML file
  2. Draw line or shape > create polygon
  3. Set fill color red at 75%
  4. Set color 4px
  5. Select export as KML

Same thing, the polygon shows up as a white box in Google Earth Pro.

The exported KML is structured like this:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns=http://www.opengis.net/kml/2.2 xmlns:gx=http://www.google.com/kml/ext/2.2 xmlns:kml=http://www.opengis.net/kml/2.2 xmlns:atom=http://www.w3.org/2005/Atom>
<Document>
        <name>Untitled Project</name>
        <gx:CascadingStyle kml:id="__managed_style_147D324643211BD21CEE">
                <Style>
                        <IconStyle>
                                <Icon>
                                        <href>https://earth.google.com/earth/rpc/cc/icon?color=1976d2&amp;id=2000&amp;scale=4</href>
                                 </Icon>
                                 <hotSpot x="64" y="128" xunits="pixels" yunits="insetPixels"/>
                        </IconStyle>
                        <LabelStyle>
                        </LabelStyle>
                        <LineStyle>
                            <color>ffa21f7b</color>
                            <width>3.63636</width>
                        </LineStyle>
                        <PolyStyle>
                            <color>c02f2fd3</color>
                        </PolyStyle>
                        <BalloonStyle>
                            <displayMode>hide</displayMode>
                        </BalloonStyle>
                </Style>
            </gx:CascadingStyle>                
            ...
                
        <StyleMap id="__managed_style_0C1991940B211BD21CEE">
            <Pair>
                 <key>normal</key>
                 <styleUrl>#__managed_style_147D324643211BD21CEE</styleUrl>
            </Pair>
            <Pair>
                 <key>highlight</key>
                 <styleUrl>#__managed_style_2EB2C27FFE211BD21CEE</styleUrl>
            </Pair>
        </StyleMap>
                
        <Placemark id="09A507D5E3211BD1D53F">
            <name>Test Polygon</name>
            <styleUrl>#__managed_style_0C1991940B211BD21CEE</styleUrl>
            <Polygon>
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
                                                                                                0.0287244781654028,51.5286273373769,4.888032506075639 0.03124375777183053,51.52899071640604,5.649232085770059 0.03060716674301966,51.5305703663013,6.296306355936279 0.02835525808849049,51.53027540191405,5.649128389213159 0.0287244781654028,51.5286273373769,4.888032506075639 
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </Placemark>
</Document>
</kml>

The <gx:CascadingStyle> does not appear in the KML reference. https://developers.google.com/kml/documentation/kmlreference

What is going on here?

i am expecting the original colored polygon to appear in Google Earth Pro.


Solution

  • The <gx:CascadingStyle> is an undocumented element that is created in Google Earth Web that is unsupported by Google Earth Pro.

    If you make a minor edit to the KML, then it will work as expected.

    Make these changes:

    1. Remove <Style> and </Style> elements.
    2. Globally change <gx:CascadingStyle kml:id="xxx"> to <Style id="xxx">.
      Replace <gx:CascadingStyle kml:id= with <Style id=
    3. Replace </gx:CascadingStyle> with</Style>

    Example:

    Old:

        <gx:CascadingStyle kml:id="__managed_style_147D324643211BD21CEE">
            <Style>
                ...
            </Style>
        </gx:CascadingStyle>
    

    New:

        <Style id="__managed_style_147D324643211BD21CEE">
            ...
        </Style>
    

    You can globally make the changes to the KML using a text editor; e.g. Notepad++.

    The KML is now valid with respect to the OGC KML 2.2 standard and will work in Google Earth Pro.