All Projects β†’ rob-murray β†’ os-leaflet

rob-murray / os-leaflet

Licence: MIT License
A Leafletjs TileLayer using Ordnance Survey OpenSpace web map service

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to os-leaflet

map
πŸ³οΈβ€πŸŒˆπŸ—Ί A map of community centers and other helpful information for queer (LGBTQ) people.
Stars: ✭ 15 (-34.78%)
Mutual labels:  leafletjs
mapus
A map tool with real-time collaboration πŸ—ΊοΈ
Stars: ✭ 2,687 (+11582.61%)
Mutual labels:  leafletjs
web-maps-wcag-evaluation
Manual accessibility evaluation of popular web map tools.
Stars: ✭ 28 (+21.74%)
Mutual labels:  leafletjs
rikitraki
This repository contains the client code of RikiTraki.com, a map-centric hiking log web application.
Stars: ✭ 16 (-30.43%)
Mutual labels:  leafletjs
treetracker-web-map-client
The front end of the treetracker web map app.
Stars: ✭ 37 (+60.87%)
Mutual labels:  leafletjs
leaflet-experiments
Demos and experiments with LeafletJS
Stars: ✭ 20 (-13.04%)
Mutual labels:  leafletjs
Teyvat.moe
A flexible, community-driven interactive website for Genshin Impact.
Stars: ✭ 137 (+495.65%)
Mutual labels:  leafletjs
Leaflet Example
πŸ—Ί An example of how to use Leaflet to create an interactive map.
Stars: ✭ 41 (+78.26%)
Mutual labels:  leafletjs
cogviewer
Simple Cloud Optimized GeoTIFF viewer.
Stars: ✭ 21 (-8.7%)
Mutual labels:  leafletjs
leaflet-map-csv
Simple Leaflet map with points from local CSV file
Stars: ✭ 23 (+0%)
Mutual labels:  leafletjs
harp-leaflet
Leaflet plugin for harp.gl
Stars: ✭ 16 (-30.43%)
Mutual labels:  leafletjs
windy-plugins
🚁extend functionality of Windy.com. Develop your plugin in less than 5 minutes.
Stars: ✭ 147 (+539.13%)
Mutual labels:  leafletjs
datasette-cluster-map
Datasette plugin that shows a map for any data with latitude/longitude columns
Stars: ✭ 51 (+121.74%)
Mutual labels:  leafletjs
community
🌎 REDAXO Community World Map
Stars: ✭ 91 (+295.65%)
Mutual labels:  leafletjs
Leaflet.streetlabels
Display the street labels following polylines for Leaflet
Stars: ✭ 58 (+152.17%)
Mutual labels:  leafletjs
human-computer
A computer that uses nothing but human resources
Stars: ✭ 16 (-30.43%)
Mutual labels:  leafletjs
Leaflet Cluster Example
πŸ—Ί Example of using the clustering plugin with Leaflet
Stars: ✭ 26 (+13.04%)
Mutual labels:  leafletjs
rainviewer-api-example
How to use RainViewer API: simple HTML + JS code which render an animated weather radar overlay on the map
Stars: ✭ 56 (+143.48%)
Mutual labels:  leafletjs
OSMChina-NextOSM
A more modern, designed and easy-to-use UI designed for browsing OpenStreetMap.
Stars: ✭ 17 (-26.09%)
Mutual labels:  leafletjs
leaflet-locationpicker
Simple location picker on Leaflet map
Stars: ✭ 31 (+34.78%)
Mutual labels:  leafletjs

os-leaflet

npm version

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

This project is no way affiliated, nor supported or endorsed by Ordnance Survey. Please review Ordnance Survey OpenSpace service terms and conditions

Description

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.

ScreenShot

Versions

Version 1.x supports Leaflet 1.0, we depend on other Leaflet 1.0 compatible libraries too.

If you are using Leaflet version < 1.0 then please use v0.2.1 of this library, or the 0.2-stable branch.

Contents

This repository contains the following sections:

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

Getting started

You can get hold of the code using 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.

require('os-leaflet');
layer = L.OSOpenSpace.tilelayer(apiKey, apiUrl, ...options);

Manually

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 EPSG:27700 L.Proj.CRS (Coordinate Reference System - how the earth is represented on Ordnance Survey maps) - via a factory method as below.

var osgbCrs = L.OSOpenSpace.CRS;

Create a L.Map as normal but specify the L.Proj.CRS from this library, see example below. The zoom levels available are essentially the layers provided by this OSOpenSpace layer so set these as below.

var map = new L.Map('map', {
  zoom: 6,
  crs: L.OSOpenSpace.CRS,
});

Finally, create a new L.TileLayer via the factory method L.OSOpenSpace.tilelayer and add to the map instance as normal. L.OSOpenSpace.tilelayer accepts the parameters below.

Argument Required? Description
apiKey Yes The Ordnance Survey OpenSpace API key for the website domain name to be used.
apiUrl No The URL of your site associated with the API key, as provided to OSOpenSpace
options No An object of layer options to pass to the tilelayer
var options = {};
var openspaceLayer = L.OSOpenSpace.tilelayer("<API Key>", "<API URL>", options);
map.addLayer(openspaceLayer);

Don't forget to set the map centre to somewhere in Great Britain too πŸ˜‰

Example

Check out the demo for an example of how to use the layer.

Map products

This layer is currently hard-coded to work with only Ordnance Survey products that have 200x200 pixel tiles at the moment, the resolutions available are below. Other products have varying tile sizes which don't play well with Leaflet, it prefers a power-of-2 stack.

// 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.

Coordinates

Points can be added to the map in WGS84 reference system - if you have British National Grid coords then these should be converted.

L.polygon([
  [50.978633, -1.5740458],
  [51.068553, -1.5732215],
  [51.067945, -1.4305097],
  [50.978027, -1.4316098]
]).addTo(map).bindPopup('I am the SU32 10K square');

OS Logo

The Ordnance Survey logo in the bottom left can be removed, along with other attribution, by supplying the option { attributionControl: false } to the map constructor. It it enabled by default.

map = new L.Map('map', {
  zoom: 6,
  crs: L.OSOpenSpace.CRS,
  attributionControl: false
});

Issues

Please open an issue for any problems.

Contributions

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

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].