我正在尝试将默认的黄色PIN位置标记更改为矩形或像素。运行下面的代码后,我仍然得到默认的黄色PIN位置标记。
import simplekml
#from simplekml import Shape,Color
kml = simplekml.Kml()
pt2=kml.newpoint(name="test", coords=[(18.432314,-33.988862)])
#both code below are not working.
pt2.style.iconstyle.icon.shape='rectangle'
pt2.style.iconstyle.shape='rectangle'
pt2.style.iconstyle.color='ffffff00'
kml.save("test.kml")发布于 2020-08-01 22:14:21
要更改图标的形状,请更改iconstyle的href属性,该属性是图标的URL。可以看到在谷歌地球显示的here中使用的图标列表。
在上面的代码中,"shape“既不是图标的属性,也不是图标样式的一部分。图标和图标样式属性的结构由KML spec定义。
更新代码以输出具有自定义图标样式的KML:
import simplekml
kml = simplekml.Kml()
pt2 = kml.newpoint(name="test", coords=[(18.432314,-33.988862)])
# use square icon
pt2.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/placemark_square.png'
# set color of icon to be cyan (RGB=#00ffff)
pt2.style.iconstyle.color ='ffffff00' # aabbggrr
print("Output: test.kml")
kml.save("test.kml")https://stackoverflow.com/questions/60259019
复制相似问题