rob-murray / os-leaflet

A Leafletjs TileLayer using Ordnance Survey OpenSpace web map service
http://rob-murray.github.io/os-leaflet/
MIT License
24 stars 8 forks source link

add support for https://osdatahub.os.uk/ (has free tier) #29

Open saturdaywalkers opened 4 years ago

saturdaywalkers commented 4 years ago

miracles can happen!

well, maybe

https://osdatahub.os.uk/ now has a free tier

it just doesn't give an example of what the tile sets look like, and if they include the 1:25 & 1:50 mapping

it supports osgb and web-mercator projections ... but not for all tile sets

Road | EPSG:27700 | Road_27700 | EPSG:27700 Road | EPSG:3857 | Road_3857 | EPSG:3857 Outdoor | EPSG:27700 | Outdoor_27700 | EPSG:27700 Outdoor | EPSG:3857 | Outdoor_3857 | EPSG:3857 Light | EPSG:27700 | Light_27700 | EPSG:27700 Light | EPSG:3857 | Light_3857 | EPSG:3857 Leisure | EPSG:27700 | Leisure_27700 | EPSG:27700

I've checked 'outdoor'. No footpaths.

The 'leisure' tile set is in osgb only, so i cant check it

This might help for use with leaflet 'https://osdatahubapi.os.uk/OSMapsAPI/wmts/v1?key=API_KEY&service=WMTS&request=GetTile&outputformat=image/png'

please could you see if its worth supporting...

andrew

saturdaywalkers commented 4 years ago

@rob-murray Just to clarify, the 3 x '3857' tile layers can be used direct in leaflet with a wms plugin. It's the 'Leisure_27700' layer (with no matching 3857 equivalent) that I curious about. I'm hoping "os-leaflet" can be repurposed to access it, and further hoping its the same mapping as openspace is/was.

rob-murray commented 4 years ago

Thanks - I have not kept up to date with OS web mapping API offerings, but will try and have a look at these and see if they can be integrated. Ideally OS APIs should just work with Leaflet much easier

saturdaywalkers commented 4 years ago

Well. A miracle has happened. Hopefully.

"osdatahub" is now live. it contains an example of: leaflet + OS mapping + OSGB projection https://labs.os.uk/public/os-data-hub-examples/os-maps-api/zxy-27700-basic-map

(so, unlike Bing, no OS mapping with an web-mercator projection - the only bad point)

The example is quite simple - and also uses proj4js, and proj4leaflet :)

There's a £1,000 per month worth of map tiles "free" tier - which they say works out to quite a lot.

From what I understand, 1:200K ("road atlas scale") and above tiles are zero rated.

Andrew

saturdaywalkers commented 4 years ago
// need leaflet, proj4js, proj4leaflet libs
// need lat, lon, zoom, os data hub api key
let key = 'your key', url_base = 'https://api.os.uk/maps/raster/v1/zxy';
let crs = new L.Proj.CRS( 
  'EPSG:27700',
  '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs',
  { resolutions: [ 896.0, 448.0, 224.0, 112.0, 56.0, 28.0, 14.0, 7.0, 3.5, 1.75 ], origin: [ -238375.0, 1376256.0 ] }
  );

let os_gb_tile_layer = L.tileLayer( `${ url_base }/Leisure_27700/{z}/{x}/{y}.png?key=${ key }` );
let map = new L.Map(  "dom_id", { 
  center: [lat, lon], 
  crs: crs,
 minZoom: 0, maxZoom: 9,
 zoom: zoom - 7, // correction from os gb layer no. to web mercator layer no, floor=0, ceiling=9
 'layers'   : [ os_gb_tile_layer ],
  } );
rob-murray commented 4 years ago

Thanks 👍 I've only had a quick look so far but those examples with the new map tile API are so simple this library isnt needed anymore. I created this because it was a pain and needed a bit of code to get it working with OS OpenSpace but if that service is replaced with this better zxy API then it would be better to use that - providing you can pay the cost.