os-leaflet icon indicating copy to clipboard operation
os-leaflet copied to clipboard

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

Open saturdaywalkers opened this issue 4 years ago • 5 comments

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' + 'style=default&layer=Outdoor_3857&tileMatrixSet=EPSG:3857&tileMatrix={z}&tileRow={y}&tileCol={x}'

please could you see if its worth supporting...

andrew

saturdaywalkers avatar Apr 30 '20 21:04 saturdaywalkers

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

saturdaywalkers avatar May 09 '20 16:05 saturdaywalkers

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

rob-murray avatar May 11 '20 20:05 rob-murray

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 avatar Jul 03 '20 13:07 saturdaywalkers

// 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 ],
  } );

saturdaywalkers avatar Jul 03 '20 16:07 saturdaywalkers

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.

rob-murray avatar Jul 04 '20 06:07 rob-murray