Cant get the colors correct in my KML!

291 views
Skip to first unread message

toby

unread,
Apr 7, 2011, 3:47:08 PM4/7/11
to kml-support-g...@googlegroups.com
Hi, I´ve tried and i´ve tried but i can´t get it to work.
See the attached kml file, it has no color tags at all, giving it a default color.
But i don´t want it like this, I´d like it green=)
Please help me with this. Where do i put a color tag and how should it look like?
I´m going crazy on this!
/Toby
dike.kml

Brendan Kenny

unread,
Apr 8, 2011, 7:39:15 PM4/8/11
to KML Developer Support - Getting Started with KML
Hi Toby,

<color> elements are generally added to styles, which are in turn
associated with KML features. Search the reference document for the
references to "<color>" to see the many places that color elements are
supported:

http://code.google.com/apis/kml/documentation/kmlreference.html

Most of the examples given in that document also show how styles can
be declared and then associated with e.g. Placemarks.

Cheers,
Brendan
>  dike.kml
> 6KViewDownload

toby

unread,
Apr 9, 2011, 3:21:07 AM4/9/11
to kml-support-g...@googlegroups.com
Hi Brendan, thanks for the help!
 
I put this at the top of the kml:

<Document>

<name>LineStyle.kml</name>

<open>1</open>

<Style id="linestyleExample">

<LineStyle>

<color>7f0000ff</color>

<width>4</width>

</LineStyle>

</Style>
 
And then this at the start of every line.

<Placemark id="kml_1">

<name>kml_1</name>

<styleUrl>#linestyleExample</styleUrl>

And this works, the line does change color! ..but there still is a problem.

I have created my kml-files thru converting a shapefile. And the shapefile includes over 500 lines with their own attributes.

Therefor, the problem is that using the tags above forces me to write that <styleurl> over 500 times, one time for every line. Would´nt it be some way easier to give all the lines the same color somehow?

/Toby

Brendan Kenny

unread,
Apr 11, 2011, 7:21:41 PM4/11/11
to KML Developer Support - Getting Started with KML
Hi Toby,

You do indeed need a styleUrl per placemark. I would suggest either
auto-generating your KML so you don't have to write each one by hand,
or simplifying your geometry in some way so you don't need as many
style references.

Cheers,
Brendan

toby

unread,
Apr 13, 2011, 8:43:04 AM4/13/11
to kml-support-g...@googlegroups.com
Hi thanks for the help! The lines are allright, but i still have problems with my polygons.
I put this tags for coloring my polygon:

<Style id="test">

<LineStyle>

<color>6414B400</color>

<width>3</width>

</LineStyle>

<PolyStyle>

<color>64F00014</color>

</PolyStyle>

</Style>

And it gets the colors i want, but the colors are transparent. Why?

cheers /Toby

Rossko

unread,
Apr 14, 2011, 7:22:48 AM4/14/11
to KML Developer Support - Getting Started with KML
> <color>64F00014</color>
> And it gets the colors i want, but the colors are transparent. Why?

Because that's what you ask for. Have you seen
http://code.google.com/apis/kml/documentation/kmlreference.html#color
which describes the opacity part (64 in your case)
Reply all
Reply to author
Forward
0 new messages