Openlayer DOP (DEV)
by LandsD Map API
HTML
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css">
<div id="map" class="map"></div>
CSS
html,
body,
#map {
height: 100%;
width: 100%;
margin: 0;
}
.ol-attribution.ol-uncollapsible {
bottom: 73px;
}
.ol-attribution:not(.ol-collapsed) {
background: transparent;
}
.text-align {
color: #333;
font-size: 10px;
font-family: sans-serif;
text-align: right;
}
JavaScript
// resize map
const mapdiv = document.getElementById('map');
var margin;
if (document.all) {
margin = parseInt(document.body.currentStyle.marginTop, 10) + parseInt(document.body.currentStyle.marginBottom, 10);
} else {
margin = parseInt(document.defaultView.getComputedStyle(document.body, '').getPropertyValue('margin-top')) + parseInt(document.defaultView.getComputedStyle(document.body, '').getPropertyValue('margin-bottom'));
}
mapdiv.style.height = (window.innerHeight - margin) + 'px';
/////
var apikey = 'f4d3e21d4fc14954a1d5930d4dde3809' //landsd.azure-api.net starter key
var map = new ol.Map({
target: 'map',
controls: ol.control.defaults({
attributionOptions: ({
collapsible: false
})
}),
layers: [
new ol.layer.Tile({
source: new ol.source.XYZ({
attributions: '<table><tr><th class="text-align"><span style="background-color:#FFFFFFB2">Image ©2002 NASA/USGS</span></th><td rowspan="2"></td></tr><tr><th class="text-align"><span style="background-color:#FFFFFFB2">Image ©2016 NASA/USGS</span></th></tr><tr><th class="text-align"><span style="background-color:#FFFFFFB2">Contains modified Copernicus Sentinel data [2022]</spa</th></tr><tr><th class="text-align"><a href="https://api.portal.hkmapservice.gov.hk/disclaimer" target="_blank" class="copyrightDiv"><span style="background-color:#FFFFFFB2">©Map information from Lands Department</span></a></th><td rowspan="2"><div style="width:28px;height:28px;display:inline-flex;background:url(https://api.hkmapservice.gov.hk/mapapi/landsdlogo.jpg);background-size:28px;"></div></td></tr></table>',
url: 'https://landsd.azure-api.net/dev/osm/xyz/worldImagery/WGS84/tile/{z}/{x}/{y}.png?key=' + apikey
})
}),
new ol.layer.Tile({
source: new ol.source.XYZ({
url: 'https://landsd.azure-api.net/dev/osm/xyz/sclabel-tc/wgs84/tile/{z}/{x}/{y}.png?key=' + apikey
}),
minResolution: 200,
maxResolution: 20000,
})
],
view: new ol.View({
...