KML for hiding and displaying placemark names

2,583 views
Skip to first unread message

kmh2000

unread,
Apr 7, 2006, 6:12:39 PM4/7/06
to KML Discussions
This may be a very simple issue to address, but I am new to KML so I was wondering if anyone could give me some help.

I have several KML files with thousands of points. The density of these can make for a rather messy view because the placemark names are always visible.

I would like these to only show when 1) when zoomed way in and/or 2) when someone rolls over the placemark icon.

I think this is pretty simple code but I have tried several times to do this but have had no luck.

Is there a way to add a universal tag that will apply to all of the points so I don't have to deal with each one individually? Again, this shows off my novice ability with KML (and XML), but I would appreciate any help with this.

Thank you!

Keene

barryhunter

unread,
Apr 7, 2006, 7:04:39 PM4/7/06
to KML Discussions
I use the following to only display the label when actully pointed at:

Include this at the very top, just inside the <Document> tag
Code:
<Style id="defaultIcon">
<LabelStyle>
<scale>0</scale>
</LabelStyle>
</Style>
<Style id="hoverIcon">
<IconStyle id="hoverIcon">
<scale>1.1</scale>
</IconStyle>
</Style>
<StyleMap id="defaultStyle">
<Pair>
<key>normal</key>
<styleUrl>#defaultIcon</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#hoverIcon</styleUrl>
</Pair>
</StyleMap>


then this in each placemark
Code:
<styleUrl>#defaultStyle</styleUrl>


If you are editing the KML manaully then you can use search and replace to insert the last line into each placemark. let us know if you need help with this step.

kmh2000

unread,
Apr 7, 2006, 7:35:44 PM4/7/06
to KML Discussions
No luck. It still displays the placemark name all the time when I zoom in some. The placemark name is not show when I am zoomed way out, but this must be the default.

I assume the <styleURL> needs to go between the <Placemark> and </Placemark> tag. I am putting it right after the <Placemark> opening tag for each entry. I assume that indentation does not really matter, it only makes reading the code a little easier.

I see what you did by defining the style and then calling it in each Placemark. I am beginning to understand this somewhat now.

Again, thanks for your help.

Keene

kmh2000

unread,
Apr 7, 2006, 7:47:00 PM4/7/06
to KML Discussions
Okay! I did get it to work. I realized I still had my old <styleURL> data in there which was overriding the code you suggested. Now I just need to change the defaulticons to the ones I have been using and it should hopefully work.

I really appreciate your help.

Keene

barryhunter

unread,
Apr 8, 2006, 10:06:09 AM4/8/06
to KML Discussions
Ah yes, I should of mentioned you might need to merge your current style with something like this! Glad it helped
Reply all
Reply to author
Forward
0 new messages