Apr 08 01
This plugin allows you to record a location against your posts. For example the country that the post talks about, the event took place in, the location you are writing the post from, etc. Your imagination is the limit…
Some of the key features are:
- Once a post is tagged with a country the plugin allows flag icons to be added to your blog’s pages with simple additions to your template files.
- You may also record the latitude & longitude of a location. The enhanced version of the plugin provides multiple ways to display the location using Google mapping.
- Country icons can be clicked to take the user to posts from that country.
- A sidebar widget that provides a popup to navigate to posts from a given country.
- Presents an admin page, under the WordPress Tools menu, to review numbers of posts from each country.
I’m quite pleased with the plugin, so it’s available to share, I hope you enjoy it too.
The plugin is available as a free download.
All I ask is that you credit the plugin, for example, include a link to this page or maybe add a link to your WordPress blogroll.
Instructions & Installation
- Just put the complete un-zipped plugin directory into your WordPress plugin directory (if this doesn’t make sense it probably isn’t something you should be trying ) and activate it.
- Within the WordPress loop, use this
country_tag($post->ID);in your index.php template file to show a post’s country tag.
- And this
country_tag($post->ID, false);in your single.php template file to show the post’s country tag.
- Note, you’ll need this
gobal $post;declaration in your template files too if it’s not already there.
- The second parameter (the default
false) determines if it is a short or long output:
- Long – Location Australia
- Short –
- The widget has a single option, one of your WordPress pages. When set to one of your pages a link is shown under the popup list of countries in the widget. Following the link goes to that page – where you might show a list of countries featured on your blog, or a map! A map is easily created with the enhanced version of this plugin.
- You can also include the same popup list of countries used in the widget on your pages by adding this
country_list_countries();to your theme’s template.
How to Tag a Post with a Country
Using the Location section (you can set the title of this section with the first of the plugin options, see below) of the post writing page. Select the Country you want to tag the post with from the country dropdown. For example, to get a UK flag select UK from the dropdown.
The country names provided are the names of the icon files in the directory:
Feel free to add additional flag icon files or remove those you don’t want to see listed in the dropdown.
Premium Version of the Plugin with Mapping
The standard plugin allows Latitude & Longitude to be stored along with the country tag. Google mapping is available with an enhanced version of the plugin available to buy below. An example of the mapping is given here showing dozens of mapped posts and venues.
The enhanced plugin provides several advanced mapping interfaces and features.
- Within the WordPress post writing interface a sophisticated interface (including geo-location by address, place name, etc.) to create and manage the location associated with posts. This interface is shown in screenshot #3 below.
- A public map for your blog readers to enjoy that shows all the mapped posts and venues (more details below about the venues feature). An example of the mapping is given here showing dozens of mapped posts and venues. The map is automatically inserted by the plugin on any page or post with
<!-- adventure-map -->.
- Show a location map on a post page (when the post has location data). Include a post map with the shortcode
[post_map]and optionally set the map-type to ROADMAP, SATELLITE, HYBRID, or the default TERRAIN and zoom level (default 11) with
[post_map type="SATELLITE" zoom="14"]. Please see Post Locations below for more options and functionality.
- The plugin remembers the last map-type shown (using a cookie).
- Several markers are used on the mapping, the default colours are:
- Posts are shown with a blue marker – .
- Posts with GPX data are shown with a purple marker – .
- Named waypoints in GPX tracks are shown with a green marker – .
- Venues are shown with a red marker – .
- Additional maps embedded within posts showing other locations are shown with a green marker – .
- When creating location data new locations are shown with a yellow marker – .
- In addition to the default markers, there are a number of custom markers included. Add to these as you like, the new markers go in the plugin’s
markersdirectory. There’s even an included Photoshop template (.PSD). The included markers are:
- A simple yet powerful mechanism to allow uploaded GPX files (e.g. from a GPS enabled device) to be automatically represented with Google mapping showing the trace of a route. These routes may also be accompanied with a graph showing elevation along the route.
- A number of template tags are provided to optionally enhance your WordPress theme:
- To including linked country icons:
country_tag($post_ID, $short=true, $prefix='Location ', $size=15, $echo=true);
- To include a popup list of countries:
- Location map links:
- Venues button:
- Show a link to all venues:
Use this template function or have the plugin automatically include a link on any page of post with
<!-- venues-link -->.
- To including linked country icons:
The plugin has several advantages over other mapping plugins. For example, it doesn’t unduly load your web server, making full use of the power of the user’s browser. This also makes content more interactive, for example hovering over elevation graphs shows the data at that point of the graph dynamically.
The following screenshots give a flavour of the plugin’s rich capabilities. The size, position, etc. of each map on your pages is customisable using CSS settings (defaults are initially provided), please refer to the options screenshot #13 below.
The following screenshot shows the location editing interface within the WordPress editor. As well as adding a country flag attribute to posts, add Latitude & Longitude either manually (click the location on the map) or use geo-location (address, place name, etc.). The new location marker () can be dragged around the map to achieve an accurate position.
The location’s map marker can also be changed from the default using the marker drop-down list.
The multiple location plugin option (see screenshot #13 below) allows multiple locations to recorded for each post. When enabled the and buttons are shown. Click the icon to set the focus of geo-location, dragging the new location marker, and map clicks.
The Country column of the post listing (screenshot #1 above) is enhanced when location data is given. Posts with location data will have Geo and an indication of the quality of the data:
- Geo: – the Latitude & Longitude are OK.
- Geo: – only one Latitude or Longitude value is provided.
- Geo: – the Latitude & Longitude are OK, but the administrator has blocked plotting.
Multiple Markers at Maximum Zoom
A limitation of Google mapping is that each map-type has a maximum level of zoom. For example, the most limited level of zoom is often found with the TERRAIN style of map. Switching to SATELLITE may allow a higher level of zooming, especially in popular urban areas like cities. However, regardless of map-type, sooner or later it will be impossible to zoom the mapping any further. At this point if you have multiple locations mapped the clustering of the markers will be impossible un-cluster. This plugin deals with this problem by offering a tabbed popup, one tab for each location. Just click on the cluster to see the tabs. (The popup will be un-tabbed when clicking on a single marker.)
This example also shows how feature image thumbnails can be optionally included in the popup summary about a location (see the display icons option in screenshot #13 below).
Alongside the default markers described above there are three ways to set custom markers:
- Venues may use their country flag as their map marker (see options screenshot #13 below).
- Custom markers can be set for individual posts (see screenshot #3 above).
- Or you may set a custom marker for a post category. The enhanced post category editing page provides this function.
GPX Tracks & Elevation Graphs
Upload GPX files, say from your GPS device, to automatically show the tracks.
The GPX trace will show any named waypoints with a small green marker – . If the post that the GPX is shown in has location data the location will be shown with a purple marker – .
Accompanying maps of GPX tracks, graphing of the elevation along the path of the track may be displayed. Graphs are built dynamically by the user’s browser using Google Charts (so unlike some other plugins they do not cause lots of PHP processing on your server or blow PHP’s memory limits). Here’s an example of the graph that accompanies the track above.
GPX files may be uploaded using the normal WordPress media upload and then embedded within a post. For example, the following simple markup will be automatically presented with a Google map showing the route described by the GPX file.
<a href='http://your-domain/path/file.gpx'>GPX Data</a>
If enabled (see options below) an elevation graph will be automatically included. However, if you want to suppress the elevation graph for a specific GPX track include
elevation='off' in the markup. For example:
<a href='http://your-domain/path/file.gpx' elevation='off'>GPX Data</a>
Posts can show their location on a map. The map is easily embedded within the post with the shortcode
[post_map] and you can optionally set the map-type to ROADMAP, SATELLITE, HYBRID, or the default TERRAIN and the zoom level (default 11). For example,
[post_map type="SATELLITE" zoom="14"] will show the location associated with this post on a satellite map at zoom level 14.
The shortcode can also be inserted using quicktag buttons. In the WordPress HTML post editor the button is and in the Visual editor the button is .
There are several more additional attributes that can be added to the shortcode to show any number of other locations within posts. These are:
location – a latitude & longitude comma separated pair;
loc_name – a name for the new location;
link – override the Include link to Venues map option;
style – override the post_map CSS option; and
current – show the current location. For example you might show a place of interest with:
[post_map zoom='16' type='SATELLITE' location='54.339,-2.743' loc_name='Playing Fields']
Show your current location (if your browser allows it) with:
[post_map zoom='16' type='ROADMAP' current='on' style='width: 400px; height: 200px; border: 1px solid #ddd;']
Geo-tagged Photo Mapping
The plugin also supports mapping of photographs with geo-tagging EXIF data. The EXIF location data may have been added to the photo’s meta-data automatically when the picture was taken by a GPS enabled camera, manually, or photo organising software such as Adobe’s Lightroom or Apple’s iPhoto or Aperture.
(Note, a default WordPress installation does not preserve EXIF data when uploading and scaling images. Therefore the plugin will not have access to location meta-data in photos uploaded before the plugin was installed and the Save image location data option was set.)
Main Location Map & Options
Using the enhanced mapping features within a post is easy and highly flexible. Using the mapping is explained more here.
Mapping of all tagged posts (and Venues, see below) can be presented to your users on a nominated page. (The blog administrator can elect to not display the location of specific posts even when latitude & longitude values have been supplied.) Here’s an example location map. The page used to display the map is defined on the plugin options page. That page should have the following simple code within its text to show the map.
<!-- adventure-map -->
Note, the options page also provides a field to enter the CSS for the map canvas. It is essential that this sets, as a minimum, the size of the canvas. To kick-off try something like:
width: 600px; height: 450px; border: 1px solid #ddd; margin: 5px;
There are seven sets of options:
- Plugin – general plugin options including the title of the editing box, if the map should initially be shown or hidden on the WordPress post editing page, the scope of searches, etc.
- Venues Map Page – the page and style used to display the main venues map.
- Post Map – how maps are embedded, with a shortcode, in posts.
- Images – options to allow and show geo-tagged images to be mapped.
- GPX Processing – control processing of GPX files attached to posts.
- Elevation Chart – control elevation charts associated with attached GPX files.
- Markers – define the colours of the default markers used by each type of map, and also enable custom markers for venues and posts.
Geo RSS Feed
The Venues Map Page options allow configuration of whether location data, for posts and/or venues, are included in the standards compliant Geo RSS feed generated by the plugin. (Note, add
?feed=venues to your blog’s main URL to access the location RSS feed. You may wish to use this, for example, to submit geo content to Google as a geo site map.)
In addition to tagging posts with country and latitude & longitude for mapping the enhanced plugin provides a special type of post – Venue. These are great for recording specific details about specific locations. For example, a page of information for each country, or a page of details (e.g. pubs, clubs, and hotels) about a particular city. Venues are a blend between standard WordPress pages and posts. Venues are accessed from the new Venues menu. (Note that the list of countries moves with the enhanced version of the plugin from the WordPress Tools menu to the Venues menu.)
Buy the Enhanced Plugin with Google Mapping
- 15.12 – Admin form moved to separate file to make more manageable.
- 15.11 – Added option to disable use of single-venue.php template.
- 15.10 – Fix for custom post type archive links.
- 15.9 – Fix for country custom column showing for “other” custom post types.
- 15.8 – Fix for “more” in excerpt used for popups.
- 15.7 – Fix for geo-located photo popup path.
- 15.6 – Update to popup for any HTML markup in post title.
- 15.5 – Use non-deprecated widget functions.
- 15.4 – Added main map zoom level as an option.
- 15.3 – Allow navigation menus to pick Venues.
- 15.2 – General tidy up, and automated use of plugin data.
- 15.1 – Add geo-tag tick mark to media library listing.
- 15 – Post maps can show geo-tagged photo locations for all JPG images attached to a post.
- 14.9 – GPX trace line-colour example for admin page.
- 14.8 – Added count of locations to post list data display.
- 14.7 – Cleaned up meta data saving.
- 14.6 – Added count of locations in each post to post meta data.
- 14.5 – Centering error fixed with respect to current location and already placed location.
- 14.4 – Improved help (tab) text.
- 14.3 – More options for post maps!
- 14.2 – Post maps can use current location. (Plus, post_map options better explained.)
- 14.1 – Small fix to location name matching to exclude parentheses.
- 14 – Added option to center administration map on current location.
- 13.5 – Added featured image thumbnails to custom post type (venues).
- 13.4 – Loading image (spinner) to provide AJAX feedback.
- 13.3 – AJAX for popup information bubble.
- 13.2 – Option for grid size of clustered markers.
- 13.1 – Option to allow marker cluster’s locations to be averaged.
- 13 – Include option to show featured image thumbnails in venue information bubbles.
- 12 – Allow multiple markers at the exact same location.
- 11.3 – Added cookies to save the last map-type displayed.
- 11.2 – Help section added to options page.
- 11.1 – Add automatic setting of country selector if using geo-locator and country selector is unset.
- 11 – Multiple locations per post.
- 10.1 – Custom column for categories view.
- 10 – Finished custom marker release – venues can use flags, posts and categories can have custom markers.
- 9.1 – Venues can use flags as markers.
- 9 – Options to select marker colours.
- 8.2 – Added filter of Countries in admin lists.
- 8.1 – Added loop for Venues and sorting of custom columns.
- 8 – Include Venues (and/or Pages) in search results.
- 7.3 – Show custom types in WordPress “Right Now” dashboard.
- 7.2 – Post map can be for a provided custom location (i.e. not the post lat/lng). This also allows multiple post maps!
- 7.1 – Enhanced country reporting to highlight errors in geo data.
- 7 – Added drag-zoom feature to venues page.
- 6.4 – Initially hide or show map option & fix for initial location of new location marker.
- 6.3 – Fixed for blank line in XML feeds.
- 6.2 – Add options for map center.
- 6.1 – Post edit button for post maps.
- 6 – Internationalisation.
- 5.1 – Map style for post maps.
- 5 – Option to include a map within a post page.
- 4.3 – Elevation graphs matched to GPX tracks.
- 4.2 – GPX files can be shown as maps with tracks in posts.
- 4.1 – Trap for a marker in the same place as another.
- 4 – Google mapping of posts and venues with location data.
- 3 – Venue post-type to record location, beta, facts, links, etc. for given locations.
- 2.2 – General tidy up.
- 2.1 – Buy link.
- 2 – Version without mapping.
- 1.3 – Various lookup widget bug fixes.
- 1.2 – Don’t duplicate meta data.
- 1.1 – New admin summary page.
- 1 – Added custom form entry to aid user experience, plus now adds Latitude & Longitude.
- 0.4 – Added custom column to posts management list to show country.
- 0.3 – Fixed bug wih where clause construction; thanks to Thomas Lindholm.
- 0.2 – Released to the WordPress community.
- 0.1 – Initial version.
Series - WordPress Plug-ins
Start slideshow with these images