setting checked state of checkboxes

640 views
Skip to first unread message

Carl Dreher

unread,
Jan 28, 2010, 1:31:35 PM1/28/10
to KML Developer Support - Getting Started with KML
I have a kml file with lots of nested folders and placemark. I want
to set the state of the various checkboxes (check or unchecked) when
the file is first loaded. I don't find anything is the <Document> or
<Folder> API that indicates how to do this.

Looking through past postings, I find a discussion about using the
<visibility> flag, but the thread concludes that it doesn't work.
I've also tried that, and find that although it DOES work on the
<Placemark> tag, it does not work on <Document> or <Folder> tags.
Everything always comes up checked when first loaded.

The <open> tag within a Folder or Document works as advertised, that
is, the folder is open or closed. But that does not affect the
checkbox.

Surely there is a way of setting the default state of a checkbox! I
can't believe the Google engineers could have missed something so
basic.

I'm using the lastest version of the Google Earth stand-alone
application in Windows XP Pro with all the lastest service packs.

shannon9585

unread,
Jan 29, 2010, 12:32:42 PM1/29/10
to KML Developer Support - Getting Started with KML
It works if you apply it to each placemark. It also seems to work if
you apply to both the Document and Folder (within the Document).

Depending on what I'm doing, I sometimes find it easier to open the
KML in Google Earth, set the visiblity of the folders the way I want
it to appear when I first open the file, then save the KML from GE.
It will save the file with the visibility configured how you had it
set. If you do it this way, you can at least see where they put the
<visibility> tags for it to work the way you want.

Carl Dreher

unread,
Jan 29, 2010, 6:02:44 PM1/29/10
to KML Developer Support - Getting Started with KML
This is a brilliant technique! I forgot all about the ability to
build it and then save the result to look at the KML file. Great
idea!

Having done that, what I'm finding is the checkboxes have some kind of
nested logic that isn't intuitive to how I think checkbox behavior
should be. For example, if I have a checkbox (folder) and is checked
and three checkbox folders under it, even if I use identical code on
the nested three to set them unchecked (visibility=0), only the first
one is unchecked. GoogleEarth's checkbox logic seems to want to make
sure that at least one of the inner checkboxes is checked if the outer
one is checked.

Jason M

unread,
Jan 30, 2010, 3:44:18 PM1/30/10
to KML Developer Support - Getting Started with KML
Note you're seeing a bug in Google Earth where Google Earth
incorrectly ignores visibility on containers when drawing features.

http://code.google.com/p/earth-issues/issues/detail?id=435&q=reporter%3Agjmathews&colspec=ID%20Type%20Summary%20Status%20Owner%20Stars
Reply all
Reply to author
Forward
0 new messages