OS OpenSpace Maps

Warning: simplexml_load_file(http://www.example.co.uk/myfile.gpx): failed to open stream: HTTP request failed! HTTP/1.1 404 Object Not Found in /home/jonlynch/public_html/wp-content/plugins/os-openspace-maps-profiles/profile.php on line 46

A plugin to display UK Ordnance Survey OpenSpace maps with markers and tracks.

This plugin works using the

To see this map cookies and javascript must be enabled. If you are still having trouble after having checked both of these please contact us using the link at the top of the page
shortcode anywhere in your post, page or custom post type content. It allows maps with markers and gpx or kml files to be shown. Examples are available at ButNoIdea.co.uk and my blog.

The following parameters can be passed:

  • height="xxx" sets the height of the map div
  • width="xxx" sets the width of the map div
  • colour="red" or colour="#ff0000" (color is also acceptable) sets the colour of the track shown from a file.
  • gpx="http://www.example.com/myfile.gpx" specifies a gpx file to be displayed
  • kml="http://www.example.com/myfile.kml" specifies a kml file to be displayed
  • markers="NY1234512345;Marker 1|54.454198,-3.211527;Marker 2" a list of positions and labels separated by | with a ; between the position and label. Positions can be 6, 8 or 10 figure grid references or decimal lat long.

To upload a kml or gpx file just use the WordPress media uploader and then copy the address of the uploaded file into the shortcode.


  • To see this map cookies and javascript must be enabled. If you are still having trouble after having checked both of these please contact us using the link at the top of the page
    displays a 300px by 300px window containing a yellow track from the file specified.

  • To see this map cookies and javascript must be enabled. If you are still having trouble after having checked both of these please contact us using the link at the top of the page
    shows a default size and zoom window with a marker placed and the popup text “Wasdale”

Download (1249 downloads)

Latest version: Download OS OpenSpace Maps v1.2.3 [zip]


  1. Go to the Plugins page in the admin area, search for openspace navigate to the plugin page and click install.
  2. Or download and extract os-openspace-maps.zip into the /wp-content/plugins/ directory. This will create a subfolder called os-openspace-maps containing the plugin files.
  3. Activate OS OpenSpace Maps through the ‘Plugins’ menu in WordPress
  4. Before the plugin will work you need to add your API key to the settings page on the dashboard.
  5. If you are running WordPress Multisite you (or your network administrator) will have to add KML and GPX files to the allowed file types under ‘Network Settings’.


Q. Where can I get support?
A. In the comments section at the plugin page

Q. Where is the rest of the FAQ?
A. This will be extended in due course.

Q. Planned for the future

  • Multiple kml and gpx files
  • A Shortcode Generator



  • CSS fix for stripy map tiles after the OS changed OpenSpace


  • Fixed problem with WordPress versions earlier then 3.3
  • Added hooks and filters to allow plugins to modify output
  • Added proxy for GPX and KML files not on the wordpress host


  • Bug Fix


  • Multiple markers with auto zoom
  • API key checking
  • New help tabs added to options and post editing screens
  • Add multiple maps to post or pages
  • Able to use lat long for markers


  • Bug Fix


  • Only adds one row to the options table
  • Fixed feed bug


  • Initial Release

42 thoughts on “OS OpenSpace Maps

  1. Mark Stanley

    Hi there,
    I get an error when the plugin is activated and I try to edit a page. It complains about an add help function on line 34. Any ideas?

    Love the idea of the plugin – I want to use OS maps rather than Google maps if possible.

    1. Jon Post author

      Hi Mark,

      Thank you for giving my plugin a try and for the feedback. Are you using WordPress 3.3 or 3.3.1? I think this may be a problem caused by using an older version of WordPress. I will release a bug fix that only trys to add the help tabs if the version supports them (3.3+).

      Cheers Jon

      1. Jon Post author

        This has fixed the problen, I will add the change in he next update. In the meantime if anybody using an earlier version of wordpress would like the fixed verson leave a comment.

  2. Dave Roberts (@Mudandroutes)

    Hi Jon,

    Thanks for developing this plugin, but I can’t get it to work. It demonstrates a map, once you click in, but no gpx file (they work with other plugins).

    Here’s the link http://www.walkupsnowdon.co.uk/?p=320 to where I’m trying to get it to work ( using the code [osmap gpx="http://www.walkupsnowdon.co.uk/wp-content/uploads/2011/09/SR-and-Cynghorion.gpx"] )


    BTW – are you willing to do some paid mods on this plugin?

    1. Jon Post author

      Hi Dave,

      I have found out what is causing the problem. There is a bug in OpenLayers (on which OpenSpace is based) which cannot cope with empty tags in the gpx file – see http://lists.osgeo.org/pipermail/openlayers-users/2011-April/020130.html

      Removing two empty desc tags from your gpx file solves the problem see – http://jonlynch.co.uk/testing/. Interestingly I use memorymap to generate my gpx files and it does not have his problem,

      Since the OpenSpace library is delivered from the Ordnance Survey it is not possible to fix the bug in openlayers directly. For the moment I hope that removing the empty tags manually is good enough.

      I would be happy to do some paid work on the plugin, what are you after?


      1. Dave Roberts (@Mudandroutes)

        Thanks Jon that’s really appreciated,

        That works great – I’ve just got to change about 600 of them now! I’ll have to change the shortcode on each page anyway, so it’ll do it at the same time.

        What I’m after –
        An Elevation Profile, with height, time and ascent and a link to download the gpx file – basically what I’ve already got plus time logged in the gpx file – I’d see it as something you may well want to add to the plugin anyway – so I’m happy to sponsor it and for it to be made available as part of the plugin.
        An example can be seen here: http://www.mudandroutes.com/archives/routes/snowdon-south-ridge-and-moel-cynghorion

        I don’t really mind if it’s got that icon following the route or not – being able to use OS maps would outweigh that!

        I’ve got a few more ideas too, I’ll run them by you too if you want (They’re a little more advanced).

        1. Jon Post author

          A suggestion for editing 600 files is to use NotePad++ or a similar editor and do a find in files to remove the empty <desc> tags.

          Hope this helps

    1. Jon Post author

      Hi Harry,
      My plugin is not designed to be used with the webmap builder. It works using shortcodes like [osmap markers="NY21600720;Scafell Pike|NY18600880;Wasdale Head"] or [osmap kml="http://www.example.com/my_file.kml"] If you go to your edit post page and then click on help you should find some instructions. To use the webmap builder code you need a raw html plugin. I think there was some instuctions on the OS OpenSpace site.
      Hope this helps, Jon

      1. Harry

        Initially I just pasted the code from the mapbuilder into the html editor box for the page but when you load the page it just shows an empty box. I tried downloading your plug in and I also downloaded the raw html plugin respectively, but I’m confused as to what both actually do because all I can do on your plug in is set a few parameters, and as far as raw html I can input html text into the box anyway. Maybe you could give me some very basic html script I can put in just to see that it will actually show a map to start with! Would be great if you could help. Thanks. Harry

  3. Harry

    Hi. I’m still trying to get my map working. I’m going with your plugin at the moment because the map builder just doesn’t work. The only thing I can get so far with your plugin activated and putting in various examples of you shortcode is an empty box with the os symbol in the corner and the navigation buttons but no map. I notice that in the plugin settings under map defaults there isn’t an option for setting ‘default map centre’ and just wondered if this might have something to do with it? I have put in my api key but it still says ‘You must register with the Ordinance Survey for an API key here before using this plugin’ but maybe it says this anyway?

    1. Jon Post author

      I’ve had a look at http://www.pyonsgroup.co.uk/?page_id=1243 and it seems that strange <p> tags are being added to the map javascript. (see line 189 of the page I linked too). I think another plugin has delayed the calling of the autop function which normally runs before shortcodes are processed. This could even be the raw html plugin. I would disable any unused plugins and then look at lines 189/190 there should not be any p tags. Then depending on how much you would like this to work try disabling other plugins that filter your content. Sorry i can’t be more help.


  4. dee

    Hi i am trying to link to some marker info, but can’t seem to get it to work.
    [osmap markers="ST3430362661;Mapping Social Enterprise"]
    is it possible to link to the text? If so, how?

    1. Jon Post author

      If you want to add a link into your text just use html but use single quotes for the href attribute, for example: [osmap markers="ST3430362661;<a href='http://www.example.com'>Mapping Social Enterprise</a>"]
      Hope this helps

      1. dee

        Thanks for helping with linking to a url. I did have a few issues getting into post as the code will only work when you are in “html” mode, rather than “visual”.

  5. andy


    I’m porting our site (which uses OS Maps) to WordPress.

    I’ve installed your plugin and I can get it working a shortcode, what I wanted to do was embed it in a php template. Is that possible?

    I tried calling osmap_generator($args) but that doesn’t work. Do I need to call some other init functions on the page too?

    I also tried do_shortcode(‘[osmap]‘); but that didn’t work either.

    – current site http://www.in-a-tent.co.uk/outlet/32
    – new site – http://dev.in-a-tent.co.uk/shop/2032/millets/aberdeen/

  6. andy

    I fixed the centering by editing os-openspacemaps.php and changing line 249 from osMap' . $mapid . '.setCenter( NGR2NE ("' . $centre . '"), ' . $zoom . '); to osMap' . $mapid . '.setCenter( CONVERT ("' . $centre . '"), ' . $zoom . ');

    1. Jon Post author

      Hi Andy, I am glad you managed to get it working in a template. Very sorry about the lack of replies but I’ve been away on a family holiday for the last week. I will update the plugin with your fix and add your use to the FAQ in the next release.


  7. Rob


    I just got the plugin installed, worked first time, its brilliant.Thank you for doing this.

    Is there a short code to get the elevation profile showing?



  8. Alan

    Hi Jon

    Working for Ordnance Survey and using their OS Openspace maps for a while now in a WordPress site, I was very pleased to see your plugin; thank you for your work with this.

    I’ve set up a test page and it loads the map and reads in a gpx file to display the route. However, I can’t get a marker to show.

    Here’s the code:

    [osmap height="600" width="600" color="red" markers="SU275085;Start" gpx="http://www.bikesandboots.co.uk/tracks/20110319newforest.gpx"]

    and here’s the test page:


    I’ve tried a different theme to see if that made any difference but it hasn’t.
    I hope you can help!

    Thanks in anticipation

    1. Jon Post author

      Hi Alan,

      Thanks for your comment. I’m afraid at the moment the plugin either shows markers or a track but not both. I will try to get this working in a future update.


  9. Jonathan

    Hi Jon,

    Great plugin :) Is there anyway to make it use the blue or green markers from OpenSpace instead of always the red ones? I’ve had a look through the php code, but can’t find anything that sets anything but the route colour.

    Hope you can help.


  10. Phil Thomas

    Hi Jon
    I can get markers to work but not gpx or kml files. Nothing appears in the map frame and then when I click on the map it defaults to somewhere near Berwick Upon Tweed (a 00 grid ref maybe?).
    I checked there are no empty tags in the gpx file. I’ve deactivated all other plugins and tried different themes. I’m not an expert, so now I’m stuck.
    Any help would be really appreciated!

    1. Jon Post author

      Hi Phil,

      Have you checked your kml or gpx files are actually accessible on a web browser at the address you are using in the shortcode? Just put the address in your browser and check they are accessible. If they are can you please either publish a post so I can take a look or let me know the whole shortcode you are trying to use. The Berwick thing always happens when the map has nothing to auto zoom to.

      Good luck

      1. Scott

        I had the same problem but figured it out. I was making the mistake of using an address in the shortcode without the ‘www.’ at the beginning whereas my site showing as being on ‘www.’. This was making the proxy kick in and my GPX files weren’t displaying.

        I’ve not tested putting the gpx on a different domain entirely to see if it was a proxy problem or not but hopefully this will help someone else.

        Great plugin by the way, thanks!

      2. Phil Thomas

        Hi Jon
        Appreciate your reply and sorry for disappearing on you!
        I’ve finally sussed out how to get it working. I had to change the file extension to xml and then upload manually to my website’s server (as the WordPress media uploader doesn’t like xml files). I’m not technically minded so I’ve no idea why or what this means – but it works!
        Great plugin, thank you. And Ordnance Survey maps are still the best.

  11. Adam


    Something odd has happened with maps displayed using the plugin, the map background appears stretched and has white spaces the same size as the map tiles striped down the maps produced. This doesn’t just seem to be affecting my blog, but seems apparent on your blog also (for example see the map associated with http://jonlynch.co.uk/2012/03/dale-head/).

    Any ideas what might be wrong?


    1. Jon Post author

      Thanks Adam, the problem is that after an update by the Ordnance Survey the CSS required for the map tiles now needs max-width:none; (or at least 250%). Many wordpress themes set a max width for all images and that is interfering with the map. I will release an update in the next day or two fixing this.

      1. Adam

        Ah that’s brilliant thanks, I’ve updated the CSS for the plugin in my installation and that seems to have done the trick.

        Cheers for the help, and thanks for the awesome plugin!


          1. Jon Post author

            I have just submitted the update to the Plugin repository, it should not make any difference now you have updated but for others with the problem it should fix it.

  12. Adrian

    Andy’s fix timed at 10th April, 2012 at 8:48 pm doesn’t seem to be included in the version of OSMaps 1.2.3 that I installed from the WordPress plugin repository.

    I had the problem of maps not being centred when I gave the co-ordinates of a marker in Lat and Long.
    I applied Andy’s fix and all is well.
    Many thanks.

    1. Mr Lynch Post author

      I have tested your shortcode at http://jonlynch.co.uk/2014/05/test-3/ and it works fine. I have looked at the code on your page and what is generated does not even request the GPX file. I suspect an another plugin is causing a problem. I’m afraid the best way to debug this is disable all other plugins and see if that fixes it, if it does then try enabling them one by one until you find the cause of the problem.

      Good luck


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>