1

I'm using simplekml to plot some data.

As I can have a lot of points I'm using sharedstyle, but the problem is that I can't any style paraneter between every point (as the icon scale or the balloosstyle text).

So, I have my sharedstyle

kml = simplekml.Kml()
    fol = kml.newfolder(name="Eventos")
    sharedstyle = simplekml.Style()
    sharedstyle.labelstyle.color = 'ffffffff'
    sharedstyle.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/target.png'
    sharedstyle.iconstyle.color = 'ff0000ff'
    sharedstyle.balloonstyle.bgcolor = simplekml.Color.lightgreen
    sharedstyle.balloonstyle.textcolor = simplekml.Color.rgb(0, 0, 255)

I read the data on a loop and I call for every point I need to create this method

def add_to_kml(folder, event, style):

    coord = (event.lon, event.lat)
    label = event.date.isoformat()
    pnt = folder.newpoint(name="{0}".format(label), coords=[coord])
    pnt.style = style
    pnt.style.iconstyle.scale = event.scale
    pnt.style.balloonstyle.text = "{0}, \n {1}".format(event.label, event.geo_ref)

But, every single point ploted has the same iconscale and balloonstyle.text (the corresponding to the last added point)

Is there a way to modify some style data while using shared style?

CodeMonkey
  • 22,825
  • 4
  • 35
  • 75
Pablo V.
  • 324
  • 2
  • 16

1 Answers1

0

Only in a very limited sense. Styles are not hierarchical, they replace each other. But...

The balloonstyle text can use variables that refer the element it is refering to ($[name], $[description], $[address], $[id], $[Snippet]). So you can put your individual info into e.g. the description and use it in the balloon.

Hope it helps!

DirkR
  • 488
  • 2
  • 9