Awesome!

Name has been added to your Follow page.

My Follow Page

Name has been removed from your Follow page.

My Follow Page

Login



OS DataHub Maps

5 Avg. Rating
100 Installs
Tested with WordPress 5.8.1

by Simon Large.

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

A plugin to display UK Ordnance Survey maps with markers and tracks. This plugin is a successor to the OS OpenSpace Maps plugin and uses the same shortcode.

This plugin works using the [osmap] shortcode anywhere in your post, page or custom post type content. It allows maps with markers or GPX/KML files to be shown.

Using the new OS Data Hub API you can now view 1:50,000 Landranger and 1:25,000 Explorer maps.

The following attributes can be passed:

  • height="600" sets the height of the map div
  • width="800" sets the width of the map div. Omit this to use available width.
  • zoom="7" sets the initial zoom level
  • profile="175" sets the elevation profile height
  • color="red" or color="#ff0000" sets the colour of the track shown from a file.
  • track="3" sets the width of the track shown from a file.
  • gestures="0" disables gesture handling.
  • markers="NY1234512345;Marker 1|54.454198,-3.211527$2!red;Marker 2" a list of positions and (optionally) labels separated by | with a ; between the position and label. Positions can be 6, 8 or 10 figure grid references or decimal lat long. Labels, if present, must be simple text. Layer index can be specified following a $ after the position. Marker colour can be specified following a ! after the position.
  • markerfile="http://example.com/markers.txt" specifies a text file containing marker definitions, one per line. As above, position and label are separated by ;. In this case the label can include any text including HTML, should you wish to include links or other formatting.
  • gpx="http://www.example.com/myfile.gpx" specifies a gpx file to be displayed. Multiple GPX files are supported, with colours and layers as described for markers
  • gpxfile="http://example.com/gpx_tracks.txt" specifies a text file containing GPX definitions, one per line
  • kml="http://www.example.com/myfile.kml" specifies a kml file to be displayed
  • kmlfile="http://example.com/kml_areas.txt" specifies a text file containing KML definitions, one per line
  • centre="54.454198,-3.211527" sets the map centre point, to override the default centre or if not using markers or track files
  • layers="Civil Parish|!Ecclesiastical Parish|!School Catchment" specifies the names for layers which can be toggled on and off. A leading - leaves the layer turned off initially
  • extent="NY123123|NY456456" sets the area to display in terms of two points which must be fitted within the display area
  • quote="^" specifies a character to be replaced with a double-quote in marker text. This makes it easier to add HTML definitions within the shortcode

There are 14 zoom levels available:

  • 0 Whole UK
  • 1 Half UK
  • 2 1:1M
  • 3 1:1M, zoom
  • 4 1:250,000
  • 5 1:250,000, zoom
  • 6 1:50,000 Landranger
  • 7 1:50,000 Landranger, zoom
  • 8 1:25,000 Leisure
  • 9 1:25,000 Leisure, zoom
  • 10 1:3,307 Detail
  • 11 1:1,654 Detail
  • 12 1:827 Detail
  • 13 1:413 Detail

Each zoom level is a factor of two higher then the previous one. Zoom 6 shows 1:50,000 Landranger maps at actual size, so zoom 8 is showing 1:25,000 Explorer maps at double scale.

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.

Additional Shortcodes

[osmap_marker color=red] will display one of the marker icons inline with your text. It takes one attribute to select the marker colour. This may be used to add annotation with your maps.

Examples

  • [osmap] displays a map at the default height and zoom level, centred on OS headquarters in Southampton. This is the simplest way to test that the plugin is working.

  • [osmap height="300" width="300" color="blue" gpx="http://www.example.co.uk/myfile.gpx"] displays a 300px by 300px window containing a blue track from the file specified.

  • [osmap markers="NY2000008000;Wasdale"]shows a default size and zoom window with a marker placed and the popup text “Wasdale”

Migration from OS OpenSpace Maps

Ordnance Survey is sunsetting the OpenSpace Maps service and it will be switched off on 31 August 2021. This plugin aims to give a seamless upgrade to use the new Data Hub Maps service instead. It uses the same shortcode and all the same attributes are supported.

The Data Hub service is a significant upgrade from OpenSpace, allowing use of the excellent 1:25,000 Explorer mapping. It also has a much more generous free data allowance, typically 2 million map views per month.

We are now using Leaflet.js to display maps, giving a cleaner and more responsive interface.

The plugin has also been upgraded with new features:

  • Full screen viewing option.
  • Elevation profiles from GPX data.
  • Better touch and mousewheel support, similar to Google Maps.
  • Ability to use both routes and markers on the same map.
  • Nine different marker colours available.
  • Option to restrict premium maps to logged-in users.

This plugin will detect whether the OpenSpace plugin is currently active and give way to it. In that case it hooks a test shortcode instead, [osmap_test]. This allows you to get to the settings page and check that everything is working on a test page. You can then disable the OpenSpace plugin and the Data Hub plugin will take over.

  1. Go to the Plugins page in the admin area, search for datahub navigate to the plugin page and click install.
  2. Or download and extract os-datahub-maps.zip into the /wp-content/plugins/ directory. This will create a subfolder called os-datahub-maps containing the plugin files.
  3. Activate OS 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’ if you wish to upload these files.

Is this compatible with OS OpenSpace Maps?

As far as possible, yes. The new Data Hub mapping service is very different from the OpenSpace service, but we have tried to maintain compatibility as far as possible. All being well you should be able to install the new plugin, set the API key and a few defaults. When you disable the OpenSpace plugin, this one should just populate the existing shortcodes in the same way.

Where can I get support?

You can find examples and much more information on the plugin homepage

Ask questions in the support forum on the WordPress plugin page

1.2.2

Re-add absolute URL conversion for GPX and KML routes which got lost in 1.2.0

1.2.1

Support description popups on tracks and shapes as well as markers
Option to show popups on hover
Option to use gesture handling on mobile only
Improved error handling and display
Add missing elevation-position icon
Use - instead of ! to indicate layer initial state is off
Allow non-integer value for track width

1.2.0

Add support for multiple GPX and KML layers, and for auto-fit to all layers added.
Add a little padding when autofitting to be sure the bounds are contained.
Add support for layer selection.
Add a setting for zoom step size.
Add a new shortcode to output a marker in approximately the current font size.
If reading markers from a URL fails, try converting to the local path. Some servers will not allow PHP to read file content from a URL.
Improvement to Leaflet 1.7.1 handling of clicks in Safari.
Hide duplicate waypoint markers created by elevation profile.
Update to leaflet-elevation 1.6.9

1.1.3

Fix elevation profile custom colour.
Fix margins on elevation profiles following leaflet-elevation update.
Compensate for the 20px stripped off the profile height by leaflet-elevation.js.
Prevent profile heights < 30px being set accidentally.

1.1.2

Revert to Leaflet.fullscreen due to problems with iOS/Safari which prevented maps from showing at all.

1.1.1

Restore file accidentally removed from WordPress on commit

1.1.0

  • Update to Leaflet 1.7.1
  • Update to leaflet-elevation 1.6.7
  • Update to leaflet-gesture-handling 1.2.1
  • Replace Leaflet EasyPrint with leaflet.browser.print
  • Replace Leaflet.fullscreen (mapbox) with leaflet.fullscreen (brunob) for better iOS compatibility
  • Improve consistency of auto-fit behaviour. Allow explicit zoom and centre to be set
  • Fix JS console error
  • Do not load unused Javascript files

1.0.11

  • Allow .txt files to be added to the media library
  • Add a shortcode attribute to allow GPX track colour to be taken from the GPX file
  • Allow " to be used to escape quotation marks in marker text

1.0.10

  • Add an option to display map scale
  • Allow a default map height of 0 to allow external CSS to style the map
  • Better validation of settings
  • Improve error message when coordinates cannot be converted

1.0.9

  • Add experimental support for printing maps
  • Add an option to disable gesture handling
  • Fix some PHP notice errors

1.0.8

  • Fix zoom when displaying a single marker.

1.0.7

  • Fix display of a single marker when marker colour is specified.
  • Change style tags to allow better co-existence with OpenSpace maps during testing.
  • Changes to internal directory structure.

1.0.6

  • Reimplement elevation profile hiding to avoid display with fixed 600px width in some browsers.

1.0.5

  • Use the default marker for waypoints in GPX files.
  • Hide elevation profile if there is no data to show.

1.0.4

  • Fix a regression in the fullscreen button CSS

1.0.3

  • Allow base-relative URLs and alternate scheme URLs
  • Add option to restrict panning to 45% of map width and height to avoid excessive tile usage
  • Add license files for all 3rd party components
  • Update to leaflet-elevation 1.3.7 to fix problem with multiple profiles on one page
  • Use leaflet-gpx in place of omnivore for GPX maps to ensure routes are processed as well as tracks
  • Improve CSS specificity to avoid some misalignments

1.0.2

  • Fix double escaping of HTML in marker files
  • Ensure theme doesn’t add box shadow to map tiles and markers

1.0.1

  • Fix setting colour of elevation profiles
  • Avoid code re-ordering when used with caching plugins
  • Add version query to CSS and JS file fetches for cache busting

1.0.0

  • Initial version, a ground-up rewrite to replace the plugin for the deprecated OS OpenSpace Maps service.