只想知道是否可以通过外部/链接的.css文件而不是嵌入式样式来设置弹出气球的样式?
最佳答案
我通常要做的是为我的地标气球创建一个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;
}
希望有帮助!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。