Question

Set KML Balloon Width


Badge +1
  • Participant
  • 126 replies

I have a KML file with lots of text in the attributes, and the balloon puts this text onto multiple lines. In KML you can set the width of the table in the description tag to make the balloon wider, like this:

<table width='300px'>

Is it possible to do this with FME?


5 replies

Badge +22

I don't think you can with just setting the Include Attribute Table: yes. But I don't see why it wouldn't work if you explicitly set the balloon Content (content type html) and include the table width.

Badge +3

You can set the BalloonStyle using the KMLPropertySetter transformer. However, FME somewhat muddles the Description (= subtext in your Google Earth navigation tree) with the Balloon text, so for that reason, I prefer to set each of these separately using an AttributeCreator.

In your AttributeCreator, create a kml_balloon_raw_text attribute and set it to whatever HTML code you want for your balloon, e.g.:

<table width='300px'> <h3>$[OSADDRESS]</h3> <b>Grid Reference:</b> $[GridRef]<br> ...

0684Q00000ArKgyQAF.png

Badge +1

I don't think you can with just setting the Include Attribute Table: yes.  But I don't see why it wouldn't work if you explicitly set the balloon Content (content type html) and include the table width.

I really didn't want to be fiddling around with the content as the KML writer does such a nice job of that, and the content might change later.

Instead I made a Python shutdown script that searches for the KML file in the fme.macroValues dictionary, opens it and reads the content, inserts the table width, then writes it back to the file:

inFileHandle = open(pathToKML)
content = inFileHandle.read()
inFileHandle.close()
content = content.replace("<table>","<table width='300px'>")
outFileHandle = open(pathToKML,"w")
outFileHandle.write(content)
outFileHandle.close()

I was hoping, however, that one of those "kml_" target attributes that FME provides would refer to the table width.

Badge +1

You can set the BalloonStyle using the KMLPropertySetter transformer. However, FME somewhat muddles the Description (= subtext in your Google Earth navigation tree) with the Balloon text, so for that reason, I prefer to set each of these separately using an AttributeCreator.

In your AttributeCreator, create a kml_balloon_raw_text attribute and set it to whatever HTML code you want for your balloon, e.g.:

<table width='300px'> <h3>$[OSADDRESS]</h3> <b>Grid Reference:</b> $[GridRef]<br> ...

0684Q00000ArKgyQAF.png

I think you'd have to enter your whole table html with attributes, though, wouldn't you? The FME KML writer already does that for you and will update it when you attributes changes. I've got 285 dates that I would have to manually create as html rows.

Badge +3

I think you'd have to enter your whole table html with attributes, though, wouldn't you? The FME KML writer already does that for you and will update it when you attributes changes. I've got 285 dates that I would have to manually create as html rows.

I think you're right @jimo. You either let FME build your balloon, or you do it all manually by building HTML code. If you want something hybrid, your Python solution is a very elegant one.

Reply