Created
March 24, 2019 12:59
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> | |
<title>OFM charts OpenLayers example</title> | |
<link rel="stylesheet" href="https://openlayers.org/en/v5.3.0/css/ol.css" type="text/css"> | |
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x --> | |
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script> | |
<script src="https://openlayers.org/en/v5.3.0/build/ol.js"></script> | |
<style> | |
html, body { | |
margin: 0; | |
padding: 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map" class="map" style="width: 100%; height: 100%; position:fixed"></div> | |
<script> | |
var ofmSource = new ol.source.XYZ(); | |
<!-- WARNING!!!!!!!!! CHANGE 1903 IN THE URL TO THE CURRENT AIRAC CYCLE --> | |
ofmSource.setUrl('https://snapshots.openflightmaps.org/live/1903/tiles/world/noninteractive/epsg3857/merged/512/latest/{z}/{x}/{y}.png'); | |
var map = new ol.Map({ | |
layers: [ | |
new ol.layer.Tile({ | |
source: ofmSource | |
}) | |
], | |
target: 'map', | |
controls: ol.control.defaults({ | |
attributionOptions: { | |
collapsible: false | |
} | |
}), | |
view: new ol.View({ | |
center: ol.proj.transform([13.5257174, 56.1670695], 'EPSG:4326', 'EPSG:3857'), | |
zoom: 9, | |
minZoom: 6, | |
maxZoom: 11, | |
}) | |
}); | |
map.on('click', function(ev){ | |
alert("You clicked near: " + ol.proj.transform(ev.coordinate, 'EPSG:3857', 'EPSG:4326')); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment