1
votes

I have asked to keep polygon, name of the polygon and the corresponding icon in the places panel.

Can any suggest me how to do this in kml?

2
Can try to explain in more detail what the problem is? Without more information it is impossible to know what you mean - hence the vote to close. - Fraser

2 Answers

3
votes

By default you only see the name label if your placemark has a Point geometry so for lines and polygons the name is not shown.

You can however create a MultiGeometry with both a Polygon and a Point (typically the center point or where you want to label to appear near). If you don't want the default yellow pushpin to appear just add a Style with an empty IconStyle href element to the Placemark.

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Placemark>
        <name>polygon</name>
        <Style>
            <IconStyle>
                <Icon/>
            </IconStyle>
        </Style>
        <MultiGeometry>
            <Point>
                <coordinates>-122.4317195,37.801848</coordinates>
            </Point>
            <Polygon>
                <outerBoundaryIs>
                    <LinearRing>
                        <coordinates>
              -122.43193945401,37.801983684521
              -122.431564131101,37.8020327731402
              -122.431499536494,37.801715236748
              -122.43187136387,37.8016634915437
              -122.43193945401,37.801983684521
                        </coordinates>
                    </LinearRing>
                </outerBoundaryIs>
            </Polygon>
        </MultiGeometry>
    </Placemark>
</kml>
0
votes

This multi-geometry method can be HIGHLY tedious if you have a couple hundred polygons (say, a grid/index) and you want to show their names.

My preference is to use something like QGIS/Arc, where I create a new vector file of polygon centroids (point file) that has the polygon attributes (including name/description). I save the new point file as a point KML and import into Google Earth. From their, I set a shared style for the point file, with the icon set to 0% opacity.

Example of Google Earth Polygons with Labels using above method