0

I am trying to change the default Yellow Push-PIN place marker to rectangle or pixel. after running code below I still getting default Yellow Push-PIN place marker.

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")
Issac_n
  • 89
  • 1
  • 2
  • 13

1 Answers1

1

To change the shape of the icon, change the href property of the iconstyle which is the URL of the icon. Can see a list of icons for use in Google Earth displayed here.

In posted code above, "shape" is not a property of icon nor is it a part of iconstyle. The structure of the icon and iconstyle property is defined by the KML spec.

Updated code to output KML with a custom icon style:

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")
CodeMonkey
  • 22,825
  • 4
  • 35
  • 75