WordPress Post Country Plugin (with premium Google Mapping)

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 second parameter (the default true, or 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.

2. Countries widget options.

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:

wp-content/plugins/post-country/Flags/

Feel free to add additional flag icon files or remove those you don’t want to see listed in the dropdown.

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 markers directory. 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:

Show a link to all venues: get_venues_link();Use this template function or have the plugin automatically include a link on any page of post with <!-- venues-link -->.

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.

Post Editing

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.

3. The post editing Location section.

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.)

4. Multiple location tabs.

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).

Custom Markers

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.

7. An uploaded GPX file automatically shown with mapping.

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.

8. A graph of elevation associated with an uploaded GPX file.

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:

Post Locations

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 .

9. Example post location map.

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:

Provide a table of locations associated with this post using the shortcode [locations_table]. There is one optional parameter title. This is the title to display before the table of locations (default is Venues or your customised name).

Geo-tagged Photo Mapping

The plugin also supports mapping of photographs (JPG images only) 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.

12. Mapping showing geo-tagged photos.

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. Photos that have had their geo-tagged location data successfully read will show with a Geo Tag in the WordPress media library list as shown.

Main Location Map & Options

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;

13. Options.

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.

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.)

Venues

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.)

14. The new Venues menu.

Buy the Enhanced Plugin with Google Mapping

Buy the enhanced Post Country Plugin here for an insanely cheap price!

Buy the plugin and I will provide free updates forever as the plugin gets more and more features…

FAQ

Are Google Map Controls failing to render properly?

Often WordPress themes makes a common mistake that stops Google mapping controls from being drawn properly. This is because the theme forces sizing for all images. I have suggested a fix for this with an alteration like the one I recommend on this Stack Overflow post.
Just add the suggested CSS rule to your theme’s style.css, however, even then some themes have CSS rules that take precedence. In these cases I suggest you either get stuck in to working out the CSS in your theme, or you could try applying a sledgehammer (!important)....gmnoprint img { max-width: none !important; }

Post editing only showing a single marker?

Make sure you have enabled the inclusion of Posts and/or Venues in the Venues Feed. These are two separate checkbox options available on the plugin's settings page, under the Venues Map Page section.

Are your geo-tagged photos failing to show on post maps?

Unfortunately some geo-tagged photos are not recognised by the underlying PHP read_exif_data function. This bug is trapped to allow the image to upload properly, but the latitude and longitude data for the image won't be captured by this plugin. You will know if your image has a faulty set of geo-tagging data as the WordPress media list will not show the image as geo-tagged. As soon as there is a fix for this PHP bug - either in a later release of PHP or by using some other geo-tagging information extraction mechanism - a new version of the plugin will be issued to all users.

Can I add GPS location data to JPG images manually?

If you digital camera (or smartphone) does not have the ability to tag photos with GPS location data it is possible to manually add the location meta data yourself using photo manipulation software like Adobe Lightroom. There other free tools too like Google’s Picasa (although I haven’t tried any of the free tools). Note, GPS data is embedded inside the JPG image file’s meta data.

Version History

Enhanced Plugin:

18 Directions.

17 – New short code ([locations_table]) to provide a table of locations.

16 – Allow a custom name for “Venues”, e.g. “Locations”.

15 – Post maps can show geo-tagged photo locations for all JPG images attached to a post.

14 – Added option to center administration map on current location.

13 – Include option to show featured image thumbnails in venue information bubbles.

With regret comments are closed on this post to avoid being deluged with “how to” queries and not genuine issues with the plugin. So, if you want support or advice use the feedback link. But please note I will ask for a donation before I’ll look at “how to” questions, I can’t teach PHP programming for free.