KML styles and stylemaps

The symbology of polygons can be defined by styles and stylemaps. Styles define specific fill and line settings. There can be as many styles as you want. Each placemark (or in this case polygon) can be defined by a separate style, or one style can be used for all placemarks. StyleMaps are used for mouse-over effects. Since there are two styles for a mouse-over (a normal style, and a highlighted style), a StyleMap defines the relationships. Below are some options for defining Styles and StyleMaps.

Here is a sample style that defines the polygon fill and outline settings:

<Style id=”normal”>
<color>64000000</color> !I used the following website to select the colour code. The code also defines the level of transparency.
<width>1</width> !Specifies the width of the line. In this case 1 is a thin line.
<color>3c14F0FF</color> !Specifies the fill colour. In this case yellow with 60% transparency

Here is another style to define highlighted polygons for a mouse-over:

<Style id=”highlight”>
<color>ff3f00ff</color> !Red line
<width>4</width> !4 is a thick line
<color>3c14F0FF</color> !Red fill with 50% transparency

Now we can define the StyleMap:

<StyleMap id=”mouseover”>!The name
<Pair> !Here we specify the normal symbology
<styleUrl>#normal</styleUrl> !Specify the name of the style preceded by a #
<Pair>!Here we specify the highlighted symbology

In the next post I will describe how to define the location of the polygon placemarks and assign them different styles or stylemaps


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s