1

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

  • Have you compared a manually-created example with your script's output? Also check the KML reference: developers.google.com/kml/documentation/kmlreference – blah238 Mar 7 '14 at 19:02
  • I have compared the KML that I am creating to merging data into a folder manually through Google Earth. I see no difference :/ Checking out your link now. Thanks! – MaryBeth Mar 7 '14 at 19:43
1

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

| improve this answer | |
  • Unfortunately, that didn't work. Tried both grouping the documents all together, instead of having separate tags for each line and adding the extra code in for formatting the balloon. It just seems that my data is not being read and I cannot figure out why. But when I look at the properties none of my attributes show up. I'm assuming that there is something else missing somewhere in the code, but cannot find it when comparing the manually created data to the perl created data. – MaryBeth Mar 10 '14 at 14:04
  • Can you upload your manually created data and the created perl data on dropbox, and then only to share the public link? This way will rise the chances to identify the issue. – Sorin Călinică Mar 10 '14 at 15:01
  • Without stripping out all of the data, I cannot. – MaryBeth Mar 10 '14 at 15:16
0

Figured it out...though not 100% sure on the logic behind it, but I changed up the StyleMap tags (gray highlighted piece) for Style Tags (second snippit):

Sample XML

| improve this answer | |
0

The StyleMap tag controls the behavior when you mouse over the element.

"A <StyleMap> maps between two different Styles. Typically a <StyleMap> element is used to provide separate normal and highlighted styles for a placemark, so that the highlighted version appears when the user mouses over the icon in Google Earth."

https://developers.google.com/kml/documentation/kmlreference#stylemap

Not clear from your original example, but the problem seems to have been in the StyleMap, not the BalloonStyle.

I did a quick search on CPAN figuring there would be a Perl KML module. Doesn't seem to be much support for it, though.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.