Styles¶
Style¶
-
class
simplekml.Style(iconstyle=None, labelstyle=None, linestyle=None, polystyle=None, balloonstyle=None, liststyle=None)¶ Styles affect how Geometry is presented.
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() pnt = kml.newpoint(name='A Point') pnt.coords = [(1.0, 2.0)] pnt.style.labelstyle.color = simplekml.Color.red # Make the text red pnt.style.labelstyle.scale = 2 # Make the text twice as big pnt.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png' kml.save("Style.kml")
-
balloonstyle¶ The balloonstyle, accepts
simplekml.BalloonStyle.
-
iconstyle¶ The iconstyle, accepts
simplekml.IconStyle.
-
id¶ The id of the style, read-only.
-
labelstyle¶ The labelstyle, accepts
simplekml.LabelStyle.
-
linestyle¶ The linestyle, accepts
simplekml.LineStyle.
-
liststyle¶ The liststyle, accepts
simplekml.ListStyle.
-
polystyle¶ The polystyle, accepts
simplekml.PolyStyle.
-
StyleMap¶
-
class
simplekml.StyleMap(normalstyle=None, highlightstyle=None)¶ Styles affect how Geometry is presented.
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() pnt = kml.newpoint(coords=[(18.432314,-33.988862)]) pnt.stylemap.normalstyle.labelstyle.color = simplekml.Color.blue pnt.stylemap.highlightstyle.labelstyle.color = simplekml.Color.red kml.save("StyleMap.kml")
-
highlightstyle¶ The highlighted
simplekml.Style, acceptssimplekml.Style.
-
id¶ The id of the style, read-only.
-
normalstyle¶ The normal
simplekml.Style, acceptssimplekml.Style.
-
BalloonStyle¶
-
class
simplekml.BalloonStyle(bgcolor=None, textcolor=None, text=None, displaymode='default')¶ Specifies the content and layout of the description balloon.
The arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() pnt = kml.newpoint(name="BallonStyle", coords=[(18.429191, -33.987286)]) pnt.style.balloonstyle.text = 'These are trees and this text is blue with a green background.' pnt.style.balloonstyle.bgcolor = simplekml.Color.lightgreen pnt.style.balloonstyle.textcolor = simplekml.Color.rgb(0, 0, 255) kml.save("BalloomStyle.kml")
-
bgcolor¶ Background color of the balloon, accepts hex string.
-
displaymode¶ How the balloon is tyo be displayed, accepts string from
simplekml.DisplayModeconstants.
-
id¶ The unique id of the substyle.
-
text¶ The actual text that will appear in the balloon, accepts string.
-
textcolor¶ Text color in the balloon, accepts hex string.
-
IconStyle¶
-
class
simplekml.IconStyle(scale=1, heading=0, icon=None, hotspot=None, **kwargs)¶ Specifies how icons for point Placemarks are drawn.
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() pnt = kml.newpoint(name='A Point') pnt.coords = [(1.0, 2.0)] pnt.style.iconstyle.scale = 3 # Icon thrice as big pnt.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/info-i.png' kml.save("IconStyle.kml")
-
color¶ Hex string representing a color, accepts string.
-
colormode¶ How the color is to be used, string from
simplekml.ColorModeconstants.
-
heading¶ Rotation of the icon, accepts float.
-
hotspot¶ Anchor position inside of the icon, accepts
simplekml.HotSpot.
-
icon¶ The actual
simplekml.Iconto be displayed, acceptssimplekml.Icon.
-
id¶ The unique id of the substyle.
-
scale¶ Size of the icon, accepts float.
-
LabelStyle¶
-
class
simplekml.LabelStyle(scale=1, **kwargs)¶ Specifies how the name of a Feature is drawn.
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() pnt = kml.newpoint(name='A Point') pnt.coords = [(1.0, 2.0)] pnt.style.labelstyle.color = simplekml.Color.red pnt.style.labelstyle.scale = 2 # Text twice as big pnt.style.labelstyle.color = simplekml.Color.blue kml.save("LabelStyle.kml")
-
color¶ Hex string representing a color, accepts string.
-
colormode¶ How the color is to be used, string from
simplekml.ColorModeconstants.
-
id¶ The unique id of the substyle.
-
scale¶ Size of the icon, accepts float.
-
LineStyle¶
-
class
simplekml.LineStyle(width=None, gxoutercolor=None, gxouterwidth=None, gxphysicalwidth=None, gxlabelvisibility=None, **kwargs)¶ Specifies the drawing style for all line geometry.
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() lin = kml.newlinestring(name="Pathway", description="A pathway in Kirstenbosch", coords=[(18.43312,-33.98924), (18.43224,-33.98914), (18.43144,-33.98911), (18.43095,-33.98904)]) lin.style.linestyle.color = simplekml.Color.red # Red lin.style.linestyle.width = 10 # 10 pixels kml.save("LineStyle.kml")
-
color¶ Hex string representing a color, accepts string.
-
colormode¶ How the color is to be used, string from
simplekml.ColorModeconstants.
-
gxlabelvisibility¶ Whether or not to display a text label.
-
gxoutercolor¶ Outer color of the line, accepts string.
-
gxouterwidth¶ Outer width of the line, accepts float.
-
gxphysicalwidth¶ Physical width of the line, accepts float.
-
id¶ The unique id of the substyle.
-
width¶ Width of the line, accepts float.
-
ListStyle¶
-
class
simplekml.ListStyle(listitemtype='check', bgcolor=None, itemicon=None)¶ Specifies the display of the elements style in the navigation bar.
The arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() fol = kml.newfolder(name='Folder') fol.style.liststyle.listitemtype = ListItemType.radiofolder fol.style.liststyle.itemicon.href = 'http://maps.google.com/mapfiles/kml/shapes/info.png' kml.save("ListStyle.kml")
-
bgcolor¶ The background color of the item, accepts a hex string.
-
id¶ The unique id of the substyle.
-
itemicon¶ An instance of an
simplekml.ItemIconclass, acceptssimplekml.ItemIcon.
-
listitemtype¶ How an item is diaplyed, accepts string from
simplekml.ListItemTypeconstants.
-
PolyStyle¶
-
class
simplekml.PolyStyle(fill=1, outline=1, **kwargs)¶ Specifies the drawing style for all polygons.
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() pol = kml.newpolygon(name="Atrium Garden", outerboundaryis=[(18.43348,-33.98985),(18.43387,-33.99004),(18.43410,-33.98972), (18.43371,-33.98952),(18.43348,-33.98985)], innerboundaryis=[(18.43360,-33.98982),(18.43386,-33.98995),(18.43401,-33.98974), (18.43376,-33.98962),(18.43360,-33.98982)]) pol.style.polystyle.color = simplekml.Color.red pol.style.polystyle.outline = 0 kml.save("PolyStyle.kml")
-
color¶ Hex string representing a color, accepts string.
-
colormode¶ How the color is to be used, string from
simplekml.ColorModeconstants.
-
fill¶ Must the polygon be filled, accepts int of 0 or 1.
-
id¶ The unique id of the substyle.
-
outline¶ Must the polygon be outlined, accepts int of 0 or 1.
-