A Leafletjs TileLayer using Ordnance Survey OpenSpace web map service
JavaScript HTML



npm version

A Leafletjs TileLayer to display Ordnance Survey map data in your Leaflet map via the OS OpenSpace web map service.

Important: This project is no way affiliated, nor supported or endorsed by Ordnance Survey. The use of this project does not comply with the Ordnance Survey OpenSpace service terms and conditions. Use at your peril!


The os-leaflet project is a new L.TileLayer that can be used to easily get Ordnance Survey products into a Leaflet map, the Leaflet API can be used as normal.

Note: This layer uses an Ordnance Survey service that requires an API KEY - attempt to get one here.



If you are using Leaflet version < 1.0 then please use v0.2.1 of this library. Checkout leaflet-1.0 for a Leaflet 1.0 compatible version - this will be become v1.0 when Leaflet 1.0 is released.


This repository contains the following sections:

  1. OSOpenSpace.js - This contains the source code to the L.TileLayer.OSOpenSpace layer.
  2. Demo - A simple demo to show off the functionality.

Getting started

You can get hold of the code with npm and it should work fine with browserify. Or you can just manually import the layer.

Dependency management

With npm:

$ npm install os-leaflet --save

Bundle for the browser with whichever tool you're using, eg webpack, browserify.

Then just require the libary along with Leaflet in your app.

layer = L.tileLayer.OSOpenSpace(...);


Download these dependencies and import into your project so that this OS OpenSpace layer can work.

Note: The order of import should be as above; Leaflet, Proj4js, Proj4Leaflet and then OS OpenSpace layer - see the demo for an example.

Register for an API key

Ordnance Survey require an API key for use with their tile service, head over to OS OpenSpace to register before using on own website.

This layer uses the OS Openspace Free service and with the mapstack or products configured for the best experience available with the Free service.

Note: This will work locally an key; both localhost and file:/// hostname and protocol override the hostname check.

Displaying a map

The os-leaflet project extends Leaflet's L.TileLayer.WMS class and integrates easily with Leaflet.

To use the Layer in your map just get the L.Proj.CRS - Coordinate Reference System, how the earth is represented in this part of the world - via a factory method.

var osgbCrs = L.OSOpenSpace.getCRS();

Create a L.Map as normal but specify the L.Proj.CRS created above and set Leaflet options continuousWorld to true and worldCopyJump to false. The zoom levels available are essentially the layers provided by this OSOpenSpace layer so set these as below.

var map = new L.Map('map', {
  crs: L.OSOpenSpace.getCRS(),
  continuousWorld: true,
  worldCopyJump: false,
  minZoom: 0,
  maxZoom: L.OSOpenSpace.RESOLUTIONS.length - 1,

Finally, create a new L.TileLayer.OSOpenSpace and add to the map instance as normal. L.TileLayer.OSOpenSpace takes two params, (apiKey, options) as (String, Object) - the apiKey should be the Ordnance Survey OpenSpace API key for the website domain name to be used.

var openspaceLayer = L.tileLayer.OSOpenSpace("<API Key>", {});


Don't forget to set the map centre to somewhere in Great Britain too.

See our demo for an example of using the layer.


This layer is currently hard-coded to work with only Ordnance Survey products with 200x200 pixel tiles are working at the moment, the resolutions available are below.

// OV0, OV1, OV2, MSR, MS, 250KR, 250K, 50KR, 50K, VMD
[2500, 1000, 500, 200, 100, 50, 25, 10, 5, 2.5]

For the full spec, see OS website.


Please open an issue for any problems.


Please use the GitHub pull-request mechanism to submit contributions.


This project is available for use under the MIT software license. See LICENSE