var apiKey = 'https://api.os.uk/maps/raster/v1/wmts?key=YujFKUCKInwKlriGiywwTjGwnA5WukGF';
var serviceUrl = 'https://api.os.uk/maps/raster/v1/zxy';
// Setup the EPSG:27700 (British National Grid) projection. var 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 +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +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 ] });
// Initialize the map. var mapOptions = { crs: crs, minZoom: 0, maxZoom: 9, center: proj4('EPSG:27700', 'EPSG:4326', [ 337297, 503695 ]).reverse(), zoom: 7, attributionControl: false };
var map = L.map('map', mapOptions);
// Load and display ZXY tile layer on the map. var basemap = L.tileLayer(serviceUrl + '/Leisure_27700/{z}/{x}/{y}.png?key=' + apiKey).addTo(map);