【发布时间】:2009-07-29 18:46:19
【问题描述】:
只是想知道是否可以通过外部/链接的.css 文件而不是内联样式来设置弹出气球的样式?
【问题讨论】:
标签: css kml google-earth google-earth-plugin
只是想知道是否可以通过外部/链接的.css 文件而不是内联样式来设置弹出气球的样式?
【问题讨论】:
标签: css kml google-earth google-earth-plugin
我通常做的是为我的地标气球创建一个 BalloonStyle,其中包含一个包装器 div 和一个 CSS 类,如 earth-balloon,然后可以直接在包含页面内设置样式。
例如,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 的地标设置气球样式:
.earth-balloon {
font-family: Georgia, serif;
}
.earth-balloon em {
color: red;
}
希望有帮助!
【讨论】:
是的,我过去曾这样做过,这可能非常棘手。您需要使用 firebug 来确定需要获取的选择器,并且在您的 CSS 中,您必须非常具体地覆盖它们,有时您甚至可能必须在规则上使用 !important。
娜塔莉
【讨论】: