2
votes

I'm working on a project where we are displaying a map of the state of Oregon using google maps. Right now I have a KML Layer that has lines for all the counties and a red overlay. I'm trying to change the color of the overlay but any changes I make to the style tags in the kml file aren't showing up.

The kml file is here, http://sixswords.net/oregon/kml/oregon_counties.kml

You can see the map with the overlay here https://maps.google.com/?q=http://sixswords.net/oregon/kml/oregon_counties.kml

Edit for more specific information:

The original kml file style looks like this.

<Style id='Style0-polygon-3'>
    <LabelStyle>
    <scale>0.0</scale>
    </LabelStyle>
    <LineStyle>
        <color>ff666666</color>
        <width>1</width>
    </LineStyle>
    <PolyStyle>
        <color>7f0000ff</color>
    </PolyStyle>
    <BalloonStyle>
        <text>$[description]</text>
    </BalloonStyle>
</Style>
<Style id='Style0-polygon-3-hover'>
    <LineStyle>
        <color>ff666666</color>
        <width>1</width>
    </LineStyle>
    <PolyStyle>
        <color>7f0000ff</color>
    </PolyStyle>
    <BalloonStyle>
        <text>$[description]</text>
    </BalloonStyle>
</Style>
<StyleMap id='Style0-polygon-3-map'>
    <Pair>
        <key>normal</key>
        <styleUrl>#Style0-polygon-3</styleUrl>
    </Pair>
    <Pair>
        <key>highlight</key>
        <styleUrl>#Style0-polygon-3-hover</styleUrl>
    </Pair>
</StyleMap>

I've tried changing the color value for the polystyle tag in the Style0-polygon-3 style but it doesn't actually change anything.

1
StyleMap doesn't work in Google Maps, perhaps that is your issue? (Try your KML file in Google Earth -- if it works there, you're doing it right.)yoyo

1 Answers

2
votes

That KML specifies red polygons.

This is the same with green polygons

https://developers.google.com/kml/documentation/kmlreference?csw=1#colorstyle

<color>

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.

so <color>

        <PolyStyle>
            <color>7f0000ff</color>
        </PolyStyle>

Is red.

        <PolyStyle>
            <color>7f00ff00</color>
        </PolyStyle>

Is green.