Documentation for Geotag v2.2

The Geotag plugin for Wordpress adds some nice geotagging features to your Wordpress weblog like saving positions with your posts and displaying maps in your posts or themes. Geotag uses version 3 of the Google Map API and supports Google Streetview.

Have a look at the Geotag website for examples and new releases.

Installation/Upgrade

Download the latest package from the Geotag website and unzip it. After that you have to copy the whole /geotag folder to the /wp-content/plugins/ folder of your Wordpress directory on your webserver. When the upload has finished, you need to active the plugin at the Wordpress Plugins menu - that's it.

Please note: After updating the Geotag plugin, your options may be set to the default values. Please restore your personal settings and save them once again.

After the installation, the plugin will add the following pages to your admin panel:

The [gmap] Shortcode

Adding a map to our post is quite easy: Whenever you write the term [gmap] in your text, it will be replaced by a Google Map container. If you don't add any options to this shortcode, Geotag will use the default options as set on the Geotag options page and it will display a marker at the position which was saved for the post. You can add as many maps to your post as you like.

If you want to add a map but change the default settings, you can do so by adding one or more options to your [gmap] shortcode. The basic syntax is:

[gmap property1="value" property2="value"]

The box at the post edit page will assist you with the creation of such shortcodes, but you can also write them manually. The latter might be important for you if you want to post an article via email, e.g. from your mobile phone, while you're on the road.

Properties

width="..." Defines the width of the map container. You must add the units px or % to the value.
Example:[gmap width="50%"]
height="..." Defines the height of the map container. You must add the units px or % to the value.
Example:[gmap height="400px"]
type="..." Changes the appearance of the map. Possible values are:
roadmap
satellite
hybrid
terrain
The value static is deprecated. You should use the static property instead as shown below.
Example:[gmap type="terrain"]
static="..." Defines wheter the map should be displayed as an ordinary image with no interactivity. Possible values are:
true
false
Please note that the width and height must be defined in pixels and is restriced to 640x640px.
Example:[gmap static="true"]
control="..." Sets the map controls which should be visible. You may use the following values:
false Disables all map controls
roadmap Shows a control to change the maptype to roadmap
satellite Shows a control to change the maptype to satellite
hybrid Shows a control to change the maptype to hybrid
terrain Shows a control to change the maptype to terrain
navigation Shows the navigation control
streetview Shows the streetview control
scale Shows a scale control
You can combine the different values if you seperate them by a comma...only a comma and no whitespace. If you combine false with other values, the plugin will ignore that false.
Example:[gmap control="roadmap,satellite,hybrid,streetview"]
zoom="..." Controls the zoom level of you map. Possible values are:
auto
0...19
If you set the zoom level to auto the map will set a proper zoom level to display all items which are selected for automatic centering (see below).
Example:[gmap zoom="5"]
center_lat="..."
center_lon="..."
Sets the center of the map manually to the given coordinates. For the possible format of coordinates see below.
Example:[gmap center_lat="10 0 46 N"
center_lon="-23,455214"]
center="..." Defines the items on which the map will center automatically. If you also set the zoom property to auto, you can be sure, that all of the specified items are visible. Possible values are:
markers Center on markers which represent the position of a post
photos Center on markers which represent the position of photos
files Center on a kml file
You can combine the different values if you seperate them by a comma.
Example:[gmap center="markers,photos,files"]
marker="..." Defines wheter a marker at the position of your posts will be shown on the map. Possible values are:
true
false
Example:[gmap marker="false"]
marker_lat="..."
marker_lon="..."
Replace the marker of the current post by a marker at the given coordinates. For the possible format of coordinates see below. If these attributes are set, the marker value (see above) will always be set to true.
Example:[gmap marker_lat="10 0 46 N"
marker_lon="-23,455214"]
marker_icon="..." Changes the icon of the markers of the posts. Must be the URL to the icon image.
Example:[gmap marker_icon="http://www.example.net/icon.png"]
photo="..." Defines whether the plugin should try to read the geotags from the exif header of the photos you published in your post. Possible values are:
true
false
Example:[gmap photo="true"]
photo_icon="..." Changes the icon of the markers of the photos. Possible values are:
thumbnail The icon will be a thumbnail of the photo
URL An URL to an icon image
Example:[gmap photo_icon="thumbnail"]
file="..." Displays a .kml or .kmz file. Must be the URL to this file. The term __UPLOAD__ will be replaced by the loction of your Wordpres upload directory.
Example:[gmap marker_icon="__UPLOAD__/2011/04/mytrack.kml"]
post_query="..." If set, the plugin will replace the position and the photos of the current post by those which match the given query. Every marker has an info window. If you click on it, a link to the post will appear. You can style the appearance of this infow window with some CSS. To get an impression of the possible queries, you should have a look at the Wordpress Codex. Please note, hat you must seperate multiple parameters by an & (ampersand).
Example:[gmap marker_query="numberposts=5&offset=1&category=1"] will show the previous five posts of category 1
div_id="..." If set, the first map of every post (manual map or automatic map) will be displayed within a div container with the given ID. This might be useful to integrate the map into custom themes (see also below). Example:[gmap div_id="Map"]
theme="..." With this attribute the theme integration (see below) can be switched off for the current map.
false
Example:[gmap photo="true"]
visible="..." If you don't want to show a map but use the shortcode to set the coordinates of your post (see below), you can force the map to be hidden. Please note that this will not work if you have the automatic map enabled. Possible values are:
false
Example:[gmap visible="false"]

The above properties allows you to control the appearance of every single map. Besides that, you can also use the shortcode to save information to the Wordpress database, especially the position of your post. This might be useful if you send your posts from your mobile phone via email 'live from the field'. In this case you put your current position with the shortcode into the text of your post and the plugin will save the values to the Wordpress database.

lat="..."
lon="..."
Sets the position of your post. For the possible format of coordinates see below. Please note, that the coordinates will be saved, when the map of the post is displayed for the first time. The coordinates will only be saved if the position of this post is empty (so it will not overwrite previously saved coordinates).
Example:[gmap lat="10 0 46 N" lon="-23,455214"]
livepost="..." Will set the meta information of your post to indicate that this post was send 'live from the field'. If supported, your theme can read this value and tell your visitors.
Example:[gmap livepost="true"]

Formating the Coordinates

If you want to set coordinates, you can always use the follwing geographic coordinate conversion:

But don't use any units like ° or '. You can use either a point or a comma to seperate a decimal fraction. For example, the following coordinates are all the same:

Examples

For some examples you may have a look at my Geotag website.

The Options Page

Most options on the Geotag options page are explained (more or less well) and otherwise you might play a little bit around with the settings. However, for some options additional explanation might be useful:

The Automatic Map

If enabled, this feature automatically adds a map to every post. Besides that, the first [gmap] shortcode with all its properties will be processed for the appaerance of the automatic map. Hence, if you would like to add a second map to the post, you have to add two [gmap] shortcodes - the first one with the properties for the automatic map (or leave it blank if you don't want to change anything) and the second one with the properties for the manually added map.

The Map Appearance Section

In the section called Map Appearance you can configure the default appearance of your maps. If you add a plain [gmap] shortcode to you post, these settings will be used to configure your map. However, most of the settings can be changed for every single map (see above).

Merge Markers

This feature is new since Geotag v2.0 and allows you to merge individual markers which are too close to each other to display both of them. The plugin will also merge the content of the info windows, for example the link to the different posts.

Marker Manager

The Marker Manager is a Google Maps utility which will improve the performance of your map in case you want to display a large amount of markers. It will only show the markers according to your viewport and zoom level. Hence, usually only a fraction of all of the markers will be visible. You can set the minimum distance between two markers for a specific zoom level.

Timthumb

Timthumb by Ben Gillbanks creates all thumbnails for the photo markers. It won't use the Wordpress-generated thumbs but will create the thumbnails directly from the original file. To use the caching feature of Timthumb, it must have the right to write to the Geotag directory. You can tweak the settings used for creating the thumbnails of the info windows as well as for creating the thumbnails used for the marker icons. For a detailed description of the settings please have a look at the Timthumb documentation.

The Media Upload Window

Because of the filetype restrictions of Wordpress, you won't be able to upload a .kml or .kmz file via the ordinary upload form (unless you set define ('ALLOW_UNFILTERED_UPLOADS', true); in your Wordpress configuration file). The added KML/KMZ Files tab in your media upload window redresses these restrictions and allows to upload these filetypes. You can also register the file as an attachment to your current post, which means that it will be added to the Wordpress Media Library. Otherwise the file will only be uploaded and won't be saved to the database.

I hope that some people might find the Convert GPS-Track to a single path feature useful. If you enable this option, the Geotag plugin will read all the coordinates (points) from your .kml file and transforms them to a path. You can specify the sensitivity so that you are able to reduce the amount of points (and the filesize). I thought this would be useful for people who use a GPS-Logger and want to share their track. Usually this GPS-Loggers save a single point every now and then, which will look ugly and result in poor performance. With this feature you can create a nice path to display on your map on the fly.

Please Note: The conversion will only work if the coordinates are saved as single points and you need at last PHP version 5.

Using Geotag with Themes

You can also integrate the Geotag plugin into your custom themes. At the options page or with the [gmap div_id="..."] attribute you can define a custom DIV-container where the map should be displayed. If set, the first map of every post (manual map or automatic map) will be displayed within the DIV-container with the given ID.

Beside that, you can also access most of the Geotag features manually by calling the

Geotag::the_geotag($action, $options)

function. If you are interested, you should have a look at the end of the geotag.php file where this function is located and have a look at the comments.