Last active
August 29, 2015 14:16
-
-
Save relet/e0d56f89d6be96d0eb50 to your computer and use it in GitHub Desktop.
Kartverket / UTM32
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> | |
<link rel="stylesheet" href="http://openlayers.org/en/v3.0.0/css/ol.css" type="text/css"> | |
<style> | |
.map { | |
height: 600px; | |
width: 800px; | |
} | |
</style> | |
<script src="http://openlayers.org/en/v3.0.0/build/ol.js" type="text/javascript"></script> | |
<title>OpenLayers3 / UTM 32</title> | |
</head> | |
<body> | |
<h2>My Map</h2> | |
<div id="map" class="map"></div> | |
<script type="text/javascript"> | |
var sProjection = 'EPSG:32632'; | |
var extent = { | |
'EPSG:3857': [20037508.34, 20037508.34, 20037508.34, 20037508.34], | |
'EPSG:32633': [-2500000, 3500000, 3045984, 9045984], | |
'EPSG:32632': [-2000000, 3500000, 3545984, 9045984] | |
}; | |
var view = new ol.View({ | |
projection: projection, | |
center: [353975, 6929923], | |
zoom: 10 | |
}); | |
var projection = new ol.proj.Projection({ | |
code: sProjection, | |
extent: extent[sProjection] | |
}); | |
ol.proj.addProjection(projection); | |
var projectionExtent = projection.getExtent(), | |
size = ol.extent.getWidth(projectionExtent) / 256, | |
resolutions = [], | |
matrixIds = []; | |
for (var z = 0; z < 21; ++z) {//Max 18? | |
resolutions[z] = size / Math.pow(2, z); | |
matrixIds[z] = sProjection+":"+z; | |
} | |
var map = new ol.Map({ | |
target: 'map', | |
layers: [ | |
new ol.layer.Tile({ | |
title: "Norges grunnkart", | |
source: new ol.source.WMTS({ | |
url: "http://cache.kartverket.no/grunnkart/wmts?", | |
layer: "norges_grunnkart", | |
matrixSet: sProjection, | |
format: 'image/png', | |
projection: projection, | |
tileGrid: new ol.tilegrid.WMTS({ | |
origin: ol.extent.getTopLeft(projection.getExtent()), | |
resolutions: resolutions, | |
matrixIds: matrixIds | |
}), | |
style: 'default' | |
}) | |
}) | |
], | |
view: view | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment