Building KML Popup Balloons - Info Window Builder

Info Window Builder

The new Info Window Builder in the KML Exporter allows you to visualize your layer's KML Popup Balloons with existing data while you are authoring them. Additionally, it contains a new Django-like template engine giving you far more control and flexibility with variable data in each feature's popup balloon.

Getting Started

Each layer for you KML export must have Info Window creation turned on before any popup balloon will appear in the export. By default, point layers are turned on while all other layers must be manually set. To turn on Info Window creation, go to each layer's "Info Window" tab and check the top option ("Create Popup Balloons for this Layer")

Select to use the Simple Template (a simple list of fields, no styling) or for custom HTML layout, use the Advanced Template. Click on the "Edit Template" button to open the new Info Window builder.

If this is the first time you are creating a template for the current layer, it will prompt you to create a default template. This will add all fields from the layer into a simple HTML table automatically. You can edit this table immediately after it is created using any valid HTML tags and styles (note - not all KML viewers will display this correctly if you use advanced tags)

You can click on the Preview tab to see how the HTML will be displayed. Use the left sidebar buttons (<< and >>) to switch the feature record to use for the preview.

Building Templates

The template consists of HTML markup and custom tokens that are replaced with actual feature data when the export occurs. A token is made up of two section that are surrounded by the special token characters "[!' and "]". Use the pipe character ("|") to separate the two section or use the dropdowns to add it automatically.

  1. The first section is the field name and it must match the exact field name used in the layer's field collection. (e.g. [!MyFieldName])
  2. The second, optional section is the filter. These custom values tell the template engine how to format the value that is retrieved for each feature's fields. (e.g. [!MyFieldName|upper] - make the field value upper case)
  3. Some filters require a third section that act as parameters for the filter (e.g. [!MyFieldName|yesno|Yes,No,N/A] -> for values that evaluate to True use "Yes", for False use "No" and for no data use "N/A")

Available Filters

  1. lower - Lower Case all letters in the field
  2. upper - Upper Case all letters in the field
  3. capfirst - Capitalize the first letter
  4. title - Use Title Case for all words in the field (ex: MY FIELD TEXT -> My Field Text)
  5. urlize - Wrap the field value with an HTML anchor (ex: http:/ -> <a href="http:/">http:/</a>)
  6. date - Format field as a date (ex: [!MyDateField|date|SHORT_DATE_FORMAT] -> 1/1/2010 For date and time values, use the standard filter options of DATE_FORMAT, DATETIME_FORMAT, SHORT_DATE_FORMAT, SHORT_DATETIME_FORMAT, TIME_FORMATor use custom ones using these formats )
  7. time - Format field as a time (ex: [!MyDateField|date|TIME_FORMAT] -> 12:35AM)
  8. cut - Replace the filter option with specific values
  9. default - Use this value for all null data
  10. stringformat - Format numbers and strings (see more here)
  11. floatformat - Format floating point numbers
  12. yesno - Replace field values that evaluate to True/False with custom text values (ex: [!MyFieldName|yesno|Yes,No,N/A])
  13. pluralize - Add custom prefix and suffix to field values based on value. For example, the field contains numeric values that you would like to display as text. Field contains "3" and the token is Cherr[!MyNumericField|pluralize|y,ies] the result will be Cherries. If the value is "1", the result would be Cherry
  14. truncatewords - remove all words after the specified limit (ex [!MyTextField|truncatewords|25])
  15. linebreaks - replace linebreaks in text with HTML break characters (<br>)
  16. compare (new as of 9/9/11) - compare attribute value with known value and replace with True and False text chunks (that can contain html markup) [!fieldname|compare:operator, valueToCompareWith, TrueText, FalseText]

the "compare" filter takes uses an operator (=,!=,* for strings and =,!=,<,>,<=,>= for numbers) and value to compare the attribute field against. You then provide text values for the true/false results. This allows you to prepend/append or replace any attribute value based on the comparison.

[!fieldname|compare:operator, valueToCompareWith, TrueText, FalseText]

For example, to get a +/- in front of number you could use:
[!field|compare:>=,0,+,-] [!field]

or if you wanted to use images instead:
[!field|compare:>=,0,<img src='' />,<img src=''/>] [!field]

Tag Insert Windows

There are couple of helper windows on the top toolbar for adding common HTML tags to your template. Each will insert HTML text directly into the template where ever the current cursor is located.

Insert Image Tool

The Insert Image tool allows you to select an internet based Url or a local image file for your template. If a local file is selected, it is automatically added to the final KMZ archive and the reference is updated.

Insert Link Tool

The Insert Link tool allows you insert hyperlink tags that use attribute values in the Url. For instance, if you have field that contains feature IDs that can be used with an external website, you can use create links that will be populated with that value.

Insert Frame Tool

The Insert Frame tool allows you to add an IFrame tag that points to en external webpage. Use the attribute values in the frame's url to determine which page to load