无法在 Google 地球气球文本中加粗

Unable to bold in Google Earth Balloon Text

我正在尝试使用 KML 格式化 Google 地球上气球中的文本。无论我尝试哪种 html/css 技巧,我都无法将文本设为粗体。下面的示例演示了我能够将文本格式设置为 Arial Black,但应用 font-family:'Arial Bold' 没有任何效果。 <b> 标签也不起作用。示例中未显示,我也尝试了 <strong>font-weight:bold

此屏幕截图显示了以下代码在 Google 地球中的呈现方式。文本 "Unformatted Text" 与文本 "Arial Bold" 和 "b tag" 具有相同的字体粗细,应该是粗体。但是,"Arial Black" 文本按预期呈现为 Arial Black。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>Format Test</name>
    <Style id="test-style">
      <BalloonStyle>
        <text>
          <p style="font-family:'Arial Black';">Arial Black</p> 
          <p style="font-family:'Arial Bold';">Arial Bold</p> 
          <p>This text has a <b>b tag</b></p>
          <p>Unformatted Text</p>
        </text>
      </BalloonStyle>
    </Style>
    <Placemark>
      <name>Test Placemark</name>
      <description><![CDATA['test']]></description>
      <Point>
        <coordinates>
          -76.0,40.0,0
        </coordinates>
      </Point>
      <styleUrl>#test-style</styleUrl>
    </Placemark>
  </Document>
</kml>

相关question/example:Using <BaloonStyle> and <LableStyle> together

您不想对样式进行实体编码。即

&lt;p style="font-family:'Arial Black';"&gt; Arial Black &lt;/p&gt;

应该是:

<p style="font-family:'Arial Black';"> Arial Black </p>

这应该符合您的预期:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <name>Format Test</name>
    <Style id="test-style">
      <BalloonStyle>
        <text><![CDATA[<b><font size="+2">$[name]</font></b>
          <br/><br/><font face="Arial Black">$[description]</font><br/>
          <br/>Some other text<br/>
          <b>Some bold text</b><br/>]]>
        </text>
      </BalloonStyle>
    </Style>
    <Placemark>
      <name>Test Placemark</name>
      <description><![CDATA['test']]></description>
      <Point>
        <coordinates>
          -76.0,40.0,0
        </coordinates>
      </Point>
      <styleUrl>#test-style</styleUrl>
    </Placemark>
  </Document>
</kml>

您的示例 KML 似乎大部分对我有用,即使使用了编码,在 Google Earth 中应该可以很好地解码。我得到了如下所示的气球……在地球专业版 v7(左)和地球网络版 v9(右)中。

这表明 style="font-family:'Arial Black';"<b> 标签都是粗体文本。 style="font-family:'Arial Bold';" 没有显示为粗体,但我相信那是因为 'Arial Bold' 是一种不常见的字体,并且似乎只被某些浏览器支持。

也许您正在寻找的是单独的字体粗细 属性,如下所示:

<p style="font-family:'Arial'; font-weight:'bold'">Arial font, bold weight</p>

我还注意到您的 BalloonStyle/text 标签中没有 $[description] 引用变量,因此您的描述文本未包含在气球中。

您是在哪个版本的 Earth 中看到这个问题的...您可以提供屏幕截图吗?