Note: This article will soon be moved to my personal Geocaching blog at http://team-eclipse.de
If you are into geocaching and have a WordPress blog like this one then maybe you’d like to include maps with geocaches in your blog posts. This is generally not a difficult task but awkward if you have to do it by hand.
In this article I’d like to show how you can create maps like the following in a very easy way
What you need:
The follwing tools have been used to create the map above:
- WordPress for the blog software
- The OSM plugin by MiKa to embed the maps in your blog posts
- The icon set which can be downloaded here
- GSAK and my „ExportWPOSM“ plugin (you don’t need it but it makes the task much easier especially if you change the data often)
I won’t explain here how to install WordPress or the OSM plugin. Details on that can be found at the corresponding sites. The only preparation you need additionally is to put the icon files where the OSM plugin can find them. This place must be on the same site as the blog post. In my case I created a directory in my directory structure wp-contents/uploads/icons/gc and places all icon files in there. After that the icons can be referenced like this
If you are going to use the GSAK macro, you’ll need to remember the base URL (the part before the icon name, „http://schmolzi.de/wp-contents/uploads/gc/“ in this example) and specify it when exporting the data.
Embedding the map in your posts
To include a simple map without icons in a post you simply need to add the following code to your page (without the * at the beginning):
[*osm_map lat="49.81" long="8.71" zoom="13" width="600" height="400"]
„lat“ and „lon“ define the center point of the map, „zoom“ is the zoom level and width and height define how big the map will be displayed on your page. This code creates the following map (note the blue „+“ sign at the top right. It opens a menu that lets you change the map type!)
Adding waypoints to the map
Now you have a map on your page you might like to add some waypoint markers to it. I’ll first explain how to do it with GSAK and the ExportWPOSM plugin. I will add a description of how to create the waypoint files by hand in another article.
Adding markers to your map using GSAK is very easy if you have installed the ExportWPOSM plugin. If you start it you will be prompted for some basic settings:
Here you need to specify the base URL for the icons as described above. Do not forget the trailing „/“. Additionally you must enter the directory and file name where the markers description will be written and define if you also want to include child waypoints or – if so – want to include only child waypoints which have the user flag set.
The marco will then go through your current database with the active filter and create a marker file which contains every waypoint in it. Once it’s done it shows how many caches and child waypoints it has written.
After that upload the generated file to your webserver. I placed mine in wp-contents/uploads/2011/01/demo.txt. To include the markers in your map add add the tag „marker_file“ to the map defintion like this:
[*osm_map lat="49.81" long="8.71" zoom="13" width="600" height="400" marker_file="http://schmolzi.de/wp-content/uploads/2011/01/demo.txt"]
This will create the following map:
Currently six icon colors are provided per type. They are used by the macro in the follwoing way (maybe this will be configurable in a future version):
- Green icons denote caches you have already found
- Blue icons denote caches you own
- White icons denote caches you have not found yet
- Red icons denote caches you logged a DNF
- Grey icons denote caches that are temporarily disabled
- Yellow icons denote mystery caches that you have not found yet but have corrected coordinates. This is useful to show Mysteries that you have solved but not found yet.
Warning: count(): Parameter must be an array or an object that implements Countable in /homepages/37/d20411291/htdocs/wp-includes/class-wp-comment-query.php on line 405