Last active
January 10, 2017 10:10
-
-
Save jirik/bfe849903aa94e068c6aad590a43c009 to your computer and use it in GitHub Desktop.
OpenStreetMap Vector Tiles in S-JTSK / Krovak East North (EPSG:5514)
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/c/cb/Flag_of_the_Czech_Republic.svg' style='width:40px;'> | |
| <h3>OpenStreetMap Vector Tiles in<br/>S-JTSK / Krovak East North (EPSG:5514)</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.42nveuf5'; | |
| //waters are somehow broken -> change it's color | |
| glStyle.layers[5].paint['fill-color']='hsl(47, 26%, 88%)'; | |
| //glStyle.layers[5].visibility='none'; | |
| var map = new mapboxgl.Map({ | |
| container: 'map', // container id | |
| style: glStyle, | |
| center: xy2ll([-544006.67, -1144002.81]), // starting position | |
| zoom: 10 | |
| }); | |
| 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