使 KML 文件中的弹出气泡变大

问题描述

有没有办法让 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,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

解决方法

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

一种简单的方法是在每行之后添加一个 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>

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

enter image description here

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...