【问题标题】:Making Pop out Bubble in KML Files larger使 KML 文件中的弹出气泡变大
【发布时间】:2021-07-23 17:35:32
【问题描述】:

有没有办法让 KML 文件中的弹出气泡变大?目前我已经显示了信息。但它并不干净。如果所有粗体项目都在左侧,它会看起来更干净。有点困惑,因为如果我玩弄宽度,这是有道理的,什么都没有改变。想法?建议添加?

#Define the Objects within the Plot Line Chart
def PlotLineChart(myKml, latList, lonList, heightList=[], name="", descriptionList="", color="", width=5):
    """
    Plot Line Chart
    """
    descriptionString = ''
    for desc in descriptionList: 
        descriptionString += (desc + '\n')
        
        print(descriptionString)
        
    ls = myKml.newlinestring(
        name=name,
        description=descriptionString
    )
    coords = []
    if len(heightList) == 0:
        for (lat, lon) in zip(latList, lonList):
            coords.append((lon, lat))
    else:
        for (lat, lon, height) in zip(latList, lonList, heightList):
            coords.append((lon, lat, height))

    ls.coords = coords
    ls.extrude = 1
    ls.altitudemode = simplekml.AltitudeMode.relativetoground
    ls.style.linestyle.width = width
    ls.style.linestyle.color = GetColorObject(color)

Pc

【问题讨论】:

  • 您在哪个平台上查看 KML?谷歌地球专业版?地球网络/移动?谷歌地图?其他 KML 查看器?他们中的大多数会尊重 HTML 内容的基本大小,并展开气球以适应。如果您可以提供您的 KML 样本,我们或许能够更有效地建议技术和细节。
  • @ChristiaanAdams 使用 Google 地球专业版。 'PC' 上面是项目的图像 - 在代码下

标签: python kml


【解决方案1】:

看起来您正在尝试将信息气球描述部分中的属性很好地格式化为列表(不一定只是让气球变大)。

一种简单的方法是在每一行之后添加一个 HTML 换行符(<br> 标记)。

您可以通过将desc + '\n' 替换为desc + '<br>' 来实现这一点,这应该会导致每个地标的KML 看起来像这样:

<Placemark>
  <name>Charley</name>
  <description><![CDATA[
    <b>Storm Classification:</b> Hurricane<br>
    <b>Start Date:</b> 08/09/2004<br>
    <b>End Date:</b> 08/15/2004<br>
    <b>Max Wind Speed:</b> 149 mph<br>
    <b>Minnimum Pressure:</b> 941 mb
  ]]></description>
...

请注意,如果您将 HTML 标记放在描述中,最好将整个描述包含在 CDATA 标记中:

<description><![CDATA[  ...your content with <tags> here... ]]></description>

这应该会产生一个看起来像这样的气球:

有关构建 KML 气球内容的更多信息,请参阅此处的抽象“Feature”元素的 KML 文档: https://developers.google.com/kml/documentation/kmlreference#feature 并向下滚动到关于&lt;description&gt; 标记内容的长部分。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多