Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying Names on the Map using KML

I am able to display polygons, circles, etc etc, using KML. Now i want to display only some Names using KML. Is this Possible ?

like image 763
Pravin Kumar Avatar asked Nov 14 '12 11:11

Pravin Kumar


People also ask

How do I show labels in KML?

With the root layer of the KML file highlighted in the Contents pane, on the KML Layer tab set, click the Labeling tab. In the Layer group, click Label . The placement and appearance of the labeling is controlled by the KML file and cannot be modified from the layer.

How do I show labels in KML in Google Earth?

Note: The Label Field can be changed by navigating to the Labels tab in Layer Properties. Use the Map to KML tool to convert the data to a KML or KMZ file, which can be viewed in Google Earth.

Can Google maps display KML?

Open Google My Maps. Create a new map. Press import. Open your KML file or drag your KML file into the import window.


1 Answers

If you want to suppress displaying the label of placemarks (via KML) on the map of Google Earth then you can add a LabelStyle to your placemarks with a 0 scale (see sn_hide style in example below). If you want to suppress the label name on the map until you hover over the icon then StyleMaps are your best bet.

The first placemark in example below has its name shown in the places panel but hidden from the map using the LabelStyle. The second placemark #2 uses a StyleMap to hide the label until the user highlights or mouses over the icon in which it activates the highlight style showing the label. The third placemark #3 uses the default style that always shows the label.

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Document>
        <name>Hide and show labels</name>
        <Style id="sn_hide">
            <LabelStyle>
                <scale>0</scale>
            </LabelStyle>
        </Style>
        <Style id="sh_style">
            <LabelStyle>
                <scale>1.1</scale>
            </LabelStyle>
        </Style>
        <StyleMap id="msn_hide">
            <Pair>
                <key>normal</key>
                <styleUrl>#sn_hide</styleUrl>
            </Pair>
            <Pair>
                <key>highlight</key>
                <styleUrl>#sh_style</styleUrl>
            </Pair>
        </StyleMap>

        <Placemark>
            <name>Placemark 1</name>
            <description>Label name always hidden</description>
            <styleUrl>#sn_hide</styleUrl>
            <Point>
                <coordinates>-119.232195,36.016021</coordinates>
            </Point>
        </Placemark>

        <Placemark>
            <name>Placemark 2</name>
            <description>Hover over place to show label</description>
            <styleUrl>#msn_hide</styleUrl>
            <Point>
                <coordinates>-119.2324,36.0155</coordinates>
            </Point>
        </Placemark>

        <Placemark>
            <name>Placemark 3</name>
            <description>Always showing</description>
            <Point>
                <coordinates>-119.232672,36.014837</coordinates>
            </Point>
        </Placemark>
    </Document>
</kml>
like image 80
CodeMonkey Avatar answered Oct 04 '22 07:10

CodeMonkey