How to avoid CSS scrubbing in Google Earth balloons

1.2k views Asked by At

I've been doing a lot of looking around into this issue. I have a project I'm working on which basically represents a tour of different locations, each of which are generated dynamically, in a Google Earth web player. The problem is that the client requires that the content of each placemark representing a location be more stylish. Of course, I quickly discovered that Google Earth maliciously scrubs all CSS that you put in the KMZ file, which is very annoying. Many online discussion talked about putting the !important keyword in the CSS declaration or to use balloon style in some funny ways to prevent this. So far, I have not found a concrete solution.

I simply want to know if there is a hack or a method for Google Earth to not simply remove all of your CSS. That can include importing or inserting CSS from an external source after the page load and/or putting in a litle jQuery if nescessary.I will provide a code template for what a typical balloon should look like. Note that this actually works in the Google Earth program, but not online.

</Placemark>
<Placemark id="placemark1">
  <name>City</name>
  <description>
  <![CDATA[<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
          <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
          <title>Untitled Document</title>
    </head>
    <body>
    <link href="http://localhost/Kmz_Files/player.css>
    <div class="container" >
            <span class = "title">My location</span>
            <hr>
            <div>

    <a href="http://www.google.com" target="_blank">
    <img src="http://www.google.ca/images/srpr/logo3w.png" width="250" /> 
    </a>
            </div>
            <hr>
            <p> My description</p>
    </div>
    </body>
    </html>]]>
    </description>
  <Point>
    <coordinates>-45, 45</coordinates>
  </Point>
</Placemark>
1

There are 1 answers

0
Mano Marks On

Looks like you're talking about the Google Earth Plugin, not the Google Earth desktop application, which does not scrub JavaScript or CSS.

Looks like you want to use getBalloonHtmlUnsafe().