Updating KML Balloon Contents & Removing "Directions"

Liz Sanderson
Liz Sanderson
  • Updated

Introduction

By default, a KML balloon will contain links "Directions to Here" and "Directions from Here" (driving directions). This demo demonstrates how to remove these links from the balloon and use HTML to set KML Balloon content, including URL links and images such as PNGs, JPEGs, and TIFFs.

Requirements

Google Earth (for viewing output)

Source Data

SourceData.png

Step-by-step Instructions

1. Read in FireHalls.gml

Open FME Workbench and start a blank workspace. Add an OGC GML reader and select the FireHalls.gml dataset. 

GMLReader.png

2. Reproject to LL84

Next, add a CsmapReprojector transformer to the canvas and connect it to the FireHalls reader feature type. In the parameters, set the Destination Coordinate System to LL84. The coordinate system needs to be changed because KML only supports latitude/longitude coordinates.

CsmapReprojector.png

3. Remove “Directions” from KML Balloons

To remove the direction links from the balloons, a KML attribute needs to be created. To do that, add an AttributeCreator to the canvas and connect it to the CsmapReprojector. In the parameters, create a New Attribute called kml_balloonstyle_text. This is a KML specific style element, for more information on KML elements see the documentation.

For the Attribute Value, set the value to $[description], which tells Google Earth to only use the description for the feature balloon rather than the default, which contains the links for "Directions to Here" and "Directions from Here".

AttributeCreator.png

4. Write to OGC/Google KML

To test that the directions were removed successfully, we need to export the data to Google KML and then view the KML file in Google Earth. Add an OGC/Google KML Writer to the canvas, and then name the Dataset FireHallsOutput.kml, ensuring this file is saved in the same folder as the JPEG images. 

KMLWriter.png

5. Run the Translation

Connect the FireHalls writer feature type to the AttributeCreator. Run the translation and then open up the folder containing the new FireHalls.kml file. Open the file in Google Earth to view the results.

RemovedDirections.png

6. Set Description Balloon HTML Content

Now that we know the directions have been removed, we can make the description balloon more useful by adding images.

Add a KMLPropertySetter to the canvas and connect it between the AttributeCreator and the FireHalls writer feature type. The KMLPropertySetter will set the HTML content for the balloon by specifying a link to the Firehall location in Google Maps as well as a photo of the Firehall if it is available. In the KMLPropertySetter parameters set the Name to the attribute Name, and the Summary to the attribute Address, this information is already contained within the FireHalls.gml dataset.

Next, set the Content Type to HTML, and then for the Content, copy and paste the following HTML code:

<h4>@Value(Name)</h4>
This facility is located at <a href="http://maps.google.com/maps?q=@YValue(),@XValue()">@Value(Address), Vancouver, BC</a>
<img src="@Value(HallNumber).jpg">

This HTML uses the X and Y values as well as the address and then embeds them into a Google Maps URL. It will also use the images that are saved in the same folder as the workspace that corresponds to the Hall Number with the appropriate image. Finally, set the Include Attribute Table to No, then click OK.

KMLPropertySetter.png

HTMLContent.png

Note that the image name can be given without a path, as the output is being written to the same folder where the image files reside. Otherwise, this would need to be given the full path. Specifying the name or full path only works with local drives. If you are using a network drive, you will need to specify the images under the Additional Files section. Please refer to the documentation for additional information on using files in FME.

7. Rerun the Workspace

Rerun the workspace and view the updated KML in Google Earth to view the new balloon description with images.

FinalOutput.png

Data Attribution

The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.