KML Label Placement

3,769 views
Skip to first unread message

BrianG

unread,
Oct 22, 2008, 6:03:47 PM10/22/08
to KML Developer Support - Advanced Support for KML
I have converted about a dozen point shapefiles to KML using an
extension called 'Export to KML.' Everything came over correct and
looks great in Google Earth, but the labels for each placemarker sit
directly on top of the point.

I would like to change this so that the labels are offset, similar to
the default labeling in GE if you were to click on the map to create a
placemark. The label 'Untitled Placemark' does not sit directly on
top of the push pin, it is above and to the right of the pushpin.

Any insight, I have tried many manipulations of the kml, nothing is
working for me and I cannot find a direct reference in the doco,
please help!

BrianG

unread,
Oct 22, 2008, 6:11:43 PM10/22/08
to KML Developer Support - Advanced Support for KML
How do I get the label, 'kml1' off the point?

Example KML:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<name><![CDATA[KMLLabelEx]]></name>
<open>1</open>
<Snippet maxLines="2"></Snippet>
<description><![CDATA[Exported from KMLLabelEx on 10/22/2008]]></
description>
<Schema name="KMLLabelEx" id="KMLLabelEx_schema">
<SimpleField type="int" name="FID">
<displayName><![CDATA[FID]]></displayName>
</SimpleField>
<SimpleField type="int" name="Id">
<displayName><![CDATA[Id]]></displayName>
</SimpleField>
<SimpleField type="string" name="ExNUM">
<displayName><![CDATA[ExNUM]]></displayName>
</SimpleField>
</Schema>
<Style id="FEATURES">
<IconStyle>
<color>FF001694</color>
<scale>0.333333333333333</scale>
<Icon>
<href>root://icons/palette-4.png</href>
<x>32</x>
<y>128</y>
<w>32</w>
<h>32</h>
</Icon>
</IconStyle>
<LabelStyle>
<color>00FFFFFF</color>
</LabelStyle>
<BalloonStyle>
<text>
<![CDATA[FID = $[KMLLabelEx/FID]
Id = $[KMLLabelEx/Id]
ExNUM = $[KMLLabelEx/ExNUM]
]]>
</text>
</BalloonStyle>
</Style>
<Style id="FEATURES_LABELS">
<IconStyle>
<color>00000000</color>
<Icon>
<href>http://maps.google.com/mapfiles/kml/shapes/
placemark_circle.png</href>
</Icon>
</IconStyle>
<LabelStyle>
<color>FFFFFFFF</color>
</LabelStyle>
</Style>
<Folder>
<name>Features</name>
<open>0</open>
<Placemark>
<name><![CDATA[kml1]]></name>
<Snippet maxLines="2"></Snippet>
<styleUrl>#FEATURES</styleUrl>
<ExtendedData>
<SchemaData schemaUrl="#KMLLabelEx_schema">
<SimpleData name="FID">0</SimpleData>
<SimpleData name="Id">0</SimpleData>
<SimpleData name="ExNUM"><![CDATA[kml1]]></SimpleData>
</SchemaData>
</ExtendedData>
<Point>
<extrude>0</extrude>
<altitudeMode>clampedToGround</altitudeMode>
<coordinates>
-122.258819443589,38.0103668159179,0
</coordinates>
</Point>
</Placemark>
</Folder>
<Folder>
<name>Feature Labels (<![CDATA[ExNUM]]>)</name>
<open>0</open>
<Placemark>
<name><![CDATA[kml1]]></name>
<styleUrl>#FEATURES_LABELS</styleUrl>
<Point>
<extrude>0</extrude>
<altitudeMode>clampedToGround</altitudeMode>
<coordinates>
-122.258819443589,38.0103668159179,0
</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>

Roman N

unread,
Oct 24, 2008, 9:12:44 PM10/24/08
to KML Developer Support - Advanced Support for KML
Hi Brian,

A few steps to do that:

1) Unless you need the Feature Labels folder for a specific purpose,
you can probably get rid of it.

2) Change, in your <LabelStyle>:

<color>00FFFFFF</color>

to:

<color>FFFFFFFF</color>

The '00' in 00FFFFFF causes a completely hidden label.

3) You may want to make the icon bigger, i.e. change the
<scale>0.3333... to <scale>1</scale> or simply remove it.

Hope that helps!
- Roman

BrianG

unread,
Oct 27, 2008, 4:09:47 PM10/27/08
to KML Developer Support - Advanced Support for KML
That did the trick, thank you very much!
Reply all
Reply to author
Forward
0 new messages