I'm using simple_kml
library to generate a kml file with data sent from drawing manager
on google Maps using Javascript, everything goes fine except the color of the shape .. the color send in this format #ec0909
, and here is how am trying to add it to the shape:
ls = kml.newlinestring(name="Polyline")
ls.coords = [(latlng['lng'], latlng['lat']) for latlng in shape['coordinates']]
ls.description = shape['info_box']
print(f"THE COLOR IS {color_code}") #returns #ec0909
ls.style.polystyle.color = color_code
as you see the color should be red .. but it is shown as blue/red shaded color.
color_code
needs to not contain the pound sign character; your comment makes it seem like that string is#ec0909
but it needs to beec0909
. Beyond that, you’re working on akml.LineString
object and not akml.Polygon
object, so I think you need to set the color usingls.style.linestyle.color
instead ofls.style.polystyle.color
.Hope that helps,
—K
EDIT: see more here and consider you may need to convert a hex string using
kml.Color.hex()
in your assignment, or include alpha codes to makecolor_code
into the stringec0909ff
.