Just wondering if it is possible to style a pop-up balloon via an external/linked .css file, rather than inline styles ?
3
votes
2 Answers
3
votes
What I generally do is create a BalloonStyle for my placemark balloons that contains a wrapper div with a CSS class like earth-balloon, which can then be styled directly from within the containing page.
For example, the KML would look like:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="foo">
<BalloonStyle>
<text><![CDATA[
<div class="earth-balloon">
$[description]
</div>
]]></text>
</BalloonStyle>
</Style>
<Placemark>
<styleUrl>#foo</styleUrl>
<name>Bar</name>
<description><![CDATA[
Some <em>HTML</em> here.
]]></description>
<Point>
<coordinates>-122,37</coordinates>
</Point>
</Placemark>
</Document>
</kml>
the containing page itself could look like:
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css"/>
<!-- Earth API stuff goes here -->
</head>
<body>
<div id="map3d"></div>
</body>
</html>
and your styles.css could then style the balloon for Placemarks with styleUrl = #foo via rules like:
.earth-balloon {
font-family: Georgia, serif;
}
.earth-balloon em {
color: red;
}
Hope that helps!