Using Parameter Presets

Parameter Presets are a simple but powerful feature to keep the "look and feel" of your Track Maps consistent throughout your website - even if you have several different types or styles of maps. They also allow for easy changes later on, after you have put many Track Maps into many different articles. Use them!

 

 

1. Preset Definition 

To use Parameter Presets, you first have to define them - you can do this in the Plugin options, like so:

gtm-parampresets

(These are actually the exact settings i have used for the maps in the "Examples")

 

2. Preset Syntax

  • each line must exactly follow this syntax:  

<presetname>:<param=value>[,<param=value>][,<param=value>][...]

  • the Preset Name must not include blank spaces, or any other "funky" characters: just the basic letters (a-z) or digits (0-9)
  • Presets may go across multiple lines (as in the example above). If they do, each new line must again begin with the Preset Name followed by a ":" (this is nice if you're on a low resolution monitor, where the single lines in the text box would wrap otherwise)
  • If a parameter is set more than one time inside a single preset, the last found setting will "win" 

 

3. Preset usage

In the invocation code, you can use presets like this:

{gpxtrackmap}track.gpx,preset=ex1{/gpxtrackmap}

(If you're a really lazy typer (like i am), you may also use "ps=" instead of "preset=" in the invocation.) 

 

4. Using multiple presets

Let's assume you want two types of Track Maps on your site: big ones and small ones. You define the following Presets in the plugin options: 

minimap:mapwidth=100px,mapheight=100px

bigmap:mapwidth=500px,mapheight=500px

nomarkers:startmarker=0,endmarker=0

redmarkers:startmarker=red,endmarker=red  

Now you can combine the Presets in the invocation by chaining their names with a "-" dash (minus sign):

{gpxtrackmap}route1.gpx,preset=minimap-nomarkers{/gpxtrackmap} or:

{gpxtrackmap}route2.gpx,preset=bigmap-redmarkers{/gpxtrackmap}

 

Note: you can NOT do the following - this will NOT work as you may expect: 

{gpxtrackmap}route2.gpx,preset=bigmap,preset=redmarkers{/gpxtrackmap}

If you write it like this, the "bigmap" preset will be ignored, and only the "redmarkers" preset (i.e. the last one found) will be applied!

 

5. Combining Presets with Individual Parameters

You can also use combinations of presets intermixed with individual parameters in the invocation, like this:

{gpxtrackmap}route2.gpx,startmarker=0,preset=bigmap-redmarkers{/gpxtrackmap}

But note the following rule:

Individual Parameters always "win" over Preset Parameters!

In the example above, this means that your map will have no start marker, even though the "redmarkers" Preset sais so - and even though the preset is listed after the individual setting(!).

 

6. Order of evaluation

To make this more clear - the plugin will always apply any parameters in the following order:

  1. Apply all the settings from the Plugin options in the Back End
  2. If presets are used in the invocation, apply their settings in the order of appearance (overwriting the settings from the Back End, and also overwriting settings from presets that where applied before(!))
    If Presets go across multiple lines, each line is processed in the order it appears.
  3. If individual parameters are set in the invocation, apply them one by one (overwriting settings from the Back End AND those from any of the Presets)

 

7. The big advantage of using Presets

There is a simple, but very strong reason to use Presets: You keep all the settings, even the individual ones, in one central place - the plugin options.

Imagine you have 30 mini-maps spread across your articles, and one day you think like "hmm, 100px is really TOO small" - no problem if you have used Presets: you go to the plugin options and change the definition of the "minimap" preset to e.g.

minimap:mapwidth=150px,mapheight=150px

Save the plugin options - and you're done! All the "minimaps" in all of your articles will adapt the new settings right away.

If you hadn't used Presets, you would now find yourself opening all those 30 articles, and editing all the invocation parameters in each plugin call, adjusting them one by one (which is error-prone, and chances are high that you will overlook some articles and/or track maps inside them). 

Presets are a really cool feature if you use them right, and i strongly advise to use them - especially if you have many individually styled Track Maps in many articles!