OS API Resources
Code Playground
Auto-refresh
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Web Maps | Basic Map | Leaflet</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/OrdnanceSurvey/os-api-branding@latest/os-api-branding.css" /> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" /> <style> body { margin:0; padding:0; } #map { position:absolute; top:0; bottom:0; width:100%; } </style> </head> <body> <div id="map"></div> <script src="https://cdn.jsdelivr.net/gh/OrdnanceSurvey/os-api-branding@latest/os-api-branding.js"></script> <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script> <script> const apiKey = 'g26a1Jhsts0w627Ic3umWPogmsfEqMpp'; // Initialize the map. const mapOptions = { minZoom: 7, maxZoom: 16, center: [ 54.425, -2.968 ], zoom: 14, maxBounds: [ [ 49.528423, -10.76418 ], [ 61.331151, 1.9134116 ] ], attributionControl: false }; const map = L.map('map', mapOptions); // Load and display ZXY tile layer on the map. const basemap = L.tileLayer(`https://api.os.uk/maps/raster/v1/zxy/Light_3857/{z}/{x}/{y}.png?key=${apiKey}`, { maxZoom: 20 }).addTo(map); </script> </body> </html>