Last active
October 1, 2021 12:28
-
-
Save emacgillavry/df319ff977f3ca848c6ec794698ea96c to your computer and use it in GitHub Desktop.
Luchtfoto 2020 (Web Mercator) in OpenLayers 4
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="nl"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Luchtfoto 2020 (Web Mercator) in OpenLayers</title> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width"> | |
<meta name="author" content="Edward Mac Gillavry"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/openlayers/4.6.4/ol.css"> | |
<link rel="stylesheet" href="main.css"> | |
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script> | |
</head> | |
<body> | |
<div id="map-canvas"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/openlayers/4.6.4/ol.js"></script> | |
<script src="main.js"></script> | |
</body> | |
</html> |
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
html, body, #map-canvas { | |
margin: 0; | |
padding: 0; | |
height: 100%; | |
} | |
#map-canvas { | |
width: 100%; | |
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAMAAABhq6zVAAAACVBMVEUAAADl5eX////EwbxGAAAAAXRSTlMAQObYZgAAABFJREFUeAFjYESCKACdT38ZAAWhAAxcPQc7AAAAAElFTkSuQmCC) repeat scroll 0 0 #f9f9f9; | |
} |
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
var map = new ol.Map({ | |
layers: [ | |
new ol.layer.Tile({ | |
source: new ol.source.XYZ({ | |
attributions: 'Kaartgegevens: © <a href="https://www.kadaster.nl">Kadaster</a>', | |
url: 'https://service.pdok.nl/hwh/luchtfotorgb/wmts/v1_0/Actueel_ortho25/EPSG:3857/{z}/{x}/{y}.jpeg' | |
}) | |
}) | |
], | |
target: 'map-canvas', | |
controls: ol.control.defaults({ | |
attributionOptions: { | |
collapsible: false | |
} | |
}), | |
view: new ol.View({ | |
minZoom: 6, | |
maxZoom: 20, | |
// These coordinates (degrees) are in WGS84! | |
center: new ol.proj.fromLonLat([4.8339212,52.3546449]), | |
// These coordinates (meters) are in Web Mercator too! | |
// center: [631711.827985, 6856275.890632], | |
zoom: 12 | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment