1

I'm using the javascript API for Google Maps and uploaded a kml. It's picking up the .kml fine, but the polygon style isn't pulling in correctly. I've got 4 polygons each with different colors and this is what it renders as:

Rendering

Here is the .kml file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document id="root_doc">
    <Schema name="LandOwnership" id="LandOwnership">
      <SimpleField name="OWNER" type="string"/>
      <SimpleField name="AGENCY" type="string"/>
      <SimpleField name="ADMIN" type="string"/>
      <SimpleField name="DESIG" type="string"/>
      <SimpleField name="STATE_LGD" type="string"/>
      <SimpleField name="UT_LGD" type="string"/>
      <SimpleField name="NATL_LGD" type="string"/>
      <SimpleField name="EDIT_DATE" type="string"/>
      <SimpleField name="LABEL_FEDE" type="string"/>
      <SimpleField name="LABEL_STAT" type="string"/>
      <SimpleField name="GIS_ACRES" type="float"/>
      <SimpleField name="COUNTY" type="string"/>
      <SimpleField name="SHAPE_Leng" type="float"/>
      <SimpleField name="SHAPE_Area" type="float"/>
    </Schema>
    <Folder>
      <name>LandOwnership</name>
      <Placemark>
        <ExtendedData>
          <SchemaData schemaUrl="#LandOwnership">
            <SimpleData name="OWNER">Federal</SimpleData>
            <SimpleData name="AGENCY">BLM</SimpleData>
            <SimpleData name="ADMIN">BLM</SimpleData>
            <SimpleData name="DESIG">N/A</SimpleData>
            <SimpleData name="STATE_LGD">Bureau of Land Management</SimpleData>
            <SimpleData name="UT_LGD">Bureau of Land Management (BLM)</SimpleData>
            <SimpleData name="NATL_LGD">Bureau of Land Management (BLM)</SimpleData>
            <SimpleData name="EDIT_DATE">2008/10/01</SimpleData>
            <SimpleData name="GIS_ACRES">81.45050049000</SimpleData>
            <SimpleData name="COUNTY">CACHE</SimpleData>
            <SimpleData name="SHAPE_Leng">2445.42598229000</SimpleData>
            <SimpleData name="SHAPE_Area">329618.47060000000</SimpleData>
          </SchemaData>
        </ExtendedData>
        <Polygon>
          <outerBoundaryIs>
            <LinearRing>
              <coordinates>
                  -114.0490723,42.0003251,0
                  -114.0710449,37.0025527,0
                  -112.6757812,37.0025527,0
                  -112.6538086,42.008489,0
                  -114.0490723,42.0003251,0
                </coordinates>
            </LinearRing>
          </outerBoundaryIs>
        </Polygon>
        <styleUrl>#federal</styleUrl>
      </Placemark>
      <Placemark>
        <ExtendedData>
          <SchemaData schemaUrl="#LandOwnership">
            <SimpleData name="OWNER">State</SimpleData>
            <SimpleData name="AGENCY">DNR</SimpleData>
            <SimpleData name="ADMIN">UDWR</SimpleData>
            <SimpleData name="DESIG">Wildlife Reserve/Management Area</SimpleData>
            <SimpleData name="STATE_LGD">State Wildlife Reserve/Management Area</SimpleData>
            <SimpleData name="UT_LGD">State Wildlife Reserve/Management Area</SimpleData>
            <SimpleData name="NATL_LGD">State, County, City; Wildlife, Park and Outdoor Recreation Areas</SimpleData>
            <SimpleData name="EDIT_DATE">2008/10/01</SimpleData>
            <SimpleData name="GIS_ACRES">308.72662354000</SimpleData>
            <SimpleData name="COUNTY">CACHE</SimpleData>
            <SimpleData name="SHAPE_Leng">6565.50929155000</SimpleData>
            <SimpleData name="SHAPE_Area">1249372.33890000009</SimpleData>
          </SchemaData>
        </ExtendedData>
        <Polygon>
          <outerBoundaryIs>
            <LinearRing>
              <coordinates>
                -112.6538086,42.008489,0
                -112.6757812,37.0025527,0
                -111.159668,37.0288694,0
                -111.1486816,42.008489,0
                -112.6538086,42.008489,0
              </coordinates>
            </LinearRing>
          </outerBoundaryIs>
        </Polygon>
        <styleUrl>#state</styleUrl>
      </Placemark>
      <Placemark>
        <ExtendedData>
          <SchemaData schemaUrl="#LandOwnership">
            <SimpleData name="OWNER">Tribal</SimpleData>
            <SimpleData name="AGENCY">Tribal</SimpleData>
            <SimpleData name="ADMIN">Tribal</SimpleData>
            <SimpleData name="DESIG">Indian Reservation</SimpleData>
            <SimpleData name="STATE_LGD">Tribal Lands</SimpleData>
            <SimpleData name="UT_LGD">Indian Reservation (IR)</SimpleData>
            <SimpleData name="NATL_LGD">Indian Reservation (IR)</SimpleData>
            <SimpleData name="EDIT_DATE">2008/10/01</SimpleData>
            <SimpleData name="LABEL_FEDE">Goshute Tribal Lands</SimpleData>
            <SimpleData name="GIS_ACRES">42453.76562500000</SimpleData>
            <SimpleData name="COUNTY">JUAB</SimpleData>
            <SimpleData name="SHAPE_Leng">119974.20068400000</SimpleData>
            <SimpleData name="SHAPE_Area">171804294.54600000381</SimpleData>
          </SchemaData>
        </ExtendedData>
        <Polygon>
          <outerBoundaryIs>
            <LinearRing>
              <coordinates>
                -111.159668,37.0288694,0
                -109.083252,37.0200982,0
                -109.0612793,39.2832939,0
                -111.1376953,39.291797,0
                -111.159668,37.0288694,0
              </coordinates>
            </LinearRing>
          </outerBoundaryIs>
        </Polygon>
        <styleUrl>#tribal</styleUrl>
      </Placemark>
      <Placemark>
        <ExtendedData>
          <SchemaData schemaUrl="#LandOwnership">
            <SimpleData name="OWNER">Private</SimpleData>
            <SimpleData name="AGENCY">Private</SimpleData>
            <SimpleData name="ADMIN">Private</SimpleData>
            <SimpleData name="DESIG">N/A</SimpleData>
            <SimpleData name="STATE_LGD">Private</SimpleData>
            <SimpleData name="UT_LGD">Private</SimpleData>
            <SimpleData name="NATL_LGD">Private</SimpleData>
            <SimpleData name="EDIT_DATE">2008/10/01</SimpleData>
            <SimpleData name="GIS_ACRES">80.33841705000</SimpleData>
            <SimpleData name="COUNTY">JUAB</SimpleData>
            <SimpleData name="SHAPE_Leng">2427.86686739000</SimpleData>
            <SimpleData name="SHAPE_Area">325118.03909999999</SimpleData>
          </SchemaData>
        </ExtendedData>
        <Polygon>
          <outerBoundaryIs>
            <LinearRing>
              <coordinates>
                -111.1486816,41.0047754,0
                -111.1376953,39.291797,0
                -109.0612793,39.2832939,0
                -109.0393066,40.996484,0
                -111.1486816,41.0047754,0
              </coordinates>
            </LinearRing>
          </outerBoundaryIs>
        </Polygon>
        <styleUrl>#private</styleUrl>
      </Placemark>
    </Folder>
    <Style id="federal">
      <LineStyle>
        <color>4DFF0000</color>
        <width>4</width>
      </LineStyle>
      <PolyStyle>
        <color>FF0000</color>
        <colorMode>normal</colorMode>
        <fill>1</fill>
        <outline>1</outline>
      </PolyStyle>
    </Style>
    <Style id="state">
      <LineStyle>
        <color>4DFFF500</color>
        <width>4</width>
      </LineStyle>
      <PolyStyle>
        <color>FFF500</color>
        <colorMode>normal</colorMode>
        <fill>1</fill>
        <outline>1</outline>
      </PolyStyle>
    </Style>
    <Style id="tribal">
      <LineStyle>
        <color>4DFF7E00</color>
        <width>4</width>
      </LineStyle>
      <PolyStyle>
        <color>FF7E00</color>
        <colorMode>normal</colorMode>
        <fill>1</fill>
        <outline>1</outline>
      </PolyStyle>
    </Style>
    <Style id="private">
      <LineStyle>
        <color>4D0000FF</color>
        <width>4</width>
      </LineStyle>
      <PolyStyle>
        <color>0000FF</color>
        <colorMode>normal</colorMode>
        <fill>1</fill>
        <outline>1</outline>
      </PolyStyle>
    </Style>
  </Document>
</kml>
1

Your PolyStyle colors need eight characters, not six.

KML colors are written like this:

<color>AABBGGRR</color>
  • AA = Alpha/Opacity
  • BB = Blue
  • GG = Green
  • RR = Red

Note that the BGR ordering is backwards from the traditional RGB.

This is different from HTML colors which are written with only six characters, like this:

#RRGGBB

Try adding "FF" (fully opaque, no transparency) to the beginning of each PolyStyle color, and you'll see the polygons are filled with color when viewed in Earth. That should work in Maps too.

  • This is helpful. I added FF to the Polystyle colors (the LineStyle colors were already 8 digits), however, and it didn't change anything (still no fill). Geojson is working, though, so I might switch to that. – JBaczuk Jun 5 '17 at 14:26
  • Hmm... sorry it's not working yet. Unlikely to be the issue, but one other KML schema issue is that your styleUrl tags should come before ExtendedData. See the KML reference for correct tag order: developers.google.com/kml/documentation/kmlreference#placemark Another thing to check is that you're actually getting the new file... not a cached copy of the old one. Try changing the filename to confirm? – Christiaan Adams Jun 6 '17 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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