Created
September 25, 2013 17:20
-
-
Save atlefren/6702948 to your computer and use it in GitHub Desktop.
Small utility for displaying Statkart tiles on a Leaflet map
This file contains 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 lang="en"> | |
<head> | |
<meta http-equiv="X-UA-Compatible" content="IE=8"> | |
<meta charset="UTF-8"> | |
<title>Leaflet with Statkart tiles</title> | |
</head> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" /> | |
<!--[if lte IE 8]> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" /> | |
<![endif]--> | |
<style type="text/css"> | |
html, body { | |
height: 100%; | |
margin: 0; | |
} | |
.map_fullscreen { | |
width: 100%; | |
height: 100%; | |
} | |
</style> | |
<body> | |
<div id="map" class="map_fullscreen"></div> | |
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script> | |
<script type="text/javascript"> | |
(function () { | |
//this could (should?) be moved to a separate file | |
var leafletUtils = window.leafletUtils || {}; | |
leafletUtils.SkTiles = function (options) { | |
/** | |
Tiles from Statkart. Available layers are: | |
- matrikkel_bakgrunn | |
- topo2 | |
- topo2graatone | |
- europa | |
- toporaster2 | |
- sjo_hovedkart2 | |
- kartdata2 | |
- norges_grunnkart | |
- norges_grunnkart_graatone | |
See http://statkart.no/Kart/Kartverksted/Visningstjenester/ | |
**/ | |
return L.tileLayer( | |
'http://opencache.statkart.no/gatekeeper/gk/gk.open_gmaps?layers=' + options.layers + '&zoom={z}&x={x}&y={y}', { | |
attribution: "© <a href='http://statkart.no'>Kartverket</a>" | |
}) | |
}; | |
var map = L.map('map').setView([64.5, 15], 5); | |
leafletUtils.SkTiles({layers: "topo2"}).addTo(map); | |
}()); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment