Customizing KML Placemark with TemplatesΒΆ

In KML, each entry in a data set is represented with a placemark. A placemark has a title and a description which is shown in a pop-up bubble when the placemark is clicked on. With templates placemark titles and descriptions can be easily customized. This section covers the task of creating custom title and description templates.

  1. Open the following link to open the storm_obs layer in superoverlay mode:



If Google Earth will not automatically open, go to the system default download folder and double click on the downloaded kml file geosolutions-storm_obs.kml. Zoom-in if you don’t see the storm-obs layer.

  1. In Google Earth click on a placemark.


    Viewing the default placemark description

  2. On the file system navigate to the GeoServer data directory located at %TRAINING_ROOT%\geoserver_data\ on Windows or ${TRAINING_ROOT}/geoserver_data/ on Linux.


You have to use slash ( / ) instead of backslash ( \ ) on Linux paths, when this one is the unique difference, the linux paths will not be described in this chapter.

  1. In the workspaces\geosolutions\storms\storm_obs directory create a new filed named title.ftl.


    Creating a title template


    The title.ftl is a template that will be used to render the title of a placemark

  2. Open title.ftl in the plain text editor of your choice (f.e. notepad) and enter the following content:

    Hurricane ${storm_name.value}


    The above template content inserts the value of the storm_name attribute. When the template is rendered it will dynamically create a title that is the name of the hurricane.


    Creating title template content

  3. In Google Earth refresh the view by expanding stom_obs.kmz under “Temporary places”, right clicking on geosolutions:storm_obs, and clicking on the refresh menu item:


    Forcing the refresh of a KML tree

  4. Click on a placemark to see the new template in action:


    Viewing a custom placemark title

  5. In the same directory as title.ftl create a file named description.ftl. Open the file and enter the following content:

    <img src="http://localhost:8083/geoserver/www/hurricane_warning.png"></img>
    On <b>${obs_datetime.value}</b> hurricane ${storm_name.value} was recorded to have a wind speed of <b>${wind.value}</b> mph.


    The above template renders some HTML that contains a static image of a hurricane warning, as well as creates a paragraph of text describing in sentence form some information about the specific storm observation.


    Creating description template content

  6. Save description.ftl and refresh the view in Google Earth.


    Viewing a custom description placemark description

In this section templates were used to customize placemark visualization. In the next few sections the use of templates for other visualization purposes will be explored.