AttributeError:“Kml”对象没有属性“style”

问题描述 投票:0回答:1

我正在学习如何使用 simplekml,但我很难在某个点上添加特定图标。

这是我的代码:

import simplekml
points_kml = simplekml.Kml()
points_kml.newpoint(name="Kirstenbosch", coords=[(18.432314,-33.988862)])
points_kml.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/paddle/ltblu-circle.png'
points_kml.save("botanicalgarden.kml")

这就是我收到的回报:

  File c:\users\marcelo\downloads\untitled0.py:4
    points_kml.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/paddle/ltblu-circle.png'

AttributeError: 'Kml' object has no attribute 'style'

我仔细检查了文档和图标链接,但一切都与文档中显示的完全一样......

我只想要一个带有单个点和特定图标的 kml 文件。

python kml google-earth simplekml
1个回答
0
投票

该错误告诉您需要了解的内容。

Kml
对象上没有
style

看着这些文档您可能想引用一个观点?

这些文档中的一些代码

pnt.style.iconstyle.icon.href = None

并创建一个点

pnt = kml.newpoint(name="Kirstenbosch", description="A botanical Garden",
                   coords=[(18.432314,-33.988862)])  # lon, lat optional height
© www.soinside.com 2019 - 2024. All rights reserved.