Display geotagged posts – old

This article and the short is not supported any more. Visit the new article.

The WordPress OSM Plugin supports geotagging for posts and pages.

  1. Install WP OSM Plugin
  2. Activate Options to see geotag and shortcode are at add post page
  3. Geotag your posts /pages

1.) Install WP OSM Plugin

Installation of WP OSM Plugin can be done simply in the backend like all other plugins.

2.) Add geotag to your post / page

Enable the Options for WP OSM Plugin geotag widget area when you create / edit your posts:

geotag widget in WordPress OpenStreetMap Plugin

geotag widget in WordPress OpenStreetMap Plugin

3.) Geotag your posts /pages

You can define an icon for the post page (optional) and add a geotag to it:

geotag widget in WordPress OpenStreetMap Plugin

geotag widget in WordPress OpenStreetMap Plugin

  1. If you do not select an icon here the default icon is shown in your overview map.
  2. Click into the map to define the geotag.
  3. Save the geotag to the page.

Note: You can add multiple geotags to one post / page, just separate them with space in the custom field, see also the Blog!

There is a shortcode generator to create the map with geotags:

geotag widget in WordPress OpenStreetMap Plugin

geotag widget in WordPress OpenStreetMap Plugin

You can define if you want to see geotags of posts, pages or any. You can also draw a line between them:

Geotag for WordPress OpenStreetMap Plugin OSM

Geotag for WordPress OpenStreetMap Plugin OSM

 

You can change the marker simply by giving a relative path to your personal icon at marker_name.

The announcements of this Blog have been geotagged with capitals of Europe, to add only marker of announcements a with link to the article add a shortcode like this:

The auto generated map looks like this – click on the map to get a link to the article.

Draw a line between the geotagged posts with addional argument import_osm_line_color=”orange” :

If you want to scan the pages of your site you have to add post_type = “page” :

There is also a widget to display a map with the geolocation at the post / page automatically. Just go to:

Deisgn => Widget to add and configure the widget:

OpenStreetMap Plugin Widget for WordPress

OpenStreetMap Plugin Widget for WordPress

You can see the widget with the map on this site.

You can also add autogenerated map to your WP-theme you this coding:

// echos a links to OpenStreetMap with post/page geo data.
OSM_echoOpenStreetMapUrl()
// returns a links to OpenStreetMap with post/page geo data.
OSM_getOpenStreetMapUrl()
// returns the Long value of post/page geo data
OSM_getCoordinateLong()
// returns the Lat value of post/page geo data
OSM_getCoordinateLat()

- - - Sample to add link to OSM with geo data in my template - - -
Add these lines in the emplate file to create a link with geo data of your post.

  <?php $NameOfPlace = get_the_title();?>
  <?php if (function_exists(OSM_echoOpenStreetMapUrl)) { ?>
    <?php if ((OSM_getCoordinateLong('osm'))&&(OSM_getCoordinateLat('osm'))) { ?>
      <?php _e(" - Map:"); ?>
      <?php echo "<a title='".$NameOfPlace."' target='_blank' href='".OSM_getOpenStreetMapUrl()."'> OSM</a >";?>
    <?php }?>
  <?php }?>

Location