Google Earth插件中的CSS

前端之家收集整理的这篇文章主要介绍了Google Earth插件中的CSS 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

只想知道是否可以通过外部/链接的.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;
}

希望有帮助!

原文链接:https://www.f2er.com/css/530727.html

猜你在找的CSS相关文章