Deprecated – OpenLayers 2 part 6

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

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

[*osm_map lat=”52.795″ lon=”23.51″ zoom=”1″ width=”450″ height=”300″ control=”mouseposition,scaleline” map_border=”thin solid orange” theme=”ol_orange” type=”osm” marker_name=”wpttemp-yellow.png” import=”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.

[*osm_map lat=”49.795″ lon=”13.51″ zoom=”3″ width=”90%” height=”300″ control=”mouseposition,scaleline” map_border=”thin solid orange” theme=”ol_orange” import=”osm” import_osm_cat_incl_name=”announcement” import_osm_line_color=”orange”]

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

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

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 }?>