Last active
January 10, 2017 10:17
-
-
Save jirik/8380a15071ba4d9fb74ee291b6127bbd to your computer and use it in GitHub Desktop.
OpenStreetMap Vector Tiles in OSGB 1936 / British National Grid (EPSG:27700)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset='utf-8' /> | |
| <title></title> | |
| <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | |
| <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.19.1/mapbox-gl.js'></script> | |
| <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.19.1/mapbox-gl.css' rel='stylesheet' /> | |
| <style> | |
| body { margin:0; padding:0; } | |
| #map { position:absolute; top:0; bottom:0; width:100%; } | |
| </style> | |
| </head> | |
| <body> | |
| <style type='text/css'> | |
| #info { | |
| display: block; position: relative; margin: 0px auto; width: 50%; padding: 10px; border: none; border-radius: 3px; font-size: 12px; text-align: center; color: #222; background: #fff; } | |
| #klokantech { | |
| display: block; position: absolute; background-color: rgba(255,255,255,0.8); padding:0; left: 0px; bottom: 0px; } | |
| #klokantech img { | |
| width:250px; | |
| } | |
| </style> | |
| <div id='map'></div> | |
| <pre id='info'> | |
| <img src='https://upload.wikimedia.org/wikipedia/commons/1/17/Union_flag_1606_%28Kings_Colors%29.svg' style='width:40px;'> | |
| <h3>OpenStreetMap Vector Tiles in<br/>OSGB 1936 / British National Grid (EPSG:27700)</h3> | |
| <p id="coord" style="font-size:3em;"></p> | |
| </pre> | |
| <div id="klokantech"><a href='http://www.klokantech.com/'><img src='http://cdn.klokantech.com/tileviewer/v1/tileserver-klokantech-logo.png' border=0 alt='Developed by Klokan Technologies GmbH'></a></div> | |
| <script> | |
| function ll2xy(ll) { return [ 6378137.0 * ll[0] * Math.PI/180, 6378137.0 * Math.log(Math.tan((Math.PI*0.25) + (0.5 * ll[1] * Math.PI/180))) ]}; | |
| function xy2ll(xy) { return [ xy[0] * 180/Math.PI / 6378137.0, ((Math.PI*0.5) - 2.0 * Math.atan(Math.exp(-xy[1] / 6378137.0))) * 180/Math.PI ]}; | |
| mapboxgl.accessToken = 'pk.eyJ1Ijoib3Blbm1hcHRpbGVzIiwiYSI6ImNpdnY3eTJxZzAwMGMyb3BpdWJmajcxNzcifQ.hP1BxcxldIhakMcPSJLQ1Q'; | |
| fetch('https://openmaptiles.github.io/klokantech-basic-gl-style/style-cdn.json').then(function(response) { | |
| response.json().then(function(glStyle) { | |
| //glStyle.sources.openmaptiles.url = 'http://localhost:8080/data/openmaptiles.json'; | |
| glStyle.sources.openmaptiles.url = 'mapbox://openmaptiles.cexkqd44'; | |
| var map = new mapboxgl.Map({ | |
| container: 'map', // container id | |
| style: glStyle, | |
| center: xy2ll([308165.30, 607733.40]), // starting position | |
| zoom: 7 | |
| }); | |
| map.on('mousemove', function (e) { | |
| var xy = ll2xy([e.lngLat.lng, e.lngLat.lat]) | |
| document.getElementById('coord').innerHTML = | |
| xy[1].toFixed(2) + ' ' + xy[0].toFixed(2); | |
| }); | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment