只是想知道是否可以通过外部/链接的.css文件来设计弹出气球的样式,而不是内联样式?
发布于 2009-08-12 15:54:12
我通常要做的是为我的placemark气球创建一个BalloonStyle,其中包含一个带有earth-balloon类的包装器div,然后可以直接从包含的页面中设置样式。
例如,KML将如下所示:
<?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>包含页面本身可能如下所示:
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css"/>
<!-- Earth API stuff goes here -->
</head>
<body>
<div id="map3d"></div>
</body>
</html>然后,您的styles.css可以通过以下规则使用styleUrl = #foo为Placemarks设置气球样式:
.earth-balloon {
font-family: Georgia, serif;
}
.earth-balloon em {
color: red;
}希望这能有所帮助!
发布于 2009-07-30 10:22:11
是的,我以前也这样做过,这可能是相当棘手的。你需要使用firebug来找出你需要获取的选择器,并且在你的CSS中,你必须非常具体地覆盖它们,有时你甚至可能不得不使用!重要的规则。
娜塔莉
https://stackoverflow.com/questions/1202265
复制相似问题