[GIS] KML Balloon Not Showing Up In

google earthkmlkmzperlxml

I've created a perl script to create multiple line files from points. It iterates through, creates everything as expected. When you hover over a line, I get a balloon with all of the attribute information that I'm pushing. Only issue, I don't want 300 separate kml files. So, I modified the script to write to a kml "folder". All of the lines display as expected. Looks just like the individual files, but I can open the one file and see everything. EXCEPT, now the attribute information does not show up when I hover over a line/click on a line/even when I go to properties. It's the same exact setup that is in the individual file…Is it impossible to show several balloons in one file, even if they are separate "documents"?

Balloon Tag Snip

Best Answer

I think you must to adapt your code perl script to generate a functional code like below:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Document>
        <name>BalloonStyle.kml</name>
        <open>1</open>
        <Style id="exampleBalloonStyle">
            <BalloonStyle>
                <!-- a background color for the balloon -->
                <bgColor>ffffffbb</bgColor>
                <!-- styling of the balloon text -->
                <text>
                <![CDATA[
                    <b><font color="#CC0000" size="+3">$[name]</font></b>
                    <br/><br/>
                    <font face="Courier">$[description]</font>
                    <br/><br/>
                    <h2>$[lineNumber]</h2>
                    <br/>
                    $[location]<br/>
                    Voltage: $[voltage]<br/>
                ]]>
                </text>
            </BalloonStyle>
        </Style>
        <Placemark>
            <name>Path1 placemark name</name>
            <description>Path1 description</description>
            <styleUrl>#exampleBalloonStyle</styleUrl>
            <ExtendedData>
                <Data name="lineNumber">
                    <value>1</value>
                </Data>
                <Data name="location">
                    <value>SF 12345</value>
                </Data>
                <Data name="voltage">
                    <value>1000</value>
                </Data>
            </ExtendedData>
            <LineString>
                <tessellate>1</tessellate>
                <coordinates>
                    -122.3708975328112,37.82092803155179,0 -122.3723545304743,37.82025693997047,0 -122.3734162295538,37.82025718538769,0 
                </coordinates>
            </LineString>
        </Placemark>
        <Placemark>
            <name>Path2 placemark name</name>
            <description>Path2 description</description>
            <styleUrl>#exampleBalloonStyle</styleUrl>
            <ExtendedData>
                <Data name="lineNumber">
                    <value>2</value>
                </Data>
                <Data name="location">
                    <value>SF 67890</value>
                </Data>
                <Data name="voltage">
                    <value>2000</value>
                </Data>
            </ExtendedData>
            <LineString>
                <tessellate>1</tessellate>
                <coordinates>
                    -122.3750690144493,37.82269022258979,0 -122.3738957588522,37.82070181614775,0 
                </coordinates>
            </LineString>
        </Placemark>
    </Document>
</kml>

This way, you''l have all your lines inside a single kml, using a unique baloon style, and the result can be seen below:

enter image description here

Related Question