【问题标题】:Add image title to infowindow of KML-point in Python在 Python 中将图像标题添加到 KML 点的信息窗口
【发布时间】:2022-08-19 21:03:26
【问题描述】:
我在信息窗口中创建了一个带有相应图像的 KML 点。
test_point = kml.newpoint(name=\"test_name\", description = \'<img src=\"path/latest_image.jpg\" width=\"500\" height=\"500\" align=\"left\"/>\',coords=[(10,70,100)])
图像显示正确,但我想添加图像的标题和描述。
此外,我想更改显示图像的窗口的背景颜色。
如何插入这些元素?我尝试了几种方法,但我不知道正确的结构。
在此先感谢,感谢您的帮助!
标签:
python
infowindow
google-earth
【解决方案1】:
您可以通过将图像描述格式化为 HTML 表格来强制将图像描述显示在图像下方的信息框中。
信息框的标题使用地标的名称字段,您可以将其用作图像的标题。
import simplekml
kml = simplekml.Kml()
test_point = kml.newpoint(name="test_name",
description = '''<table><tr><td><img src="path/latest_image.jpg"
width="500" height="500" align="left"/></td></tr>
<tr><td>Image caption</table></td></tr></table>''',
coords=[(10,70,100)])
kml.save("test.kml")
您可以通过应用BalloonStyle 进一步自定义信息框。见API。